Ignore:
Timestamp:
04/27/06 11:05:35 (18 years ago)
Author:
pinsard
Message:

upgrade of UTILITAIRE/Utilities according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/ : files

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/isadirectory.pro

    r9 r11  
    55; NAME:isadirectory 
    66; 
    7 ; PURPOSE:check if a directory is in the !path variable or is the 
    8 ; common. end it by '/' under Unix/Linux, ':' under Mac and '\' under 
    9 ; Windows. 
     7; PURPOSE:check if a directory exists and make sure that it ends  
     8;         with the directory separator mark. 
    109; 
    1110; CATEGORY: io 
    1211; 
    13 ; CALLING SEQUENCE: directory=isadirectory() 
     12; CALLING SEQUENCE: directory=isadirectory([dirname]) 
    1413;  
    15 ; INPUTS:none 
     14; INPUTS:optional:a proposed directory. If neither dirname  
     15;        input parameter of IODIRECTORY keyword are defined, 
     16;        the ask the user to choose a directory. 
    1617; 
    1718; KEYWORD PARAMETERS: 
    18 ;       IODIRECTORY:a proposed directory 
    19 ;       TITLE: the title of the widget open if we need to choose a 
    20 ;       directory. 
    21 ;       /NOPATH:do not check if the directory is in the !path 
    22 ;       variable. 
    2319; 
    24 ; OUTPUTS: de directory name 
     20;     IODIRECTORY:a proposed directory 
    2521; 
    26 ; COMMON BLOCKS: 
     22;     TITLE = the title of the window 
    2723; 
    28 ; SIDE EFFECTS:while statement until we found a good directory... 
     24;     all dialog_pickfile keywords (like filter) 
     25; 
     26; OUTPUTS: the directory name 
     27; 
     28; COMMON BLOCKS:none 
     29; 
     30; SIDE EFFECTS: 
    2931; 
    3032; RESTRICTIONS: 
     
    3234; EXAMPLE: 
    3335; 
     36;    IDL> print, !dir 
     37;    /usr/local/rsi/idl_6.0 
     38;    IDL> print, isadirectory(!dir) 
     39;    /usr/local/rsi/idl_6.0/ 
     40;    IDL> print, isadirectory(!dir+'notgood') 
     41; 
    3442; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 
    3543;                      June 28, 2000 
     44; June 2005: Sebastien Masson: cleaning, use for file_* functions 
    3645;- 
    3746;------------------------------------------------------------ 
    3847;------------------------------------------------------------ 
    3948;------------------------------------------------------------ 
    40 FUNCTION isadirectory, IODIRECTORY = iodirectory, NOPATH = nopath, TITLE = title 
    41  
    42    cd, current = current 
    43 ; if directory is undefine, we get the current directory. 
    44    if  keyword_set(iodirectory) THEN directory = iodirectory ELSE directory = current  
     49FUNCTION isadirectory, directoryin, TITLE = title, IODIRECTORY = iodirectory, _extra = ex 
    4550; 
    46    thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
    47    CASE thisOS of 
    48    'MAC':BEGIN & sep = ':' & pathsep = ',' & end 
    49    'WIN':BEGIN & sep = '\' & pathsep = ';' & end 
    50    ELSE: BEGIN & sep = '/' & pathsep = ':' & end 
    51    ENDCASE 
    52 ; si directory ou current ne finit pas par sep on le rajoute 
    53    if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep 
    54    if rstrpos(directory, sep) NE strlen(directory)-1 then directory = directory+sep 
    55    if keyword_set(nopath) then return, directory 
    56 ; does directory is define in the !path variable or is it the current directory? 
    57    possibledirectory = str_sep(!path, pathsep) 
    58    if rstrpos(possibledirectory[0],sep) NE strlen(possibledirectory[0])-1 then $ 
    59     possibledirectory = possibledirectory+sep 
    60    possibledirectory = [current, possibledirectory] 
    61    while (where(possibledirectory EQ directory))[0] EQ -1 do begin 
    62       directory = dialog_pickfile(/directory, title = title) 
    63       if directory EQ '' then return, report('read_data canceled') 
    64       if rstrpos(directory, sep) NE strlen(directory)-1 then directory = directory+sep 
    65    endwhile 
    66  
    67    return, directory 
    68 end 
     51  CASE 1 OF 
     52    (size(directoryin, /type))[0] EQ 7:directory = directoryin 
     53    keyword_set(iodirectory):directory = iodirectory 
     54    ELSE:directory = 'directory that is not existing' 
     55  ENDCASE 
     56  testfile = file_test(directory, /directory) 
     57; if directory doesn't exist, we ask the user to provide a directory name 
     58  IF total(testfile) NE n_elements(directory) THEN BEGIN 
     59    IF NOT keyword_set(title) THEN title = 'choose a directory' 
     60    FOR i = 0, n_elements(directory)-1 DO BEGIN 
     61      IF testfile[i] EQ 0 THEN BEGIN 
     62        directory[i] = dialog_pickfile(/directory, title = title $ 
     63                                       , /must_exist, _extra = ex) 
     64        if directory[i] EQ '' THEN RETURN, report('check/find directory canceled') 
     65      ENDIF 
     66    ENDFOR 
     67  ENDIF 
     68; 
     69  directory = file_search(directory, /mark_directory) 
     70  IF n_elements(directory) EQ 1 THEN RETURN, directory[0] $ 
     71  ELSE RETURN, directory 
     72; 
     73END 
    6974 
    7075 
Note: See TracChangeset for help on using the changeset viewer.