source: trunk/SRC/Utilities/def_myuniquetmpdir.pro @ 378

Last change on this file since 378 was 371, checked in by pinsard, 16 years ago

improvements of headers (alignments of IDL prompt in examples)

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1;+
2;
3; @file_comments
4; if needed, define and create myuniquetmpdir
5; (common variable from cm_general) and add it to !path
6;
7; @categories
8; Utilities
9;
10; @examples
11;
12;   IDL> def_myuniquetmpdir
13;
14; @uses
15; <pro>cm_general</pro>
16;
17; @history
18; Sebastien Masson (smasson\@lodyc.jussieu.fr)
19;                      June 2005
20;
21; @version
22; $Id$
23;
24;-
25PRO def_myuniquetmpdir
26;
27  compile_opt idl2, strictarrsubs
28;
29@cm_general
30;
31  IF n_elements(myuniquetmpdir) EQ 0 THEN BEGIN
32; define a new and unique directory in getenv('IDL_TMPDIR') by using systime(1)
33; if possible, look for the login to make a more explicite name
34    IF file_which(getenv('PATH'), 'whoami') ne '' THEN spawn, 'whoami', login, /noshell ELSE login = 'unknown'
35    myuniquetmpdir = file_search(getenv('IDL_TMPDIR'), /mark_directory)
36    myuniquetmpdir = myuniquetmpdir[0] + 'saxo_' + login[0] + '.' $
37                     + strtrim(long(systime(1)), 1) + '/'
38; create it
39    file_mkdir, myuniquetmpdir
40; add it to !path
41    !path = myuniquetmpdir + path_sep(/search_path) + !path
42; check that each element of !path is unique
43    splpath = strsplit(!path, path_sep(/search_path), /extract, count = ndir)
44    nouniq = different(lindgen(ndir), uniq(splpath, sort(splpath)))
45    IF nouniq[0] NE -1 THEN BEGIN
46      allpro = find('*.pro', iodirectory = !path, /onlypro)
47      nall = n_elements(allpro)
48      allpro = strmid(allpro, reform(strpos(allpro, '/', /reverse_search), 1, nall)+1)
49      nouniqpro = different(lindgen(nall), uniq(allpro, sort(allpro)))
50      IF nouniqpro[0] NE -1 THEN BEGIN
51        nouniqcnt = n_elements(nouniq)
52        nouniqprocnt = n_elements(nouniqpro)
53        text = ['', '   --- WARNING ---' $
54                , 'Your !path contains '+strtrim(nouniqcnt, 1)+' duplicate elements' $
55                , 'This can create bugs for files with the same name located in several directories ('+strtrim(nouniqprocnt, 1)+' found)']
56        dummy = report(text)
57        text = ['', 'duplicate directories in the path:', splpath[nouniq[0:9 <(nouniqcnt-1)]]]
58        IF nouniqcnt GT 10 THEN text = [text, '...']
59        dummy = report(text, /simple)
60        text = ['', 'files with the same name:', allpro[nouniqpro[0:9 <(nouniqprocnt-1)]]]
61        IF nouniqprocnt GT 10 THEN text = [text, '...', '']
62        dummy = report(text, /simple)
63      ENDIF
64    ENDIF
65  ENDIF
66;
67
68  return
69end
Note: See TracBrowser for help on using the repository browser.