How can know a file is hidden?

  • Dear all,

          I want to know a file is hidden.How can i do?Waiting for you help.
  • Hi,

    You can get the kLSItemIsInvisible attribute using
    LSCopyItemAttributes() function. In addition to this you should also
    check if a file begins with a dot ('.').

    Diederik

    --
    Diederik Hoogenboom
    Twitter: obviousmatter

    Obvious Matter - DiskLibrary for Mac
    http://www.obviousmatter.com

    On 26 dec 2007, at 09:25, shengjun_guan (ºÞÁn«T) wrote:

    > Dear all,
    >
    > I want to know a file is hidden.How can i do?Waiting for you
    > help.
    >
  • http://lists.apple.com/archives/cocoa-dev/2002/May/msg00039.html

    But there is a mistake of "infoRec" in the code which seems to be
    "infoRef"

    On Dec 26, 2007, at 4:39 PM, Diederik Hoogenboom wrote:

    > Hi,
    >
    > You can get the kLSItemIsInvisible attribute using
    > LSCopyItemAttributes() function. In addition to this you should
    > also check if a file begins with a dot ('.').
    >
    > Diederik
    >
    > --
    > Diederik Hoogenboom
    > Twitter: obviousmatter
    >
    > Obvious Matter - DiskLibrary for Mac
    > http://www.obviousmatter.com
    >
    >
    >
    >
    > On 26 dec 2007, at 09:25, shengjun_guan (管�俊) wrote:
    >
    >> Dear all,
    >>
    >> I want to know a file is hidden.How can i do?Waiting for you
    >> help.
    >>

    >

    =============================================
    Qi Liu
    E-Mail: <qliu...>
    --You only get one shot, do not miss your chance to blow.
    This opportunity comes once in a lifetime.
    =============================================
  • Must be a typo in the example. Should have been:

    NSURL* someURL=getURLFromSomePlace;
    LSItemInfoRecord infoRec;
    OSStatus err=noErr;

    err=LSCopyItemInfoForURL((CFURLRef)someURL,
    kLSRequestBasicFlagsOnly,&infoRec);
    if (!err && ((infoRec.flags&kLSItemInfoIsInvisible) || [[[someURL
    path] lastPathComponent] hasPrefix:@"."]))
    {
    //file is invisible
    }

    --
    Diederik Hoogenboom

    Obvious Matter - DiskLibrary for Mac
    http://www.obviousmatter.com

    On 26 dec 2007, at 10:13, Constantine wrote:

    > http://lists.apple.com/archives/cocoa-dev/2002/May/msg00039.html
    >
    > But there is a mistake of "infoRec" in the code which seems to be
    > "infoRef"
    >
    > On Dec 26, 2007, at 4:39 PM, Diederik Hoogenboom wrote:
    >
    >> Hi,
    >>
    >> You can get the kLSItemIsInvisible attribute using
    >> LSCopyItemAttributes() function. In addition to this you should
    >> also check if a file begins with a dot ('.').
    >>
    >> Diederik
    >>
    >> --
    >> Diederik Hoogenboom
    >> Twitter: obviousmatter
    >>
    >> Obvious Matter - DiskLibrary for Mac
    >> http://www.obviousmatter.com
    >>
    >>
    >>
    >>
    >> On 26 dec 2007, at 09:25, shengjun_guan (管�俊) wrote:
    >>
    >>> Dear all,
    >>>
    >>> I want to know a file is hidden.How can i do?Waiting for you
    >>> help.
    >>>

    >>
    >
    > =============================================
    > Qi Liu
    > E-Mail: <qliu...>
    > --You only get one shot, do not miss your chance to blow.
    > This opportunity comes once in a lifetime.
    > =============================================
    >
    >
    >
    >
  • I actually don't think you need to do the dot-prefix check in Tiger or
    later (didn't try older OSes).

    Diederik Hoogenboom wrote:
    > Must be a typo in the example. Should have been:
    >
    > NSURL* someURL=getURLFromSomePlace;
    > LSItemInfoRecord infoRec;
    > OSStatus err=noErr;
    >
    > err=LSCopyItemInfoForURL((CFURLRef)someURL,
    > kLSRequestBasicFlagsOnly,&infoRec);
    > if (!err && ((infoRec.flags&kLSItemInfoIsInvisible) || [[[someURL
    > path] lastPathComponent] hasPrefix:@"."]))
    > {
    > //file is invisible
    > }
    >
    >
    > --
    > Diederik Hoogenboom
    >
    > Obvious Matter - DiskLibrary for Mac
    > http://www.obviousmatter.com
    >
    >
    >
    >
    > On 26 dec 2007, at 10:13, Constantine wrote:
    >
    >> http://lists.apple.com/archives/cocoa-dev/2002/May/msg00039.html
    >>
    >> But there is a mistake of "infoRec" in the code which seems to be
    >> "infoRef"
    >>
    >> On Dec 26, 2007, at 4:39 PM, Diederik Hoogenboom wrote:
    >>
    >>> Hi,
    >>>
    >>> You can get the kLSItemIsInvisible attribute using
    >>> LSCopyItemAttributes() function. In addition to this you should also
    >>> check if a file begins with a dot ('.').
    >>>
    >>> Diederik
    >>>
    >>> --
    >>> Diederik Hoogenboom
    >>> Twitter: obviousmatter
    >>>
    >>> Obvious Matter - DiskLibrary for Mac
    >>> http://www.obviousmatter.com
    >>>
    >>>
    >>>
    >>>
    >>> On 26 dec 2007, at 09:25, shengjun_guan (管�俊) wrote:
    >>>
    >>>> Dear all,
    >>>>
    >>>> I want to know a file is hidden.How can i do?Waiting for you
    >>>> help.
    >>>>

    >>>
    >>
    >> =============================================
    >> Qi Liu
    >> E-Mail: <qliu...>
    >> --You only get one shot, do not miss your chance to blow.
    >> This opportunity comes once in a lifetime.
    >> =============================================
    >>
    >>
    >>
    >>

  • You do not need to check for a leading dot when using LaunchServices
    to determine file visibility via kLSItemIsInvisible. LS takes care of
    this for you.

    --
    m-s

    On 26 Dec, 2007, at 03:39, Diederik Hoogenboom wrote:

    > Hi,
    >
    > You can get the kLSItemIsInvisible attribute using
    > LSCopyItemAttributes() function. In addition to this you should also
    > check if a file begins with a dot ('.').
    >
    > Diederik
    >
    > --
    > Diederik Hoogenboom
    > Twitter: obviousmatter
    >
    > Obvious Matter - DiskLibrary for Mac
    > http://www.obviousmatter.com
    >
    >
    >
    >
    > On 26 dec 2007, at 09:25, shengjun_guan (ºÞÁn«T) wrote:
    >
    >> Dear all,
    >>
    >> I want to know a file is hidden.How can i do?Waiting for you
    >> help.
    >>

previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today