[11] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[128] | 3 | ; @file_comments |
---|
| 4 | ; if needed, define and create myuniquetmpdir |
---|
[93] | 5 | ; (common variable from cm_general) and add it to !path |
---|
[11] | 6 | ; |
---|
[157] | 7 | ; @categories |
---|
| 8 | ; Utilities |
---|
[11] | 9 | ; |
---|
[128] | 10 | ; @examples |
---|
[11] | 11 | ; |
---|
[371] | 12 | ; IDL> def_myuniquetmpdir |
---|
| 13 | ; |
---|
[224] | 14 | ; @uses |
---|
[371] | 15 | ; <pro>cm_general</pro> |
---|
[11] | 16 | ; |
---|
[224] | 17 | ; @history |
---|
| 18 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[11] | 19 | ; June 2005 |
---|
| 20 | ; |
---|
[224] | 21 | ; @version |
---|
| 22 | ; $Id$ |
---|
[118] | 23 | ; |
---|
[11] | 24 | ;- |
---|
| 25 | PRO def_myuniquetmpdir |
---|
[114] | 26 | ; |
---|
| 27 | compile_opt idl2, strictarrsubs |
---|
| 28 | ; |
---|
[11] | 29 | @cm_general |
---|
| 30 | ; |
---|
[311] | 31 | IF n_elements(myuniquetmpdir) EQ 0 THEN BEGIN |
---|
[11] | 32 | ; define a new and unique directory in getenv('IDL_TMPDIR') by using systime(1) |
---|
[311] | 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' |
---|
[11] | 35 | myuniquetmpdir = file_search(getenv('IDL_TMPDIR'), /mark_directory) |
---|
[311] | 36 | myuniquetmpdir = myuniquetmpdir[0] + 'saxo_' + login[0] + '.' $ |
---|
| 37 | + strtrim(long(systime(1)), 1) + '/' |
---|
[11] | 38 | ; create it |
---|
| 39 | file_mkdir, myuniquetmpdir |
---|
| 40 | ; add it to !path |
---|
[239] | 41 | !path = myuniquetmpdir + path_sep(/search_path) + !path |
---|
[317] | 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 |
---|
[11] | 65 | ENDIF |
---|
| 66 | ; |
---|
| 67 | |
---|
| 68 | return |
---|
| 69 | end |
---|