fsevents

How to listen for file system changes MAC - kFSEventStreamCreateFlagWatchRoot

♀尐吖头ヾ 提交于 2019-12-31 22:25:52
问题 I am listening for Directory and disk changes in a Cocoa project using FSEvents . I need to get events when a root folder is renamed or deleted. So, I passed kFSEventStreamCreateFlagWatchRoot while creating the FSEventStream . But even if I delete or rename the root folder I am not getting corresponding FSEventStreamEventFlags . Any idea what could possibly be the issue. I am listening for changes in a USB mounted device. I used both FSEventStreamCreate and FSEventStreamCreateRelativeToDevice

How to detect if a file was closed?

独自空忆成欢 提交于 2019-12-24 15:55:20
问题 is it possible to detect if a file (e.g. a pdf file opened in preview) was closed? The FSEvents API does not fire such an event. Maybe I could observe the associated process or something like that?! 回答1: Yes there is the way that you can find out whether file has been closed or not. So below i tried with unix lsof -t yourFilePath command to determine the same and hence have implemented the same in cocoa. Please follow below here lsof -t yourFilePath will give you the process id of only open

How to determine if a file copy is completed using cocoa

China☆狼群 提交于 2019-12-22 15:02:29
问题 I am developing folder watcher application for MAC in XCode using Foundation framework and FSEvents API. I need to know whether the file has been completely copied to the destination before I open the file for other operation. Is there any way of knowing it? please advice 回答1: From simply studying the FSEvents API I would say that what you want is not possible. I could be mistaken, though, I have never used FSEvents myself. The asker of this question has solved the problem by separately

How to determine if a file copy is completed using cocoa

白昼怎懂夜的黑 提交于 2019-12-22 15:02:06
问题 I am developing folder watcher application for MAC in XCode using Foundation framework and FSEvents API. I need to know whether the file has been completely copied to the destination before I open the file for other operation. Is there any way of knowing it? please advice 回答1: From simply studying the FSEvents API I would say that what you want is not possible. I could be mistaken, though, I have never used FSEvents myself. The asker of this question has solved the problem by separately

Not compatible with your operating system or architecture: fsevents@1.0.11

爷,独闯天下 提交于 2019-12-20 09:21:54
问题 I'm using Ubuntu 15.04. While running the following command: npm install fsevents I'm getting following error: npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.11 npm WARN tutorial@1.0.0 No repository field. Has anybody solved this? 回答1: I was facing the same issue with this dependecy when building other application. Just for the sake of knowledge and to people who are not well

FSEvents weirdness on OS X Leopard

痞子三分冷 提交于 2019-12-20 03:30:34
问题 I want to monitor file-system events for a couple of directories on the mac. The directories I want to monitor might change at runtime, so using FSEvents here's what my app does: creates a global callback function to handle callbacks create a new FSEventStreamRef per folder, associating it with the callback created above and adding a context to the eventStream that helps me associate the change callback with this folder Stuff seems to mostly work, but I've noticed some weirdness in when the

FSEvents and copying large files

﹥>﹥吖頭↗ 提交于 2019-12-18 16:53:01
问题 I'm using FSEvents to monitor a directory of files that will have some large files copied into it. Currently FSEvents seems to be sending out a notification when I've begun copying the file, and again when it's finished copying the file. When it's a smaller file though, I only get the one event. Is there any way to check if a file is in the middle of being copied? This is for Snow Leopard by the way. 回答1: I ended up just using lsof to check if the file is open at a kernel level. I only begin

tracking file renaming/deleting with FSEvents on Lion

送分小仙女□ 提交于 2019-12-18 12:58:20
问题 I'm trying to use FSEvents to detect when files were added/removed from a specific folder. For the moment, I implemented a simple wrapper around FSEvents, and it works fine : I get all the events. BUT the problem I have now is that when I rename a file in the Finder, I catch 2 distinct events : the first one of type "renamed" with the old file name, and another one with "renamed" and the new filename. The event ids are different between both calls. So, how am I supposed to know which "renamed

How to use the File System Events API in Swift?

余生长醉 提交于 2019-12-12 16:04:41
问题 maybe my search terms are not good today, but i can't find a simple example how to use the FSEvents in swift. I have a cocoa application that displays contents from a file. When the file is changed outside of my application i have to mark the reload-button in another color. I thing FSEvents is the right place to look for this, or should I use another API? Can you give me an example of how to revive an event when a file has changed the content? Thank you very much. 回答1: After looking again I

Use FSEvents in sandboxed app

混江龙づ霸主 提交于 2019-12-12 08:48:16
问题 I'm trying to use FSEvents in my sandboxed app to monitor some directories. I implemented the following class: @implementation SNTracker - (id)initWithPaths:(NSArray *)paths { self=[super init]; if (self) { trackedPaths=paths; CFTimeInterval latency=1.0; FSEventStreamContext context={0,(__bridge void *)self,NULL,NULL,NULL}; FSEventStreamRef eeventStream=FSEventStreamCreate(kCFAllocatorDefault,&callback,&context,(__bridge CFArrayRef)trackedPaths,kFSEventStreamEventIdSinceNow,latency