Re: [lazarus] Detect if file is written?

2006-08-14 Thread Bogusław Brandys

Alexandre Leclerc wrote:

Hi all,

an application writes a text file on disk (Windows) and my FPC
application opens it to process it. On some systems I open the file
faster than the OS has finished writing it. I then get an 'Unexpected
end of file'.

I would like to know if there is a way I can detect the file is finish
written on the disk; else should I simply trap the error and then
close/reopen if I get it?

Regards.



Other solution is to change this application which writes to text file 
on disk,that way that it should write to temporary file and then change 
filename to destination.Because renaming file is atomic under linux and 
windows you will not worry about file writes.



Regards
Boguslaw

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


AW: [lazarus] Detect if file is written?

2006-08-14 Thread Christian Ulrich
>I think the problem is with the write cache. The system don't write 
>data to disk directly, but to a cache, and when it has time, it 
>writes 'really' to the disk. Don't know on windows, but on unix 
>system the system call is flush.

No, the write cache is also readed by the system so it schoudnt be a
problem i think.

Christian

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Detect if file is written?

2006-08-14 Thread Eduardo

At 20:34 14/08/2006, you wrote:

Hi all,

an application writes a text file on disk (Windows) and my FPC
application opens it to process it. On some systems I open the file
faster than the OS has finished writing it. I then get an 'Unexpected
end of file'.

I would like to know if there is a way I can detect the file is finish
written on the disk; else should I simply trap the error and then
close/reopen if I get it?


I think the problem is with the write cache. The system don't write 
data to disk directly, but to a cache, and when it has time, it 
writes 'really' to the disk. Don't know on windows, but on unix 
system the system call is flush.


HTH 


_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Detect if file is written?

2006-08-14 Thread ik

Can you make a program to lock file that is written ?
If so, then all you should check is that the file is unlocked... But
still remember that the data can be problematic ...

Another way is to monitor file for changes... I'd seen few Delphi
applications that does that, but I do not remember any specific
program.
Anyway you can also do a monitor of your own like so: changes of file
size ... for example check 3 times and see the file size changes, and
then wait for a second and check 3 times again ...
Repeat it until file size was not changed for more then 3/6 checks ...

Ido

On 8/14/06, Christian U. <[EMAIL PROTECTED]> wrote:

try
except
end;

:)

when an exception occours it is not finished !?

not very "clean" but i think the only way to detect this good


Christian

- Original Message -
From: "Alexandre Leclerc" <[EMAIL PROTECTED]>
To: "lazarus mailinglist" 
Sent: Monday, August 14, 2006 8:34 PM
Subject: [lazarus] Detect if file is written?


> Hi all,
>
> an application writes a text file on disk (Windows) and my FPC
> application opens it to process it. On some systems I open the file
> faster than the OS has finished writing it. I then get an 'Unexpected
> end of file'.
>
> I would like to know if there is a way I can detect the file is finish
> written on the disk; else should I simply trap the error and then
> close/reopen if I get it?
>
> Regards.
>
> --
> Alexandre Leclerc
>
> _
>  To unsubscribe: mail [EMAIL PROTECTED] with
> "unsubscribe" as the Subject
>archives at http://www.lazarus.freepascal.org/mailarchives
>
>
>

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives



_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Detect if file is written?

2006-08-14 Thread Christian U.
try
except
end;

:)

when an exception occours it is not finished !?

not very "clean" but i think the only way to detect this good


Christian

- Original Message - 
From: "Alexandre Leclerc" <[EMAIL PROTECTED]>
To: "lazarus mailinglist" 
Sent: Monday, August 14, 2006 8:34 PM
Subject: [lazarus] Detect if file is written?


> Hi all,
> 
> an application writes a text file on disk (Windows) and my FPC
> application opens it to process it. On some systems I open the file
> faster than the OS has finished writing it. I then get an 'Unexpected
> end of file'.
> 
> I would like to know if there is a way I can detect the file is finish
> written on the disk; else should I simply trap the error and then
> close/reopen if I get it?
> 
> Regards.
> 
> -- 
> Alexandre Leclerc
> 
> _
>  To unsubscribe: mail [EMAIL PROTECTED] with
> "unsubscribe" as the Subject
>archives at http://www.lazarus.freepascal.org/mailarchives
> 
> 
> 

_
 To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Detect if file is written?

2006-08-14 Thread Alexandre Leclerc

Hi all,

an application writes a text file on disk (Windows) and my FPC
application opens it to process it. On some systems I open the file
faster than the OS has finished writing it. I then get an 'Unexpected
end of file'.

I would like to know if there is a way I can detect the file is finish
written on the disk; else should I simply trap the error and then
close/reopen if I get it?

Regards.

--
Alexandre Leclerc

_
To unsubscribe: mail [EMAIL PROTECTED] with
   "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives