Re: need a better file copy method

"Ioan - Ciprian Tandau" <[email protected]> Wed, 3 May 2006 08:21:31 -0400
Newsgroups gmane.comp.java.linux.general
Message-ID <[email protected]>
On 5/3/06, Stefaan A Eeckels <[email protected]> wrote:
> On Wed, 3 May 2006 07:32:10 -0400
> "Ioan - Ciprian Tandau" <[email protected]> wrote:
>
> > I told him about getFD().sync() (for FileInput/OutputStream and
> > RandomFile.... It seems to be the only way to make sure things are
> > synchronously written to disk (local storage).
>
> The fact that the file is physically written to disk is not important
> because the OS will provide the last contents of a file either from
> disk or from the buffers. Flushing the buffers to disk is only
> important when one doesn't want to lose data when the system crashes.
>
> I believe that the OP's problem is that the copying of the file happens
> in a different thread than the use of the copy by the test routine. In
> this case, the thread performing the copy can still be busy while the
> thread performing the test is being scheduled.
>
> Other than synchronising the threads, the OP could try to copy to a
> file in a staging directory below the directory where the final copy
> needs to be placed, and then rename the file after the copy completes.
> File renaming is atomic on Unix/Linux.
>
> --
> Stefaan
> --
> As complexity rises, precise statements lose meaning,
> and meaningful statements lose precision. -- Lotfi Zadeh
>

I thought the same but he convinced me otherwise :-).
(This time reply all)


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]