Changeset 1220
- Timestamp:
- 9/29/2009 2:15:24 PM (4 years ago)
- Location:
- trunk/eraser6/Eraser.Util.FileSystem
- Files:
-
- 3 edited
-
Fat32Api.cpp (modified) (4 diffs)
-
FatApi.cpp (modified) (6 diffs)
-
FatApi.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser6/Eraser.Util.FileSystem/Fat32Api.cpp
r1219 r1220 58 58 } 59 59 60 FatDirectory^ Fat32Api::LoadDirectory(unsigned cluster, String^ name )60 FatDirectory^ Fat32Api::LoadDirectory(unsigned cluster, String^ name, FatDirectory^ parent) 61 61 { 62 return gcnew Directory(name, cluster, this);62 return gcnew Directory(name, parent, cluster, this); 63 63 } 64 64 … … 126 126 //Traverse the directories until we get the cluster we want. 127 127 unsigned cluster = BootSector->Fat32ParameterBlock.RootDirectoryCluster; 128 String^ parentDir = nullptr;128 FatDirectory^ parentDir = nullptr; 129 129 for each (String^ component in components) 130 130 { … … 132 132 break; 133 133 134 FatDirectory^ currentDirectory = LoadDirectory(cluster, parentDir);135 cluster = currentDirectory->Items[component]->Cluster;136 parentDir = component;134 parentDir = LoadDirectory(cluster, parentDir == nullptr ? nullptr : parentDir->Name, 135 parentDir); 136 cluster = parentDir->Items[component]->Cluster; 137 137 } 138 138 … … 140 140 } 141 141 142 Fat32Api::Directory::Directory(String^ name, unsigned cluster, Fat32Api^ api)143 : FatDirectory(name, cluster, api)142 Fat32Api::Directory::Directory(String^ name, FatDirectory^ parent, unsigned cluster, Fat32Api^ api) 143 : FatDirectory(name, parent, cluster, api) 144 144 { 145 145 } -
trunk/eraser6/Eraser.Util.FileSystem/FatApi.cpp
r1219 r1220 80 80 FatDirectory^ FatApi::LoadDirectory(String^ directory) 81 81 { 82 String^ directory2 = Path::GetDirectoryName(directory); 83 return LoadDirectory(DirectoryToCluster(directory), directory2); 82 array<wchar_t>^ pathSeparators = { Path::DirectorySeparatorChar, Path::AltDirectorySeparatorChar }; 83 DirectoryInfo^ info = gcnew DirectoryInfo(directory); 84 return LoadDirectory(DirectoryToCluster(directory), directory->Substring( 85 directory->IndexOfAny(pathSeparators)), 86 info->Parent == nullptr ? nullptr : LoadDirectory(info->Parent->FullName)); 84 87 } 85 88 … … 146 149 } 147 150 148 FatDirectoryEntry::FatDirectoryEntry(String^ name, FatDirectoryEntryTypes type, unsigned cluster) 151 FatDirectoryEntry::FatDirectoryEntry(String^ name, FatDirectory^ parent, 152 FatDirectoryEntryTypes type, unsigned cluster) 149 153 { 150 154 Name = name; 155 Parent = parent; 151 156 Type = type; 152 157 Cluster = cluster; … … 161 166 { 162 167 currentEntry = currentEntry->Parent; 163 result = currentEntry->Name + Path:: PathSeparator + result;168 result = currentEntry->Name + Path::DirectorySeparatorChar + result; 164 169 } 165 170 … … 167 172 } 168 173 169 FatDirectory::FatDirectory(String^ name, unsigned cluster, FatApi^ api) 170 : FatDirectoryEntry(name, FatDirectoryEntryTypes::Directory, cluster) 171 { 174 FatDirectory::FatDirectory(String^ name, FatDirectory^ parent, unsigned cluster, FatApi^ api) 175 : FatDirectoryEntry(name, parent, FatDirectoryEntryTypes::Directory, cluster) 176 { 177 System::Diagnostics::Debug::Print(FullName); 172 178 Entries = gcnew Dictionary<String^, FatDirectoryEntry^>(); 173 179 Api = api; … … 227 233 //invalid characters. 228 234 String^ fileName = gcnew String(longFileName.c_str()); 229 Entries->Add(fileName, gcnew FatDirectoryEntry(fileName, 235 Entries->Add(fileName, gcnew FatDirectoryEntry(fileName, this, 230 236 (i->Short.Attributes & FILE_ATTRIBUTE_DIRECTORY) ? 231 237 FatDirectoryEntryTypes::Directory : FatDirectoryEntryTypes::File, … … 259 265 260 266 String^ fileName = gcnew String(shortFileName); 261 Entries->Add(fileName, gcnew FatDirectoryEntry(fileName, 267 Entries->Add(fileName, gcnew FatDirectoryEntry(fileName, this, 262 268 (i->Short.Attributes & FILE_ATTRIBUTE_DIRECTORY) ? 263 269 FatDirectoryEntryTypes::Directory : FatDirectoryEntryTypes::File, -
trunk/eraser6/Eraser.Util.FileSystem/FatApi.h
r1219 r1220 54 54 55 55 /// Loads the directory structure at the given cluster. 56 virtual FatDirectory^ LoadDirectory(unsigned cluster, String^ name ) = 0;56 virtual FatDirectory^ LoadDirectory(unsigned cluster, String^ name, FatDirectory^ parent) = 0; 57 57 58 58 internal: … … 128 128 { 129 129 public: 130 /// Gets the name of the file or directory. 131 property String^ Name 132 { 133 String^ get() { return name; } 134 private: 135 void set(String^ value) { name = value; } 136 } 137 138 /// Gets the full path to the file or directory. 139 property String^ FullName 140 { 141 String^ get(); 142 } 143 144 /// Gets the parent directory of this entry. 145 property FatDirectory^ Parent 146 { 147 FatDirectory^ get() { return parent; } 148 private: 149 void set(FatDirectory^ value) { parent = value; } 150 } 151 152 /// Gets the type of this entry. 153 property FatDirectoryEntryTypes Type 154 { 155 FatDirectoryEntryTypes get() { return type; } 156 private: 157 void set(FatDirectoryEntryTypes value) { type = value; } 158 } 159 160 /// Gets the first cluster of this entry. 161 property unsigned Cluster 162 { 163 unsigned get() { return cluster; } 164 private: 165 void set(unsigned value) { cluster = value; } 166 } 167 168 internal: 130 169 /// Constructor. 131 170 /// 132 171 /// \param[in] name The name of the entry. 172 /// \param[in] parent The parent directory containing this file. 133 173 /// \param[in] type The type of this entry. 134 174 /// \param[in] cluster The first cluster of the file. 135 FatDirectoryEntry(String^ name, FatDirectoryEntryTypes type, unsigned cluster); 136 137 /// Gets the name of the file or directory. 138 property String^ Name 139 { 140 String^ get() { return name; } 141 private: 142 void set(String^ value) { name = value; } 143 } 144 145 /// Gets the full path to the file or directory. 146 property String^ FullName 147 { 148 String^ get(); 149 } 150 151 /// Gets the parent directory of this entry. 152 property FatDirectory^ Parent 153 { 154 FatDirectory^ get() { return parent; } 155 private: 156 void set(FatDirectory^ value) { parent = value; } 157 } 158 159 /// Gets the type of this entry. 160 property FatDirectoryEntryTypes Type 161 { 162 FatDirectoryEntryTypes get() { return type; } 163 private: 164 void set(FatDirectoryEntryTypes value) { type = value; } 165 } 166 167 /// Gets the first cluster of this entry. 168 property unsigned Cluster 169 { 170 unsigned get() { return cluster; } 171 private: 172 void set(unsigned value) { cluster = value; } 173 } 175 FatDirectoryEntry(String^ name, FatDirectory^ parent, FatDirectoryEntryTypes type, 176 unsigned cluster); 174 177 175 178 private: … … 187 190 /// 188 191 /// \param[in] name The name of the current directory. 192 /// \param[in] parent The parent directory containing this directory. 189 193 /// \param[in] cluster The cluster at which the directory list starts. 190 194 /// \param[in] api The FAT API object which is creating this object. 191 FatDirectory(String^ name, unsigned cluster, FatApi^ api);195 FatDirectory(String^ name, FatDirectory^ parent, unsigned cluster, FatApi^ api); 192 196 193 197 /// Compacts the directory structure. … … 222 226 public: 223 227 virtual void LoadFat() override; 224 virtual FatDirectory^ LoadDirectory(unsigned cluster, String^ name ) override;228 virtual FatDirectory^ LoadDirectory(unsigned cluster, String^ name, FatDirectory^ parent) override; 225 229 226 230 internal: … … 235 239 { 236 240 public: 237 Directory(String^ name, unsigned cluster, Fat32Api^ api);241 Directory(String^ name, FatDirectory^ parent, unsigned cluster, Fat32Api^ api); 238 242 239 243 protected:
Note: See TracChangeset
for help on using the changeset viewer.
