;+ ; ; @file_comments ; if needed, define and create myuniquetmpdir ; (common variable from cm_general) and add it to !path ; ; @categories ; Utilities ; ; @examples ; ; IDL> def_myuniquetmpdir ; ; @uses ; cm_general ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; June 2005 ; ; @version ; $Id$ ; ;- PRO def_myuniquetmpdir ; compile_opt idl2, strictarrsubs ; @cm_general ; IF n_elements(myuniquetmpdir) EQ 0 THEN BEGIN ; define a new and unique directory in getenv('IDL_TMPDIR') by using systime(1) ; if possible, look for the login to make a more explicite name IF file_which(getenv('PATH'), 'whoami') ne '' THEN spawn, 'whoami', login, /noshell ELSE login = 'unknown' myuniquetmpdir = file_search(getenv('IDL_TMPDIR'), /mark_directory) myuniquetmpdir = myuniquetmpdir[0] + 'saxo_' + login[0] + '.' $ + strtrim(long(systime(1)), 1) + '/' ; create it file_mkdir, myuniquetmpdir ; add it to !path !path = myuniquetmpdir + path_sep(/search_path) + !path ; check that each element of !path is unique splpath = strsplit(!path, path_sep(/search_path), /extract, count = ndir) nouniq = different(lindgen(ndir), uniq(splpath, sort(splpath))) IF nouniq[0] NE -1 THEN BEGIN allpro = find('*.pro', iodirectory = !path, /onlypro) nall = n_elements(allpro) allpro = strmid(allpro, reform(strpos(allpro, '/', /reverse_search), 1, nall)+1) nouniqpro = different(lindgen(nall), uniq(allpro, sort(allpro))) IF nouniqpro[0] NE -1 THEN BEGIN nouniqcnt = n_elements(nouniq) nouniqprocnt = n_elements(nouniqpro) text = ['', ' --- WARNING ---' $ , 'Your !path contains '+strtrim(nouniqcnt, 1)+' duplicate elements' $ , 'This can create bugs for files with the same name located in several directories ('+strtrim(nouniqprocnt, 1)+' found)'] dummy = report(text) text = ['', 'duplicate directories in the path:', splpath[nouniq[0:9 <(nouniqcnt-1)]]] IF nouniqcnt GT 10 THEN text = [text, '...'] dummy = report(text, /simple) text = ['', 'files with the same name:', allpro[nouniqpro[0:9 <(nouniqprocnt-1)]]] IF nouniqprocnt GT 10 THEN text = [text, '...', ''] dummy = report(text, /simple) ENDIF ENDIF ENDIF ; return end