Changeset 1229 for trunk/eraser6
- Timestamp:
- 9/30/2009 4:52:22 AM (4 years ago)
- Location:
- trunk/eraser6/Eraser.Util.FileSystem
- Files:
-
- 3 edited
-
Fat12Or16Api.cpp (modified) (5 diffs)
-
Fat32Api.cpp (modified) (2 diffs)
-
FatApi.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/Eraser.Util.FileSystem/Fat12Or16Api.cpp
r1228 r1229 66 66 long long Fat12Or16Api::ClusterToOffset(unsigned cluster) 67 67 { 68 unsigned long long sector = BootSector->ReservedSectorCount + //Reserved area69 BootSector->FatCount * BootSector->SectorsPerFat + //FAT area70 (BootSector->RootDirectoryEntryCount * sizeof(::FatDirectoryEntry) / (ClusterSize / SectorSize)) + //Root directory area68 unsigned long long sector = BootSector->ReservedSectorCount + //Reserved area 69 BootSector->FatCount * BootSector->SectorsPerFat + //FAT area 70 (BootSector->RootDirectoryEntryCount * sizeof(::FatDirectoryEntry) / SectorSize) + //Root directory area 71 71 (static_cast<unsigned long long>(cluster) - 2) * (ClusterSize / SectorSize); 72 72 return SectorToOffset(sector); … … 76 76 { 77 77 //The path must start with a backslash as it must be volume-relative. 78 if (path->Length != 0 && path[0] != L'\\') 79 throw gcnew ArgumentException(L"The path provided is not volume relative. " + 80 gcnew String(L"Volume relative paths must begin with a backslash.")); 78 if (path->Length != 0) 79 { 80 if (path[0] != L'\\') 81 throw gcnew ArgumentException(L"The path provided is not volume relative. " + 82 gcnew String(L"Volume relative paths must begin with a backslash.")); 83 path = path->Remove(0, 1); 84 } 81 85 82 86 //Chop the path into it's constituent directory components … … 86 90 //Traverse the directories until we get the cluster we want. 87 91 unsigned cluster = 0; 88 FatDirectoryBase^ parentDir = gcnew RootDirectory(this);92 FatDirectoryBase^ parentDir = nullptr; 89 93 for each (String^ component in components) 90 94 { … … 92 96 break; 93 97 94 parentDir = LoadDirectory(cluster, parentDir == nullptr ? nullptr: parentDir->Name,98 parentDir = LoadDirectory(cluster, parentDir == nullptr ? String::Empty : parentDir->Name, 95 99 parentDir); 96 100 cluster = parentDir->Items[component]->Cluster; … … 105 109 BootSector->SectorCount32 : BootSector->SectorCount16); 106 110 unsigned long long availableSectors = numberOfSectors - ( 107 BootSector->ReservedSectorCount + //Reserved area108 BootSector->FatCount * BootSector->SectorsPerFat + //FAT area109 (BootSector->RootDirectoryEntryCount * sizeof(::FatDirectoryEntry) / (ClusterSize / SectorSize)) //Root directory area111 BootSector->ReservedSectorCount + //Reserved area 112 BootSector->FatCount * BootSector->SectorsPerFat + //FAT area 113 (BootSector->RootDirectoryEntryCount * sizeof(::FatDirectoryEntry) / SectorSize) //Root directory area 110 114 ); 111 115 unsigned long long numberOfClusters = availableSectors / (ClusterSize / SectorSize); -
trunk/eraser6/Eraser.Util.FileSystem/Fat32Api.cpp
r1226 r1229 114 114 { 115 115 //The path must start with a backslash as it must be volume-relative. 116 if (path->Length != 0 && path[0] != L'\\') 117 throw gcnew ArgumentException(L"The path provided is not volume relative. " + 118 gcnew String(L"Volume relative paths must begin with a backslash.")); 116 if (path->Length != 0) 117 { 118 if (path[0] != L'\\') 119 throw gcnew ArgumentException(L"The path provided is not volume relative. " + 120 gcnew String(L"Volume relative paths must begin with a backslash.")); 121 path = path->Remove(0, 1); 122 } 119 123 120 124 //Chop the path into it's constituent directory components … … 130 134 break; 131 135 132 parentDir = LoadDirectory(cluster, parentDir == nullptr ? nullptr: parentDir->Name,136 parentDir = LoadDirectory(cluster, parentDir == nullptr ? String::Empty : parentDir->Name, 133 137 parentDir); 134 138 cluster = parentDir->Items[component]->Cluster; -
trunk/eraser6/Eraser.Util.FileSystem/FatApi.cpp
r1226 r1229 84 84 int lastIndex = directory->LastIndexOfAny(pathSeparators); 85 85 return LoadDirectory(DirectoryToCluster(directory), directory->Substring(lastIndex + 1), 86 LoadDirectory(directory->Substring(0, lastIndex == 0 ? 0 : lastIndex - 1)));86 LoadDirectory(directory->Substring(0, lastIndex))); 87 87 } 88 88 … … 200 200 for (unsigned char sequence = 0; i->Short.Attributes == 0x0F; ++i) 201 201 { 202 if (!(i->LongFileName.Sequence & 0x40)) //Second entry onwards 202 if (static_cast<unsigned char>(i->Short.Name[0]) == 0xE5) 203 continue; 204 else if (!(i->LongFileName.Sequence & 0x40)) //Second entry onwards 203 205 { 204 206 //Check that the checksum of the file name is the same as the previous … … 226 228 validEntries.insert(validEntries.end(), longFileNameBegin, i); 227 229 } 230 else 231 { 232 --i; 233 continue; 234 } 228 235 } 229 236 … … 234 241 //the memory used. 235 242 memset(Directory, 0, DirectorySize * sizeof(::FatDirectoryEntry)); 236 memcpy(Directory, &validEntries.front(), validEntries.size() * sizeof(::FatDirectory ));243 memcpy(Directory, &validEntries.front(), validEntries.size() * sizeof(::FatDirectoryEntry)); 237 244 238 245 //Write the entries to disk … … 262 269 for (unsigned char sequence = 0; i->Short.Attributes == 0x0F; ++i) 263 270 { 264 if (!(i->LongFileName.Sequence & 0x40)) //Second entry onwards 271 if (static_cast<unsigned char>(i->Short.Name[0]) == 0xE5) 272 continue; 273 else if (!(i->LongFileName.Sequence & 0x40)) //Second entry onwards 265 274 { 266 275 //Check that the checksum of the file name is the same as the previous … … 273 282 throw gcnew ArgumentException(L"Invalid directory entry."); 274 283 } 284 else 285 longFileName.clear(); 275 286 276 287 sequence = i->LongFileName.Sequence & ~0x40; … … 297 308 FatDirectoryEntryTypes::Directory : FatDirectoryEntryTypes::File, 298 309 GetStartCluster(*i))); 310 } 311 else 312 { 313 --i; 314 continue; 299 315 } 300 316 }
Note: See TracChangeset
for help on using the changeset viewer.
