Changeset 8257 for trunk/src/kernel32/disk.cpp
- Timestamp:
- Apr 13, 2002, 8:20:36 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/disk.cpp
r7849 r8257 1 /* $Id: disk.cpp,v 1.3 2 2002-02-09 12:45:12 sandervlExp $ */1 /* $Id: disk.cpp,v 1.33 2002-04-13 06:20:36 bird Exp $ */ 2 2 3 3 /* … … 85 85 TVFSTOHPFS = 1 86 86 */ 87 if(lpSectorsPerCluster!=NULL) 87 if(lpSectorsPerCluster!=NULL) 88 88 { 89 if(*lpSectorsPerCluster==1024 && PROFILE_GetOdinIniBool("DRIVESPACE","CLUSTERTO32",0)) 89 if(*lpSectorsPerCluster==1024 && PROFILE_GetOdinIniBool("DRIVESPACE","CLUSTERTO32",0)) 90 90 {/* TVFS returns 1024 sectors per cluster */ 91 91 dprintf(("KERNEL32: GetDiskFreeSpaceA, TVFS-Drive detected. Faking clustersize to 32.\n")); … … 206 206 return(rc); 207 207 } 208 //****************************************************************************** 209 //Note: NT4, SP6 does not change the last error, regardless of the junk it receives! 210 //****************************************************************************** 208 209 210 /** 211 * Determin the type of a specific drive or the current drive. 212 * 213 * @returns DRIVE_UNKNOWN 214 * DRIVE_NO_ROOT_DIR 215 * DRIVE_CANNOTDETERMINE 216 * DRIVE_DOESNOTEXIST 217 * DRIVE_REMOVABLE 218 * DRIVE_FIXED 219 * DRIVE_REMOTE 220 * DRIVE_CDROM 221 * DRIVE_RAMDISK 222 * 223 * @param lpszDrive Root path of the drive in question. 224 * NULL means the current drive. 225 * @sketch 226 * If no drive Then 227 * Get Current Drive Index. 228 * ElseIf valid drive letter Then 229 * Convert to Drive Index. 230 * Else 231 * Return Error: Invalid root dir. 232 * Endif 233 * Call the OSLib worker function with the index. 234 * return it's result. 235 * 236 * @status completely implemented and tested 237 * @author Sander 238 * @remark NT4, SP6 does not change the last error, regardless of the junk it receives! 239 */ 211 240 UINT WIN32API GetDriveTypeA(LPCSTR lpszDrive) 212 241 { 213 UINT rc; 214 ULONG driveIndex; 215 216 if(lpszDrive == 0) { 217 driveIndex = OSLibDosQueryCurrentDisk() - 1; 218 } 219 else 220 if(*lpszDrive >= 'A' && *lpszDrive <= 'Z') 221 driveIndex = (DWORD)(*lpszDrive - 'A'); 222 else 223 if(*lpszDrive >= 'a' && *lpszDrive <= 'z') { 224 driveIndex = (DWORD)(*lpszDrive - 'a'); 225 } 226 else { 242 UINT rc; 243 ULONG ulDrive = ~0; 244 245 /* validate and convert input */ 246 if (!lpszDrive) 247 ulDrive = OSLibDosQueryCurrentDisk() - 1; 248 else if (*lpszDrive != '\0' && lpszDrive[1] == ':') 249 { 250 if (*lpszDrive >= 'A' && *lpszDrive <= 'Z') 251 ulDrive = *lpszDrive - 'A'; 252 else if (*lpszDrive >= 'a' && *lpszDrive <= 'z') 253 ulDrive = *lpszDrive - 'a'; 254 255 /* 256 * Validate the rest of the path. 257 * Note: This validate is kind of weird. 258 * "c:\\\\\\\\\\\\" is ok 259 * "c:\\\\\\\\\\\\." is ok 260 * "c:\\\\\\\\\\\\........" is ok 261 * "c:\\\\\\\\\\\.\" is not ok 262 * "c:..............." is ok 263 * "c:\\ \ \ \ \ \\\\\" is not ok 264 * "c:\\ \ \ \ \ \\\\\" is not ok 265 * "c:\ . . . . . ." is ok 266 * "c:\/\/\/ . . . . ." is ok 267 * "c:\\\.\\\/\." is ok 268 * I hope I got it right. 269 */ 270 if (ulDrive != ~0) 271 { 272 LPCSTR lpsz = lpszDrive + 2; 273 274 /* skip slashes and dots */ 275 while (*lpsz == '.' || *lpsz == '\\' || *lpsz == '/') 276 lpsz++; 277 /* skip dot's and spaces. */ 278 while (*lpsz == ' ' || *lpsz == '.') 279 lpsz++; 280 if (*lpsz) 281 ulDrive = ~0; 282 } 283 } 284 285 /* check if validation failed */ 286 if (ulDrive == ~0) 287 { 288 dprintf(("KERNEL32: GetDriveType(""%s"") -> DRIVE_NO_ROOT_DIR (%d)", lpszDrive, DRIVE_NO_ROOT_DIR)); 227 289 return DRIVE_NO_ROOT_DIR; //return value checked in NT4, SP6 (GetDriveType(""), GetDriveType("4"); 228 290 } 229 291 230 292 //NOTE: Although GetDriveTypeW handles -1, GetDriveTypeA crashes in NT 4, SP6 231 rc = OSLibGetDriveType( driveIndex);293 rc = OSLibGetDriveType(ulDrive); 232 294 dprintf(("KERNEL32: GetDriveType %s = %d", lpszDrive, rc)); 233 295 return rc; 234 296 } 235 //****************************************************************************** 236 //****************************************************************************** 297 298 299 /** 300 * Determin the type of a specific drive or the current drive. 301 * 302 * @returns DRIVE_UNKNOWN 303 * DRIVE_NO_ROOT_DIR 304 * DRIVE_CANNOTDETERMINE 305 * DRIVE_DOESNOTEXIST 306 * DRIVE_REMOVABLE 307 * DRIVE_FIXED 308 * DRIVE_REMOTE 309 * DRIVE_CDROM 310 * DRIVE_RAMDISK 311 * 312 * @param lpszDrive Root path of the drive in question. 313 * NULL means the current drive. 314 * @sketch 315 * If no drive Then 316 * Get Current Drive Index. 317 * ElseIf valid drive letter Then 318 * Convert to Drive Index. 319 * Else 320 * Return Error: Invalid root dir. 321 * Endif 322 * Call the OSLib worker function with the index. 323 * return it's result. 324 * 325 * @status completely implemented and tested 326 * @author Sander 327 * @remark NT4, SP6 does not change the last error, regardless of the junk it receives! 328 */ 237 329 UINT WIN32API GetDriveTypeW(LPCWSTR lpszDrive) 238 330 { … … 293 385 } 294 386 } 295 if(lpFileSystemNameBuffer || lpMaximumComponentLength || lpFileSystemFlags) 387 if(lpFileSystemNameBuffer || lpMaximumComponentLength || lpFileSystemFlags) 296 388 { 297 389 if(!lpFileSystemNameBuffer) { … … 303 395 if(rc == ERROR_SUCCESS) strcpy(szOrgFileSystemName, lpFileSystemNameBuffer); 304 396 305 if(lpFileSystemNameBuffer) 397 if(lpFileSystemNameBuffer) 306 398 { 307 399 dprintf2(("File system name: %s", lpFileSystemNameBuffer)); 308 if(!strcmp(lpFileSystemNameBuffer, "JFS")) 400 if(!strcmp(lpFileSystemNameBuffer, "JFS")) 309 401 { 310 402 strcpy(lpFileSystemNameBuffer, "NTFS"); … … 316 408 //do nothing 317 409 } 318 else 410 else 319 411 {//pretend everything else is FAT16 (HPFS and FAT have the same file size limit) 320 412 strcpy(lpFileSystemNameBuffer, "FAT16");
Note:
See TracChangeset
for help on using the changeset viewer.