如何在運行時以編程方式確定給定路徑是Mac OS X上的網絡路徑還是本地路徑?以編程方式知道給定的路徑在Mac OS X上是網絡路徑還是本地路徑
例如: 1. /卷/ ABC/XYZ(安裝使用SMB) 2. ../test/pqr(應用程序共享的網絡路徑上,因此,在當前工作目錄也是一個網絡路徑,因此相對路徑也是網絡路徑)
像下面的Windows一樣,代碼將確定pPath是否是網絡共享路徑(如* 1. \ TallyDT100 \ c \ test \ file.txt 2. z:\ test \ file.txt(當z:映射到某個網絡路徑時的網絡路徑)
UNIVERSAL_NAME_INFO * universalname = NULL; ///< for getting the universal path name of file on network share.
DWORD retval; ///< for getting the return value from WNetGetUniversalName
DWORD length = MAX_PATH_LEN; ///< length of universal name which would be made.
// The memory for getting the universal name information is allocated.
universalname = (UNIVERSAL_NAME_INFO *) Calloc (MAX_PATH_LEN * sizeof (Char));
retval = WNetGetUniversalName (pPath, UNIVERSAL_NAME_INFO_LEVEL, universalname, &length);
Free (universalname);
// NO_ERROR is returned only when it's drive mapped for shared network folder.
return (NO_ERROR == retval) ? true : false;
你有特定的網絡路徑?? –
例如:1./Volumes/abc/xyz(使用smb掛載) –
或2. ../test/pqr(應用程序位於共享網絡路徑上,因此當前工作目錄也是網絡路徑,因此相對路徑也是一個網絡路徑) –