• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to check whether directory tree has changed?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to check whether directory tree has changed?


  • Subject: Re: How to check whether directory tree has changed?
  • From: Sandor Szatmari via Cocoa-dev <email@hidden>
  • Date: Sat, 21 Dec 2019 12:33:02 -0500

I’ve used dispatch stuff.  I found this with a quick google… it should be close
to what one would need to monitor a folder.
int fildes = open("/path/to/directory", O_RDONLY);

dispatch_queue_t queue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE,
fildes, DISPATCH_VNODE_DELETE | DISPATCH_VNODE_WRITE | DISPATCH_VNODE_EXTEND |
DISPATCH_VNODE_RENAME | DISPATCH_VNODE_REVOKE, queue);

dispatch_source_set_event_handler(source, ^{
// ... handle changes
});

dispatch_source_set_cancel_handler(source, ^{
// ... handle cancel
});

dispatch_resume(source); // Start monitoring

// And sometime later
dispatch_source_cancel(source); // Stop monitoring

> On Dec 21, 2019, at 11:08, Gabriel Zachmann via Cocoa-dev
> <email@hidden> wrote:
>
> Is there a quick and easy way to check whether or not a directory tree has
> changed?
>
> I am only interested in file additions or deletions, somewhere beneath a
> specific root directory,
> e.g., ~/Data/some_directory.
>
> However, I am interested in such changes between different invocations of my
> program.
> So, when the user adds a file somewhere in the directory tree while my
> program is not running, I'd still like to detect that.
>
> Is there a quick and easy way to do this?
>
> Thanks a lot in advance.
> Best regards, Gabriel
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to check whether directory tree has changed?
      • From: Gabriel Zachmann via Cocoa-dev <email@hidden>
References: 
 >How to check whether directory tree has changed? (From: Gabriel Zachmann via Cocoa-dev <email@hidden>)

  • Prev by Date: How to check whether directory tree has changed?
  • Next by Date: Re: How to check whether directory tree has changed?
  • Previous by thread: How to check whether directory tree has changed?
  • Next by thread: Re: How to check whether directory tree has changed?
  • Index(es):
    • Date
    • Thread