FROM : Alastair Houghton
DATE : Fri Jan 11 15:53:34 2008
On 11 Jan 2008, at 05:19, shengjun_guan (ºÞÁn«T) wrote:
> Because i have one application to monitor one folder that files are
> created in.
> eg. file1 and file2 have been created in the folder. My application
> will send the file1 and file2
> to other application to open them.
> In some case, file1 have been finishing created.And file2 is
> creating . So, if i send the tow files for
> opening to other application. file2 will open fail.
>
> So, i want to check the file2 if is busy before i send.
There is no such thing as a "busy" file on a UNIX system. You need to
redesign your application to work in a different way. For instance,
maybe files that your application acts on could have a different
extension to the ones that are being created; renaming a file is an
atomic operation, so once you've finished writing a file, you could
then rename it to bring it to the attention of your other process.
If the source code is available for all the programs in question, you
may also be able to use advisory locks, or lock files, or even some
other mechanism (for instance, you could use a socket to send the
names of the files to process to the far end).
Kind regards,
Alastair.
--
http://alastairs-place.net
DATE : Fri Jan 11 15:53:34 2008
On 11 Jan 2008, at 05:19, shengjun_guan (ºÞÁn«T) wrote:
> Because i have one application to monitor one folder that files are
> created in.
> eg. file1 and file2 have been created in the folder. My application
> will send the file1 and file2
> to other application to open them.
> In some case, file1 have been finishing created.And file2 is
> creating . So, if i send the tow files for
> opening to other application. file2 will open fail.
>
> So, i want to check the file2 if is busy before i send.
There is no such thing as a "busy" file on a UNIX system. You need to
redesign your application to work in a different way. For instance,
maybe files that your application acts on could have a different
extension to the ones that are being created; renaming a file is an
atomic operation, so once you've finished writing a file, you could
then rename it to bring it to the attention of your other process.
If the source code is available for all the programs in question, you
may also be able to use advisory locks, or lock files, or even some
other mechanism (for instance, you could use a socket to send the
names of the files to process to the far end).
Kind regards,
Alastair.
--
http://alastairs-place.net
| Related mails | Author | Date |
|---|---|---|
| shengjun_guan (???… | Jan 11, 03:24 | |
| Horn Deric | Jan 11, 04:08 | |
| shengjun_guan (???… | Jan 11, 06:19 | |
| Alastair Houghton | Jan 11, 15:53 |






Cocoa mail archive

