如何在运行时以编程方式确定给定路径是 Mac OS X 上的网络路径还是本地路径?
例如:1. /Volumes/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;