The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

This topic is READ ONLY
import-bot (20211) [Avatar] Offline
#1
Re: Copying Open Files
[Originally posted by rross]

> DOS will allow a COPY on files that are currently open, and any other
> read-only operation.
>
> However, of_FileCopy() will NOT copy the file if it is open by another
> application.

Impatient and intrepid as I am, I traced the problem/feature down through the
function chain from of_fileCopy() to of_fileRead() where I changed :

li_FileNo = FileOpen(as_FileName, StreamMode!, Read!)

TO

li_FileNo = FileOpen(as_FileName, StreamMode!, Read!,Shared!)

To make the change, I copied of_fileRead() from PFCAPSRV:smilieFC_N_CST_FILESRV to
the PFE equivalent and made my small modification there.

But its not over.

I don't feel comfortable with this way of extending/fixing the functionality,
although the other alternative was to overload at least three functions to
permit an argument which would trickle down to of_fileRead() and control the
usage of the fourth argument (filelock) for FileOpen().

In most cases, I can safely assume that it is perfectly acceptable to allow
reading from a file that is currently open by another application since I am
not modifying it in any way. There may be cases, however, where reading from
the file at the very instant it is being written to may cause me some grief in
the future.

Ideas?
import-bot (20211) [Avatar] Offline
#2
[Originally posted by rross]

Have a situation where I need PowerBuilder to copy a file that is perpetually
open for another application (FoxPro, incidentally.)

DOS will allow a COPY on files that are currently open, and any other
read-only operation.

However, of_FileCopy() will NOT copy the file if it is open by another
application.

I notice that of_FileCopy() essentially just calls the standard PowerBuilder
file IO functions which do the work manually, instead of...uh..."asking" the
OS to do it.

The only possibility for copying an open file seems to use the fourth argument
for FileOpen(), passing Shared! or LockWrite!, which would require me to
overload of_FileRead() and subsequently of_FileCopy() to somehow force that
argument to be used.

I could just call a batch file to do the standard DOS Copy, but then why have
the service in the layer at all? Would rather not do that.
Any thoughts, alternate solutions...sympathy?

Thanks.
import-bot (20211) [Avatar] Offline
#3
Re: Copying Open Files
[Originally posted by rik brooks]

> Impatient and intrepid as I am, I traced the problem/feature down through the
> function chain from of_fileCopy() to of_fileRead() where I changed :
>
> li_FileNo = FileOpen(as_FileName, StreamMode!, Read!)
>
> TO
>
> li_FileNo = FileOpen(as_FileName, StreamMode!, Read!,Shared!)
>
How about this, add another of_fileCopy to your PFE. call it
of_fileCopy(StreamMode) and supply the argument. Then you can use it either
way. Of course you have to do the same thing for of_fileRead. That's what I
would do. I have a feeling those functions were put there just to be complete
since they really don't insulate you from much.
import-bot (20211) [Avatar] Offline
#4
Re: Copying Open Files
[Originally posted by rross]

> How about this, add another of_fileCopy to your PFE. call it
> of_fileCopy(StreamMode) and supply the argument. Then you can use it either

We eventually took the proper route and extended and overloaded the existing
function set to allow specification of a "copy, even if file is currently
open" argument.

Thanks for the suggestion.

Ryan