NSFileManager directory lists and hidden files

  • I am trying to write something using kqueue to monitor a directory. It is my understanding that for file creation I will be told a directory has been written to and I then have to list the directory myself to determine the file added.

    I add the original directory path files using enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: which I gather is the preferred deep, subdirectories included, lister choice.
    This seems to have an option to omit hidden files. I am not using it but  still do not seem to get .DS_Store

    When I receive a kqueue event that a directory has been written to I attempt to use contentsOfDirectoryAtPath to get a shallow, no subdirectories, list I can check for a file I didn't previously know about. This list does appear to include .DS_Store, the result being that I keep thinking this is the file being created.

    2012-07-07 17:30:56.658 java[1680:5003] UKKQueue: Detected file change: /Users/mjh/trz/
        [exec] 2012-07-07 17:30:56.664 java[1680:5003] created .DS_Store
        [exec] 2012-07-07 17:30:56.665 java[1680:5003] UKKQueue: Detected file change: /Users/mjh/trz/
        [exec] 2012-07-07 17:30:56.667 java[1680:5003] created .DS_Store

    The code based on UK source as you see.
    Although I don't think relevant you might also note the java as this is being run off of jni.
    I just created another hidden file just to verify enumeratorAtURL would default skip it and it seems to default ignore.

    How do I get the enumeratorAtURL to include the .DS_Store files. Or do I have to add my own filter to contentsOfDirectoryAtPath to skip hidden files for consistency?
  • On Jul 7, 2012, at 5:58 PM, Michael Hall wrote:

    > How do I get the enumeratorAtURL to include the .DS_Store files.

    It does for me on 10.6.8.  How are you testing for a file you've seen before?  Maybe you did actually get it in the enumeration but your logic for determining if a file is new is wrong.

    Regards,
    Ken
  • On Jul 7, 2012, at 6:48 PM, Ken Thomases wrote:

    > On Jul 7, 2012, at 5:58 PM, Michael Hall wrote:
    >
    >> How do I get the enumeratorAtURL to include the .DS_Store files.
    >
    > It does for me on 10.6.8.  How are you testing for a file you've seen before?  Maybe you did actually get it in the enumeration but your logic for determining if a file is new is wrong.
    >
    > Regards,
    > Ken
    >
    I think this is a never mind. Somewhere in here I'm mixing full and relative paths.
previous month july 2012 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