home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.claremont.edu!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
- From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
- Newsgroups: comp.os.vms
- Subject: Re: Problem with file open detection
- Date: 23 Dec 1992 13:59:08 GMT
- Organization: HST Wide Field/Planetary Camera
- Lines: 39
- Distribution: world
- Message-ID: <1h9rbcINN1c9@gap.caltech.edu>
- References: <1992Dec23.024625.20490@ee.ubc.ca>
- Reply-To: carl@SOL1.GPS.CALTECH.EDU
- NNTP-Posting-Host: sol1.gps.caltech.edu
-
- In article <1992Dec23.024625.20490@ee.ubc.ca>, mhui@ee.ubc.ca (HUI MAN HOI SAMUEL) writes:
- >Hi,
- > Can I use any DCL command or C Library function call to find out that
- >if a particular file is already opened by any process.
- > Is there anyone who can give me some help? Thank you!
-
- Yes. Try to open the file for APPEND access with NO sharing. If the file's
- already open, you'll get the error status %X1001828A (%RMS-E-FLK, file
- currently locked by another user). Unfortunately, in a misguided effort to
- make VAXC look like UNIX C, DEC implemented the run-time library in such a way
- that you've got to go through some (mild) contortions to get the actual error
- status (I thought there was a "vmserr" variable, but a quick look at HELP CC
- RUN didn't show it, so here's a routine to do it using RMS (the routine returns
- 0 if the file's already open, 1 if it's not):
-
- #include fab
-
- is_open(char *file)
- { struct FAB my_fab;
-
- my_fab = cc$rms_fab;
- my_fab.fab$b_fac = FAB$M_PUT;
- my_fab.fab$l_fna = file;
- my_fab.fab$b_fns = strlen(my_fab.fab$l_fna);
- if((stat = SYS$OPEN(&my_fab)) = 0x0001828A)
- return 0;
- else
- { SYS$CLOSE(&my_fab);
- return(1);
- }
- }
- --------------------------------------------------------------------------------
- Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
-
- Disclaimer: Hey, I understand VAXen and VMS. That's what I get paid for. My
- understanding of astronomy is purely at the amateur level (or below). So
- unless what I'm saying is directly related to VAX/VMS, don't hold me or my
- organization responsible for it. If it IS related to VAX/VMS, you can try to
- hold me responsible for it, but my organization had nothing to do with it.
-