Re: fstat, file_info and file_test [message #35215 is a reply to message #35090] |
Thu, 15 May 2003 08:27  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Ben Tupper wrote:
>
> Nigel Wade wrote:
>>
>> How do you deal with the issue of the file being renamed or deleted after
>> you've opened it? What do you do if the file you opened is renamed and new
>> file created with the same name - should the test indicate it's open or
>> not?
>>
>> In general, not even the OS can tell you reliably what you want for these
>> reasons.
>>
>
> Good questions! Another question to add to your list, what happens if
> more than one valid pointers exist to the single file? Witness below,
> that u1 and u2 are each valid LUNs to the same file. Gaak! I can see
> why the underlying OS can't be counted upon for 'truth' - too many cooks!
>
> IDL> get_LUN, u1
> IDL> get_LUN, u2
> IDL> openW, u1, file
> IDL> for i = 0, 2 do print, s[i]
> Unit Attributes Name
> 100 Read, Write, New, Reserved /Users/ben/data.dat
> 101 Closed, Reserved
> IDL> openU, u2, file
> IDL> help, /file, output = s
> IDL> for i = 0, n_elements(s)-1 do print, s[i]
> Unit Attributes Name
> 100 Read, Write, New, Reserved /Users/ben/data.dat
> 101 Read, Write, Reserved /Users/ben/data.dat
Umm, pardon my denseness, but how is this different from file access/status issues for
other languages? My experience is limited to Fortran (which has a number of file inquiry
capabilities) but I would think at some point, regardless of language, the programmer has
to take responsibility for avoiding the problems mentioned. At the very least, code
defensively to trap or minimise subsequent damage.
paulv
--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Ph: (301)763-8000 x7748
Fax:(301)763-8545
|
|
|