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

Home » Public Forums » archive » Re: Best way of detecting a directory
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: Best way of detecting a directory [message #3273] Mon, 02 January 1995 05:46
knipp is currently offline  knipp
Messages: 68
Registered: January 1993
Member
Hi

I append a routine which does the job WITHOUT a system-call.
It runs under SunOs (for sure), MsWindows (should be), but may
easily modified for other OS.

Karlheinz



____________________________________________________________ _________________
__ ____ __
/ // _ \ / / Karlheinz Knipp Tel. 0511 - 762 4922
/ // /_/ // / Uni Hannover Fax. 0511 - 762 2483
/ // ____// / Institut f. Photogrammetrie
/ // / / / Nienburger Str.1 email knipp@ipi.uni-hannover.de
/_//_/ /_/ FRG 30167 Hannover


--------------------------------- snip-snap --------------------------------




--------------------------------- snip-snap --------------------------------;+
function exist_dir, test_dir, rtcode=rtcode

; function: checks existence of DIRECTORY
; ------------------------------------------------------------ --------------
; START OF DESCRIPTION
;
; function IPI, U Hannover 06'94
; 06'94:
;
; METHOD: checks existence of DIRECTORY
; uses: OPENR,...,ERROR=ERROR
;
; INPUT PARAMETER: test_dir directory to test
;
; RETURNS: 1: exists
; 0: does NOT exists
;
; INPUT KEYWORDS : none
;
; OUTPUT KEYWORDS : rtcode Return-code : 0 for o.k., -1 for ERROR
;
; EXAMPLE:
;
; print, exist_dir('$HOME')
;
; END OF DESCRIPTION
; ------------------------------------------------------------ --------------
;-

ret_val = 0 ; return - value
rtcode = 0 ; Return - code


; ------------------------------------------------------------ --------------
; test input

if n_params() ne 1 then begin
print,"The number of parameters was wrong:",n_params()
doc_library,"exist_dir"
return, ret_val
endif

if n_elements(test_dir) eq 0 then begin
message, 'TEST_+DIR UNDEFINED : ', /info
return, ret_val
endif


; ------------------------------------------------------------ --------------
; OS ?

case !version.os of
'windows': dir_delim = '\'
else: dir_delim = '/'
endcase


; ------------------------------------------------------------ --------------
; re-store

test = test_dir


; ------------------------------------------------------------ --------------
; length

len = strlen(test)


; ------------------------------------------------------------ --------------
; delimiter at end?

if strmid(test, len-1, 1) eq dir_delim $
then test = strmid(test, 0, len-1)


; ------------------------------------------------------------ --------------
; open

openr, uni, test, /get_lun, error=error


; ------------------------------------------------------------ --------------
; check

if error ne 0 then return, 0


; ------------------------------------------------------------ --------------
; close

free_lun, uni


; ------------------------------------------------------------ --------------
; return & end

rtcode = 0

return, 1
end
[Message index]
 
Read Message
Previous Topic: Legendre Polynomials
Next Topic: Truncating a file

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

Current Time: Fri Oct 10 09:53:19 PDT 2025

Total time taken to generate the page: 0.24235 seconds