;+ pro check_filepath, input_file ; test of file (HOME_TO_PATH, ENV_TO_PATH, ADD_PATH) ; ------------------------------------------------------------------------------ ; START OF DESCRIPTION ; ; subroutine IPI, U Hannover 02'92, modified 02'93 (for use with DOS) ; ; METHOD: test of file (HOME_TO_PATH, ENV_TO_PATH, ADD_PATH) ; changes input_filename ; ; INPUT PARAMETER: input_file name of file to be tested ; ; OUTPUT PARAMETER: input_file updated ; ; KEYWORDS : none ; ; EXAMPLE: ; ; file = '~/.login' & check_filepath, file & print, file ; ; END OF DESCRIPTION ; ------------------------------------------------------------------------------ ;- ; ------------------------------------------------------------------------------ ; test input if n_params() ne 1 then begin print,"The number of parameters was wrong:",n_params() doc_library,"check_filepath" return endif if n_elements(input_file) eq 0 then begin print,string(7b) message, 'INPUTFILE UNDEFINED ', /info return endif ; ------------------------------------------------------------------------------ ; preparations if strpos(input_file,' ') ne -1 $ then input_file = strcompress(input_file, /remove_all) ; Condition added below to allow for DOS filenames at this point. ; DPS 94/06/10 IF !VERSION.OS EQ 'RISC/os' $ THEN pos = strpos(input_file,'/') $ ELSE pos = STRPOS(input_file,'\') ; assume DOS ; Added condition to avoid getting spurious stuff in REST. ; DPS 94/06/10 IF pos GE 0 THEN BEGIN env_name = strmid(input_file, 1, pos-1) rest = strmid(input_file,pos, strlen(input_file)-pos) ENDIF ELSE BEGIN env_name = '' rest = '' ENDELSE ; ------------------------------------------------------------------------------ ; UNIX if !version.os eq 'RISC/os' then begin ; ------------------------------------------------------------------ ; home_to_path if strpos(input_file,'~') eq 0 then begin path_name = getenv('HOME') if path_name eq '' then begin print, ' Environment variable HOME NOT found' endif else input_file = path_name + rest endif ; --------------------------------------------------------------------- ; env_to_path if strpos(input_file,'$') eq 0 then begin path_name = getenv(env_name) if path_name eq '' then begin print, ' Environment variable NOT found' endif else input_file = path_name + rest endif dir_delim = '/' path_delim = ':' endif else begin ; assuming MS-WINDOWS message, ' assuming MS-WINDOWS (DOS) ...', /info dir_delim = '\' path_delim = ';' endelse ; ------------------------------------------------------------------------------ ; add_path if strpos(input_file, dir_delim) eq -1 then begin fini = 0 tmp = !path pos = strpos(tmp, path_delim) while pos ne -1 and not fini do begin dir = strmid (tmp, 0, pos) if strmid(dir, strlen(dir)-1,1) ne dir_delim $ then tfile = dir + dir_delim + input_file $ else tfile = dir + input_file f_find = findfile( tfile ) if f_find(0) ne '' then begin input_file = tfile fini = 1 endif tmp = strmid(tmp, pos+1, strlen(tmp)-pos-1) pos = strpos(tmp, path_delim) endwhile if strmid(tmp, strlen(tmp)-1,1) ne dir_delim $ then tfile = tmp + dir_delim + input_file $ else tfile = tmp + input_file f_find = findfile( tfile ) if f_find(0) ne '' then input_file = tfile endif ; ------------------------------------------------------------------------------ ; return & end return end