source: trunk/SRC/Utilities/isadirectory.pro @ 260

Last change on this file since 260 was 260, checked in by pinsard, 17 years ago

only uppercase between <proidl>...</proidl> in perspective of links to /usr/local_macosx/idl/idl_6.2/idl_6.2/

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1;+
2;
3; @file_comments
4; check if a directory exists and make sure that it ends
5; with the directory separator mark.
6;
7; @categories
8; io
9;
10; @param DIRECTORYIN {in}{optional}
11; a proposed directory. If neither dirname
12; input parameter of IODIRECTORY keyword are defined,
13; we ask the user to choose a directory.
14;
15; @keyword IODIRECTORY
16; a proposed directory
17;
18; @keyword TITLE
19; the title of the window
20;
21; @keyword _EXTRA
22; Used to pass keywords to <proidl>DIALOG_PICKFILE</proidl>
23;
24; @returns
25; the directory name
26;
27; @examples
28;
29; IDL> print, !dir
30;    /usr/local/rsi/idl_6.0
31; IDL> print, isadirectory(!dir)
32;    /usr/local/rsi/idl_6.0/
33; IDL> print, isadirectory(!dir+'notgood')
34;
35; @history
36; Sebastien Masson (smasson\@lodyc.jussieu.fr)
37;                      June 28, 2000
38; June 2005: Sebastien Masson: cleaning, use for file_* functions
39;
40; @version
41; $Id$
42;
43;-
44;
45FUNCTION isadirectory, directoryin, TITLE = title, IODIRECTORY = iodirectory, _EXTRA = ex
46;
47  compile_opt idl2, strictarrsubs
48;
49  CASE 1 OF
50    (size(directoryin, /type))[0] EQ 7:directory = directoryin
51    keyword_set(iodirectory):directory = iodirectory
52    ELSE:directory = 'directory that is not existing'
53  ENDCASE
54  testfile = file_test(directory, /directory)
55; if directory doesn't exist, we ask the user to provide a directory name
56  IF total(testfile) NE n_elements(directory) THEN BEGIN
57    IF NOT keyword_set(title) THEN title = 'choose a directory'
58    FOR i = 0, n_elements(directory)-1 DO BEGIN
59      IF testfile[i] EQ 0 THEN BEGIN
60        directory[i] = dialog_pickfile(/directory, title = title $
61                                       , /must_exist, _extra = ex)
62        if directory[i] EQ '' THEN RETURN, report('check/find directory canceled')
63      ENDIF
64    ENDFOR
65  ENDIF
66;
67  directory = file_search(directory, /mark_directory, /test_directory, /fully_qualify_path)
68  IF n_elements(directory) EQ 1 THEN RETURN, directory[0] $
69  ELSE RETURN, directory
70;
71END
Note: See TracBrowser for help on using the repository browser.