vbox的更動 20101 路徑 trunk/src/VBox/Runtime/r3/path.cpp
- 時間撮記:
- 2009-5-27 下午04:43:08 (15 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Runtime/r3/path.cpp
r20019 r20101 964 964 } 965 965 966 966 967 /** 967 968 * Gets the temporary directory path. 968 969 * 969 970 * @returns iprt status code. 971 * 970 972 * @param pszPath Buffer where to store the path. 971 973 * @param cchPath Buffer size in bytes. … … 973 975 RTDECL(int) RTPathTemp(char *pszPath, size_t cchPath) 974 976 { 975 int rc; 976 const char *pszTmpEnv = RTEnvGet("TMP"); 977 if (!pszTmpEnv) 978 pszTmpEnv = RTEnvGet("TEMP"); 979 char *pszTmpDir; 980 /* Make a copy in any case. */ 981 if (pszTmpEnv) 982 pszTmpDir = RTStrDup(pszTmpEnv); 983 else 984 pszTmpDir = RTStrDup("/tmp"); 985 986 size_t cchTmpDir = strlen(pszTmpDir); 987 if (cchTmpDir < cchPath) 988 memcpy(pszPath, pszTmpDir, cchTmpDir + 1); 989 else 990 rc = VERR_BUFFER_OVERFLOW; 991 RTStrFree(pszTmpDir); 992 return rc; 977 /* 978 * Try get it from the environment first. 979 */ 980 static const char * const s_apszVars[] = 981 { 982 "IPRT_TMPDIR" 983 #if defined(RT_OS_WINDOWS) 984 , "TMP", "TEMP", "USERPROFILE" 985 #elif defined(RT_OS_OS2) 986 , "TMP", "TEMP", "TMPDIR" 987 #else 988 , "TMPDIR" 989 #endif 990 }; 991 for (size_t iVar = 0; iVar < RT_ELEMENTS(s_apszVars); iVar++) 992 { 993 int rc = RTEnvGetEx(RTENV_DEFAULT, s_apszVars[iVar], pszPath, cchPath, NULL); 994 if (rc != VERR_ENV_VAR_NOT_FOUND) 995 return rc; 996 } 997 998 /* 999 * Here we should use some sane system default, instead we just use 1000 * the typical unix temp dir for now. 1001 */ 1002 /** @todo Windows should default to the windows directory, see GetTempPath. 1003 * Some unixes has path.h and _PATH_TMP. There is also a question about 1004 * whether /var/tmp wouldn't be a better place... */ 1005 if (cchPath < sizeof("/tmp") ) 1006 return VERR_BUFFER_OVERFLOW; 1007 memcpy(pszPath, "/tmp", sizeof("/tmp")); 1008 return VINF_SUCCESS; 993 1009 } 994 1010
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器