For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2005 > Is file finished writing?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Is file finished writing?
David Jacopille

2005-03-24, 3:56 am

I'm looking for some strategies to determine when other applications
are finished writing a file. I've got a script printing page layout
files to postscript in rapid fashion. I'd like to move the postscript
to another location for some additional modifications as fast as
possible. I can't figure out how to have my perl script NOT move those
postscript files that are in the process of being written.

I've tried checking the -w status but that seems to check the files
permissions settings which apparently are writable even if while the
file is being actively written by the page layout app. I've tried last
access time > 2 seconds or modification date > 2 seconds but those
don't quite seem to work.

Opening a filehandle for writing seems to give an error if the file is
still being written - is that the best way?

Isn't there a very direct way to ask if a file is not in the middle of
being written by any other process?

Thanks,
Dave

JupiterHost.Net

2005-03-24, 3:56 am



David Jacopille wrote:
> I'm looking for some strategies to determine when other applications are
> finished writing a file. I've got a script printing page layout files
> to postscript in rapid fashion. I'd like to move the postscript to
> another location for some additional modifications as fast as possible.
> I can't figure out how to have my perl script NOT move those postscript
> files that are in the process of being written.



make foo.lock when you open foo to work on and remove foo.lock when
you're done.

don't open it if the foo.lock exists

Search cpan for file and lock file tools
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com