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

Home » Public Forums » archive » Re: Win32 and Removeable Drives
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Win32 and Removeable Drives [message #23776] Wed, 21 February 2001 09:24
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
Hi Bernard,

I think the best way is to catch the error using a wrapper function
heres a couple of functions which I tested on Win 2000. Hope they do the
job for you.

example usage:

IDL> print, dir_exist("c:")
1
IDL> print, dir_exist("f:")
1
; eject media
IDL> print, dir_exist("f:\")
0
IDL> safe_cd, "f:", success = success
IDL> print, success
0

regards

Martin
;----------------------------------------------------------- ----------------
--
; Wrapper function for CD - change directory
; Martin Downing 2000
; If it catches an error, sucess is set to 0 otherwise 1
pro safe_cd, dir, success=success, current = current, debug=debug

; error handling
Catch, error_status
IF Error_status NE 0 THEN BEGIN
if keyword_set(DEBUG) then begin
PRINT, "Directory change failed"
PRINT, 'Error message: ', !ERROR_STATE.MSG
endif
success = 0
return
ENDIF

; try to change directory
cd, dir , cur = current
; if we get this far then everything must be ok
success = 1
return
end

;----------------------------------------------------------- ----------------
--
; Test if a directory exists
function dir_exist, dir
cd, cur = cur
safe_cd, dir, success=success
if success eq 1 then cd, cur
return, success
end

;----------------------------------------------------------- ----------------
--


--
----------------------------------------
Mr. Martin Downing,
Clinical Research Physicist,
Orthopaedic RSA Research Centre,
Woodend Hospital,
Aberdeen, AB15 6LS.
Tel. 01224 556055
Fax. 01224 556662
m.downing@abdn.ac.uk
"Bernard Puc" <bpuc@va.aetc.com> wrote in message
news:3A92D8C3.3A6CFC9A@va.aetc.com...
> Hello,
>
> I need some help with determining whether a removable drive has media
> installed or not on a win32 platform running windows. Specifically, how
> can I do it? I need to use the CD command but I also need to verify
> that the drive is readable beforehand. Any clues much appreciated.
>
> -Bernard Puc
> AETC, Inc.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: New to Linux not IDL
Next Topic: Re: Generally accessing the rest of the elements in an array

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

Current Time: Wed Oct 08 15:28:23 PDT 2025

Total time taken to generate the page: 0.00476 seconds