Operating System - OpenVMS
1753608 Members
6423 Online
108797 Solutions
New Discussion юеВ

Re: How program can find out that a file can be copied?

 
SOLVED
Go to solution
Jurek Sokolowski
Occasional Contributor

How program can find out that a file can be copied?

I need to copy a file with LIB$SPAUN('copyтАж . What system service can I use to determine that file to be copied is not allocated by other program (e.g. that file transfer from different machine has finished). From DCL I can use SHOW DEV /FIL to check it, but I have no idea how to do that from FORTRAN or C level.
6 REPLIES 6
Volker Halle
Honored Contributor

Re: How program can find out that a file can be copied?

Jurek,

there is no system service to tell, whether a file is opened from another process.

You could try to open the file in exclusive mode, allowing no sharing, which would fail, if another process has the file open.

Volker.
Kris Clippeleyr
Honored Contributor

Re: How program can find out that a file can be copied?

Jurek,

You might want to try SYS$OPEN.
See HELP SYSTEM_SERVICES $OPEN , and the Record Management Services Reference manual.

Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Karl Rohwedder
Honored Contributor

Re: How program can find out that a file can be copied?

Have a look into the utility FILES_INFO.
It can display, if a file is locked and by whom.
Source code (C and macro) is provided.
May you can get some hints.

You find it at the usual place at Hunter Goatley filearchive:

http://www.process.com/openvms/index.html

regards Kalle
Volker Halle
Honored Contributor
Solution

Re: How program can find out that a file can be copied?

Jurek,

the following statement in FORTRAN could do, what you want:

OPEN (UNIT=1, FILE='test.dat',STATUS='OLD')

$! File test.dat not access by any process
$ run ITRC_965548

$! Access file
$ open/read x test.dat
$ run ITRC_965548
%FOR-F-OPEFAI, open failure
unit 1 file USERDISK1:TEST.DAT;
user PC 00000000
-RMS-E-FLK, file currently locked by another user
...

Volker.
Jurek Sokolowski
Occasional Contributor

Re: How program can find out that a file can be copied?

Opening a file as a test is simple and works fine. Thank you very much for your help.
Jurek
John Gillings
Honored Contributor

Re: How program can find out that a file can be copied?

The best approach is to simply attempt to copy the file and react to any errors. Any test is subject to timing windows. Yes, the file may be available NOW, but that doesn't say it will still be available when you attempt the copy.

The simplest way to copy a file under program control is using callable CONVERT.

Attached is a MACRO32 program to perform a COPY. Check the return status to see if it was successful.

A crucible of informative mistakes