儲存庫 vbox 的更動 45243
- 時間撮記:
- 2013-3-28 下午09:22:12 (12 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Runtime/r3/darwin/RTPathUserDocuments-darwin.cpp
r36611 r45243 5 5 6 6 /* 7 * Copyright (C) 2011 Oracle Corporation7 * Copyright (C) 2011-2013 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 29 29 *******************************************************************************/ 30 30 #include <iprt/path.h> 31 #include "internal/iprt.h" 32 33 #include <iprt/assert.h> 34 #include <iprt/string.h> 31 35 #include <iprt/err.h> 32 #include <iprt/assert.h>33 36 34 #include <CoreServices/CoreServices.h> 37 #include <NSSystemDirectories.h> 38 #include <sys/syslimits.h> 39 #ifdef IPRT_USE_CORE_SERVICE_FOR_USER_DOCUMENTS 40 # include <CoreServices/CoreServices.h> 41 #endif 42 35 43 36 44 RTDECL(int) RTPathUserDocuments(char *pszPath, size_t cchPath) … … 42 50 AssertReturn(cchPath, VERR_INVALID_PARAMETER); 43 51 52 /* 53 * Try NSSystemDirectories first since that works for directories that doesn't exist. 54 */ 55 int rc = VERR_PATH_NOT_FOUND; 56 NSSearchPathEnumerationState EnmState = NSStartSearchPathEnumeration(NSDocumentDirectory, NSUserDomainMask); 57 if (EnmState != 0) 58 { 59 char szTmp[PATH_MAX]; 60 szTmp[0] = szTmp[PATH_MAX - 1] = '\0'; 61 EnmState = NSGetNextSearchPathEnumeration(EnmState, szTmp); 62 if (EnmState != 0) 63 { 64 size_t cchTmp = strlen(szTmp); 65 if (cchTmp >= cchPath) 66 return VERR_BUFFER_OVERFLOW; 67 68 if (szTmp[0] == '~' && szTmp[1] == '/') 69 { 70 /* Expand tilde. */ 71 rc = RTPathUserHome(pszPath, cchPath - cchTmp + 2); 72 if (RT_FAILURE(rc)) 73 return rc; 74 rc = RTPathAppend(pszPath, cchPath, &szTmp[2]); 75 } 76 else 77 rc = RTStrCopy(pszPath, cchPath, szTmp); 78 return rc; 79 } 80 } 81 82 #ifdef IPRT_USE_CORE_SERVICE_FOR_USER_DOCUMENTS 83 /* 84 * Fall back on FSFindFolder in case the above should fail... 85 */ 44 86 FSRef ref; 45 87 OSErr err = FSFindFolder(kOnAppropriateDisk, kDocumentsFolderType, false /* createFolder */, &ref); 46 if (err != noErr) 47 return VERR_PATH_NOT_FOUND; 48 49 err = FSRefMakePath(&ref, (UInt8*)pszPath, cchPath); 50 if (err != noErr) 51 return VERR_PATH_NOT_FOUND; 52 53 return VINF_SUCCESS; 88 if (err == noErr) 89 { 90 err = FSRefMakePath(&ref, (UInt8*)pszPath, cchPath); 91 if (err == noErr) 92 return VINF_SUCCESS; 93 } 94 #endif 95 Assert(RT_FAILURE_NP(rc)); 96 return rc; 54 97 } 55 98
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器