mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Split functionality from AddDirectoryEntries into ScanDirectoryTree (generic directory scanning; OS depedent) and ComputeNameSize (specific for CVolumeDirectory; OS independent).
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@646 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1a27044b0a
commit
5a3aee5118
@ -455,7 +455,7 @@ static bool ReadFoundFile(const WIN32_FIND_DATA& ffd, CVolumeDirectory::FSTEntry
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry)
|
static u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
|
||||||
{
|
{
|
||||||
// Find the first file in the directory.
|
// Find the first file in the directory.
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
@ -483,7 +483,6 @@ u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntr
|
|||||||
++foundEntries;
|
++foundEntries;
|
||||||
|
|
||||||
parentEntry.children.push_back(entry);
|
parentEntry.children.push_back(entry);
|
||||||
m_totalNameSize += entry.virtualName.length() + 1;
|
|
||||||
}
|
}
|
||||||
} while (FindNextFile(hFind, &ffd) != 0);
|
} while (FindNextFile(hFind, &ffd) != 0);
|
||||||
}
|
}
|
||||||
@ -493,11 +492,35 @@ u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntr
|
|||||||
return foundEntries;
|
return foundEntries;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry)
|
static u32 ScanDirectoryTree(const std::string& _Directory, FSTEntry& parentEntry)
|
||||||
{
|
{
|
||||||
// TODO - Insert linux stuff here
|
// TODO - Insert linux stuff here
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static u32 ComputeNameSize(const FSTEntry& parentEntry)
|
||||||
|
{
|
||||||
|
u32 nameSize = 0;
|
||||||
|
const std::vector<FSTEntry>& children = parentEntry.children;
|
||||||
|
for (std::vector<FSTEntry>::const_iterator it = children.begin();
|
||||||
|
it != children.end(); ++it)
|
||||||
|
{
|
||||||
|
const FSTEntry& entry = *it;
|
||||||
|
if (entry.isDirectory)
|
||||||
|
{
|
||||||
|
nameSize += ComputeNameSize(entry);
|
||||||
|
}
|
||||||
|
nameSize += entry.virtualName.length() + 1;
|
||||||
|
}
|
||||||
|
return nameSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 CVolumeDirectory::AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry)
|
||||||
|
{
|
||||||
|
u32 foundEntries = ScanDirectoryTree(_Directory, parentEntry);
|
||||||
|
m_totalNameSize += ComputeNameSize(parentEntry);
|
||||||
|
return foundEntries;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -30,6 +30,15 @@
|
|||||||
namespace DiscIO
|
namespace DiscIO
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct FSTEntry
|
||||||
|
{
|
||||||
|
bool isDirectory;
|
||||||
|
u32 size; // file length or number of entries from children
|
||||||
|
std::string physicalName; // name on disk
|
||||||
|
std::string virtualName; // name in FST names table
|
||||||
|
std::vector<FSTEntry> children;
|
||||||
|
};
|
||||||
|
|
||||||
class CVolumeDirectory
|
class CVolumeDirectory
|
||||||
: public IVolume
|
: public IVolume
|
||||||
{
|
{
|
||||||
@ -55,15 +64,6 @@ class CVolumeDirectory
|
|||||||
|
|
||||||
void BuildFST();
|
void BuildFST();
|
||||||
|
|
||||||
struct FSTEntry
|
|
||||||
{
|
|
||||||
bool isDirectory;
|
|
||||||
u32 size; // file length or number of entries from children
|
|
||||||
std::string physicalName; // name on disk
|
|
||||||
std::string virtualName; // name in FST names table
|
|
||||||
std::vector<FSTEntry> children;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string ExtractDirectoryName(const std::string& _rDirectory);
|
static std::string ExtractDirectoryName(const std::string& _rDirectory);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class CVolumeDirectory
|
|||||||
void WriteEntry(const FSTEntry& entry, u32& fstOffset, u32& nameOffset, u64& dataOffset, u32 parentEntryNum);
|
void WriteEntry(const FSTEntry& entry, u32& fstOffset, u32& nameOffset, u64& dataOffset, u32 parentEntryNum);
|
||||||
|
|
||||||
// returns number of entries found in _Directory
|
// returns number of entries found in _Directory
|
||||||
u32 AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry);
|
u32 AddDirectoryEntries(const std::string& _Directory, FSTEntry& parentEntry);
|
||||||
|
|
||||||
std::string m_rootDirectory;
|
std::string m_rootDirectory;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user