I would like to, cleanly, watch a flat file for changes (updates and
the like). The file will be altered by another program... I found some
example code (which actually didn't compile) on Google, but it
essentially does it the way I would have in the first place (i.e. sets
up a loop and gets the file's attributes each iteration, comparing to
the previous instance). This seems kind of cludgy to me: is there a
better way?
Thank you :)
Christopher Harrison 8 2196
"Christopher Harrison" <Sp*********@ChrisHarrison.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... I would like to, cleanly, watch a flat file for changes (updates and the like). [...]
Then you should look into platform-specific methods, and if necessary ask in
the relevant group(s).
The closest you can get using standard C, the scope of this newsgroup, is to
make a copy of the file (either read it into memory or read it and write to
another file) and repeatedly compare the file with the copy. That certainly
isn't what I'd call "clean" :).
Alex
Alex Fraser wrote: "Christopher Harrison" <Sp*********@ChrisHarrison.co.uk> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com... I would like to, cleanly, watch a flat file for changes (updates and the like). [...]
Then you should look into platform-specific methods, and if necessary ask in the relevant group(s).
The closest you can get using standard C, the scope of this newsgroup, is to make a copy of the file (either read it into memory or read it and write to another file) and repeatedly compare the file with the copy. That certainly isn't what I'd call "clean" :).
You could also compute a CRC or a hash from the file, store it in
memory and compare in each iteration with the stored value. But this is
not much cleaner than simply copying the file and compare directly, and
eats much more processor time.
I've been looking around and have found sys/stat.h which I'm currently
working with... I know I'm asking for trouble, but could someone
explain to me why this isn't "standard C". I read it's POSIX (although
it seems to be working OK under) Windows: what's the difference?
Christopher Harrison wrote: I've been looking around and have found sys/stat.h which I'm currently working with... I know I'm asking for trouble, but could someone explain to me why this isn't "standard C".
It isn't defined by the C Standard (not any of them). By default,
the comp.lang.c interpretation of "the standard" is the appropriate
C standard.
Consequently, a C implementation is under no obligation to provide
a sys/stat.h, nor - if it does - for any functions inside to do
what you expect, /as far as the C standard is concerned/. Your
implementation may of course offer items taken from some /other/
standard ...
I read it's POSIX (although it seems to be working OK under) Windows: what's the difference?
.... such as POSIX; the difference is that, generally speaking,
what POSIX offers isn't topical here.
--
Chris "electric hedgehog" Dollin
Il Principe - Byzantium - Hansa - Antike - King's Progress
Farfalia - Mu - Havoc - Tigris & Euphrates [kartenspiel]
Christopher Harrison <Sp*********@chrisharrison.co.uk> wrote: I've been looking around and have found sys/stat.h which I'm currently working with... I know I'm asking for trouble, but could someone explain to me why this isn't "standard C". I read it's POSIX (although it seems to be working OK under) Windows: what's the difference? http://www.ungerhu.com/jxh/clc.welcome.txt http://www.eskimo.com/~scs/C-faq/top.html http://benpfaff.org/writings/clc/off-topic.html
Also...
It is proper Usenet etiquette to include the relevant portions of the text
you are replying to. To do this using Google groups, please follow the
instructions below, penned by Keith Thompson:
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Christopher Harrison <Sp*********@chrisharrison.co.uk> wrote: I would like to, cleanly, watch a flat file for changes (updates and the like). The file will be altered by another program... I found some example code (which actually didn't compile) on Google, but it essentially does it the way I would have in the first place (i.e. sets up a loop and gets the file's attributes each iteration, comparing to the previous instance). This seems kind of cludgy to me: is there a better way?
Judging from this thread you should take this to comp.unix.programmer.
There you can learn about things like dnotify, inotify, kqueue(2), and other
techniques (similar to sleep and stat). None of them can be done in what
plain C offers. They all require platform specific support (API's), and by
asking in the wrong group you're likely to get confusing or misleading
answers (either because the people are too experienced in a domain or not
enough, and the group isn't tuned for correcting and normalizing nontopical
subjects).
On 18 Oct 2005 05:52:47 -0700, in comp.lang.c , "Christopher Harrison"
<Sp*********@ChrisHarrison.co.uk> wrote: I've been looking around and have found sys/stat.h which I'm currently working with... I know I'm asking for trouble, but could someone explain to me why this isn't "standard C".
C supports hardware and OSes for which the functions in stat.h would
be either unimplementable or meaningless. Even for those for which a
posix layer exists, some of the functionality doesn't always make
sense, for example dev, ino, mtime, atime, nlink, gid, uid, in struct
_stat under DOS or Win9x.
I read it's POSIX (although it seems to be working OK under) Windows: what's the difference?
POSIX is defined by one Standard, ISO C is defined by another.
FWIW posix provides a set of unix-like APIs which work on a range of
hardware that C cupports, but far from all of it.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =---- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Benjamin D. LeMasurier |
last post by:
Hey everyone,
Is there a way to "watch" a file for changes? I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?
thanks!
Ben
|
by: Ajay Pal Singh |
last post by:
Hi,
I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the config
file so that the service can take...
|
by: Luis Esteban Valencia Muñoz |
last post by:
Hi everyone,
I created a VB.NET application that looks at a folder
in my local system from which I can read the file, enter data into the
database and delete the file. I am using the filewatcher...
|
by: paul |
last post by:
Watching connections to your computer.
Can some one tell where to start.
I want to write some code to be alerted when
some one connect to my computer and browses/copies/changes
files or...
|
by: John Dann |
last post by:
I need to watch a specific file that updates at irregular intervals
and raise an event when an update happens (ie file date/time stamp
changes). I had heard that there is a native method in .Net...
| |
by: John Dann |
last post by:
I'm using the FileSystemWatcher with NotifyFilters.LastWrite set. This
works fine during the same day but fails to fire its event for changes
in the monitored file after midnight, ie into the next...
|
by: Gordon Airporte |
last post by:
I'm trying to find a way to take a file that another program has opened
and writes to periodically, open it simultaneously in Python, and
automatically update some of my objects in Python when the...
|
by: Zed A. Shaw |
last post by:
Hi Everyone,
Just putting out an announcement that I've released a new version of
Vellum numbered 0.16. This version should be ready for people to use
as not much of the internal structure has...
|
by: Andrew Cooper |
last post by:
I've got an application that I'm modifying and the client needs it to
watch a particular file and then do some stuff when that file gets
modified. For example, let's say the file is C:\Test.dat...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |