source: trunk/Utilities/isadirectory.pro @ 11

Last change on this file since 11 was 11, checked in by pinsard, 18 years ago

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

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1;------------------------------------------------------------
2;------------------------------------------------------------
3;------------------------------------------------------------
4;+
5; NAME:isadirectory
6;
7; PURPOSE:check if a directory exists and make sure that it ends
8;         with the directory separator mark.
9;
10; CATEGORY: io
11;
12; CALLING SEQUENCE: directory=isadirectory([dirname])
13;
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.
17;
18; KEYWORD PARAMETERS:
19;
20;     IODIRECTORY:a proposed directory
21;
22;     TITLE = the title of the window
23;
24;     all dialog_pickfile keywords (like filter)
25;
26; OUTPUTS: the directory name
27;
28; COMMON BLOCKS:none
29;
30; SIDE EFFECTS:
31;
32; RESTRICTIONS:
33;
34; EXAMPLE:
35;
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;
42; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)
43;                      June 28, 2000
44; June 2005: Sebastien Masson: cleaning, use for file_* functions
45;-
46;------------------------------------------------------------
47;------------------------------------------------------------
48;------------------------------------------------------------
49FUNCTION isadirectory, directoryin, TITLE = title, IODIRECTORY = iodirectory, _extra = ex
50;
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
74
75
76
77
Note: See TracBrowser for help on using the repository browser.