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