Changeset 1175 in kBuild
- Timestamp:
- Oct 4, 2007 6:33:47 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt_fullpath.c
r1165 r1175 225 225 226 226 static BOOL g_fInitialized = FALSE; 227 static int g_afNtfsDrives['Z' - 'A' + 1]; 227 228 static LONG (NTAPI *g_pfnNtQueryInformationFile)(HANDLE FileHandle, 228 229 PMY_IO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, … … 238 239 LONG rcNt; 239 240 HANDLE hFile; 241 int cchOut; 242 char *psz; 240 243 241 244 /* … … 248 251 *(FARPROC *)&g_pfnNtQueryInformationFile = 249 252 GetProcAddress(LoadLibrary("ntdll.dll"), "NtQueryInformationFile"); 253 if (g_pfnNtQueryInformationFile) 254 { 255 unsigned i; 256 for (i = 0; i < sizeof(g_afNtfsDrives) / sizeof(g_afNtfsDrives[0]); i++ ) 257 g_afNtfsDrives[i] = -1; 258 } 250 259 } 251 260 if (!g_pfnNtQueryInformationFile) 261 return -1; 262 263 /* 264 * The FileNameInformation we get is relative to where the volume is mounted, 265 * so we have to extract the driveletter prefix ourselves. 266 * 267 * FIXME: This will probably not work for volumes mounted in NTFS sub-directories. 268 */ 269 psz = pszFull; 270 if (pszPath[0] == '\\' || pszPath[0] == '/') 271 { 272 /* unc or root of volume */ 273 if ( (pszPath[1] == '\\' || pszPath[1] == '/') 274 && (pszPath[2] != '\\' || pszPath[2] == '/')) 275 { 276 #if 0 /* don't bother with unc yet. */ 277 /* unc - we get the server + name back */ 278 *psz++ = '\\'; 279 #endif 280 return -1; 281 } 282 /* root slash */ 283 *psz++ = _getdrive() + 'A' - 1; 284 *psz++ = ':'; 285 } 286 else if (pszPath[1] == ':' && isalpha(pszPath[0])) 287 { 288 /* drive letter */ 289 *psz++ = toupper(pszPath[0]); 290 *psz++ = ':'; 291 } 292 else 293 { 294 /* relative */ 295 *psz++ = _getdrive() + 'A' - 1; 296 *psz++ = ':'; 297 } 298 299 /* 300 * Fat32 doesn't return filenames with the correct case, so restrict it 301 * to NTFS volumes for now. 302 */ 303 if (g_afNtfsDrives[*pszFull - 'A'] == -1) 304 { 305 char szFSName[32]; 306 307 psz[0] = '\\'; 308 psz[1] = '\0'; 309 if ( GetVolumeInformation(pszFull, 310 NULL, 0, /* volume name */ 311 NULL, /* serial number */ 312 NULL, /* max component */ 313 NULL, /* volume attribs */ 314 szFSName, 315 sizeof(szFSName)) 316 && !strcmp(szFSName, "NTFS")) 317 g_afNtfsDrives[*pszFull - 'A'] = 1; 318 else 319 g_afNtfsDrives[*pszFull - 'A'] = 0; 320 } 321 if (!g_afNtfsDrives[*pszFull - 'A']) 252 322 return -1; 253 323 … … 269 339 if (rcNt >= 0) 270 340 { 271 /*272 * The FileNameInformation we get is relative to where the volume is mounted,273 * so we have to extract the driveletter prefix ourselves.274 *275 * FIXME: This will probably not work for volumes mounted in NTFS sub-directories.276 */277 int cchOut;278 int fUnc = 0;279 char *psz = pszFull;280 if (pszPath[0] == '\\' || pszPath[0] == '/')281 {282 /* unc or root of volume */283 if ( (pszPath[1] == '\\' || pszPath[1] == '/')284 && (pszPath[2] != '\\' || pszPath[2] == '/'))285 {286 /* unc - we get the server + name back */287 *psz++ = '\\';288 fUnc = 1;289 }290 else291 {292 /* root slash */293 *psz++ = _getdrive() + 'A' - 1;294 *psz++ = ':';295 }296 }297 else if (pszPath[1] == ':' && isalpha(pszPath[0]))298 {299 /* drive letter */300 *psz++ = toupper(pszPath[0]);301 *psz++ = ':';302 }303 else304 {305 /* relative */306 *psz++ = _getdrive() + 'A' - 1;307 *psz++ = ':';308 }309 310 341 cchOut = WideCharToMultiByte(CP_ACP, 0, 311 342 pFileNameInfo->FileName, pFileNameInfo->FileNameLength / sizeof(WCHAR), … … 314 345 { 315 346 const char *pszEnd; 316 347 #if 0 317 348 /* upper case the server and share */ 318 349 if (fUnc) … … 323 354 *psz = toupper(*psz); 324 355 } 325 356 #endif 326 357 /* add trailing slash on directories if input has it. */ 327 358 pszEnd = strchr(pszPath, '\0');
Note:
See TracChangeset
for help on using the changeset viewer.