www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Is there anything in the standard library to help writing a file

reply "Gary Willoughby" <dev kalekold.net> writes:
Is there anything in the standard library to help writing a file 
watcher? I want to monitor a single file for changes and if a 
change is detected call a function. Is there any existing 
libraries to do this in D as it must be cross-platform as much as 
possible?
May 23 2013
parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 23.05.2013 17:26, schrieb Gary Willoughby:
 Is there anything in the standard library to help writing a file
 watcher? I want to monitor a single file for changes and if a change is
 detected call a function. Is there any existing libraries to do this in
 D as it must be cross-platform as much as possible?
I have something like this implemented for windows. It watches a entire directory including subdirectories (optional) and tells you which files changed upon request: https://github.com/Ingrater/thBase/blob/master/src/thBase/directory.d I don't think its possible to imiplement this cross-plattform. You will have to reimplement for every plattform you need it on. Kind Regards Benjamin Thaut
May 23 2013
parent reply David <d dav1d.de> writes:
Am 23.05.2013 17:35, schrieb Benjamin Thaut:
 Am 23.05.2013 17:26, schrieb Gary Willoughby:
 Is there anything in the standard library to help writing a file
 watcher? I want to monitor a single file for changes and if a change is
 detected call a function. Is there any existing libraries to do this in
 D as it must be cross-platform as much as possible?
I have something like this implemented for windows. It watches a entire directory including subdirectories (optional) and tells you which files changed upon request: https://github.com/Ingrater/thBase/blob/master/src/thBase/directory.d I don't think its possible to imiplement this cross-plattform. You will have to reimplement for every plattform you need it on. Kind Regards Benjamin Thaut
For Linux you can use inotify http://linux.die.net/man/7/inotify
May 23 2013
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-05-23 18:19, David wrote:

 For Linux you can use inotify

 http://linux.die.net/man/7/inotify
I think the corresponding for Mac OS X is fsevents: http://en.wikipedia.org/wiki/FSEvents -- /Jacob Carlborg
May 23 2013
prev sibling parent reply "Gary Willoughby" <dev kalekold.net> writes:
Hmmm.. this is what i first thought. I think i'll implement a 
simple watcher based on modification times as a first iteration. 
Then if time allows add platform specific solutions based on the 
above. Thanks.
May 23 2013
parent "Zz" <Zz nospam.com> writes:
https://code.google.com/p/simplefilewatcher/

may help with platform specific solutions.

On Thursday, 23 May 2013 at 18:56:41 UTC, Gary Willoughby wrote:
 Hmmm.. this is what i first thought. I think i'll implement a 
 simple watcher based on modification times as a first 
 iteration. Then if time allows add platform specific solutions 
 based on the above. Thanks.
Jul 15 2013