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 #35083 is a reply to message #35075] Wed, 14 May 2003 11:28 Go to previous messageGo to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Richard Younger wrote:
> Ben Tupper wrote:
> [...]
>
>> 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.
>
>
> Hi Ben.
>
> I don't think IDL associates file names with open files except through LUNs,
> so I can only think of the brute force method:
>
> FUNCTION IsFilenameOpen, filename
>
> COMPILE_OPT idl2
>
> test_struc = Fstat(0)
> struc_array = Replicate(test_struc, 129)
>
> FOR i=1, 128 DO BEGIN
> struc_array[i] = Fstat(i)
> ENDFOR
>
> index = Where(struc_array.name EQ File_Expand_Path(filename), count)
>
> IF count EQ 0 THEN RETURN, 0 ELSE RETURN, 1
>
> END
>
> Wouldn't want to put it in an inner loop, though.
>
> Good luck,
> Rich
>
>

Hi,

OK, how about running through the possible LUNs (100-128) until a match
is found. I like the cross-platforminess of your solution.

FUNCTION File_IsOpen, filename

COMPILE_OPT idl2

For i = 100, 128 Do $
If ( (Fstat(i)).NAME EQ File_Expand_Path(filename) ) Then Return, 1

Return, 0
END

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: Wed Oct 08 17:53:00 PDT 2025

Total time taken to generate the page: 0.00251 seconds