comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: fstat, file_info and file_test
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: fstat, file_info and file_test [message #35217 is a reply to message #35073] Thu, 15 May 2003 07:56 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Nigel Wade wrote:
> Ben Tupper wrote:
>
>
>> Hello,
>>
>> This appears to be the week for file questions.
>>
>> I see that in the now distant past, my question has been asked here
>> before, but the answers were pre-IDL 5.4 when FILE_xxxxx routines
>> appeared.
>>
>> I would like to have a test that reports if the file is open - by simply
>> providing the filename. FSTAT almost does it, but I have to associate
>> the file with a LUN first. FILE_INFO and FILE_TEST each take the
>> filename as an argument (instead of the lun that FSTAT requires), but
>> neither test for 'openess'.
>>
>> What I would like to have is a function similar to:
>>
>> result = FILE_ISOPEN(filename)
>>
>> that returns a 1 (for open) or a 0 (for closed). Or, perhaps better in
>> the long run, I'd like to see an /ISOPEN keyword added to FILE_TEST.
>>
>>
>> Any suggestions?
>>
>> Thanks,
>> Ben
>
>
> 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


Thanks,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: replace array's elemets
Next Topic: new object from a save/restore doesn't execute init function

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 15:08:05 PDT 2025

Total time taken to generate the page: 2.15397 seconds