|
|
|
@ -20,8 +20,8 @@ Directory_SDMC::Directory_SDMC(const Archive_SDMC* archive, const std::string& p
|
|
|
|
|
// the root directory we set while opening the archive.
|
|
|
|
|
// For example, opening /../../usr/bin can give the emulated program your installed programs.
|
|
|
|
|
std::string absolute_path = archive->GetMountPoint() + path;
|
|
|
|
|
entry_count = FileUtil::ScanDirectoryTree(absolute_path, entry);
|
|
|
|
|
current_entry = 0;
|
|
|
|
|
FileUtil::ScanDirectoryTree(absolute_path, directory);
|
|
|
|
|
children_iterator = directory.children.begin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Directory_SDMC::~Directory_SDMC() {
|
|
|
|
@ -35,44 +35,39 @@ Directory_SDMC::~Directory_SDMC() {
|
|
|
|
|
* @return Number of entries listed
|
|
|
|
|
*/
|
|
|
|
|
u32 Directory_SDMC::Read(const u32 count, Entry* entries) {
|
|
|
|
|
u32 i;
|
|
|
|
|
for (i = 0; i < count && current_entry < entry_count; ++i) {
|
|
|
|
|
FileUtil::FSTEntry file = entry.children[current_entry];
|
|
|
|
|
std::string filename = file.virtualName;
|
|
|
|
|
WARN_LOG(FILESYS, "File %s: size=%d dir=%d", filename.c_str(), file.size, file.isDirectory);
|
|
|
|
|
u32 entries_read = 0;
|
|
|
|
|
|
|
|
|
|
Entry* entry = &entries[i];
|
|
|
|
|
while (entries_read < count && children_iterator != directory.children.cend()) {
|
|
|
|
|
const FileUtil::FSTEntry& file = *children_iterator;
|
|
|
|
|
const std::string& filename = file.virtualName;
|
|
|
|
|
Entry& entry = entries[entries_read];
|
|
|
|
|
|
|
|
|
|
WARN_LOG(FILESYS, "File %s: size=%d dir=%d", filename.c_str(), file.size, file.isDirectory);
|
|
|
|
|
|
|
|
|
|
// TODO(Link Mauve): use a proper conversion to UTF-16.
|
|
|
|
|
for (int j = 0; j < FILENAME_LENGTH; ++j) {
|
|
|
|
|
entry->filename[j] = filename[j];
|
|
|
|
|
entry.filename[j] = filename[j];
|
|
|
|
|
if (!filename[j])
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Split the filename into 8.3 format.
|
|
|
|
|
// TODO(Link Mauve): move that to common, I guess, and make it more robust to long filenames.
|
|
|
|
|
std::string::size_type n = filename.rfind('.');
|
|
|
|
|
if (n == std::string::npos) {
|
|
|
|
|
strncpy(entry->short_name, filename.c_str(), 8);
|
|
|
|
|
memset(entry->extension, '\0', 3);
|
|
|
|
|
} else {
|
|
|
|
|
strncpy(entry->short_name, filename.substr(0, n).c_str(), 8);
|
|
|
|
|
strncpy(entry->extension, filename.substr(n + 1).c_str(), 8);
|
|
|
|
|
}
|
|
|
|
|
FileUtil::SplitFilename83(filename, entry.short_name, entry.extension);
|
|
|
|
|
|
|
|
|
|
entry->is_directory = file.isDirectory;
|
|
|
|
|
entry->file_size = file.size;
|
|
|
|
|
entry.is_directory = file.isDirectory;
|
|
|
|
|
entry.is_hidden = (filename[0] == '.');
|
|
|
|
|
entry.is_read_only = 0;
|
|
|
|
|
entry.file_size = file.size;
|
|
|
|
|
|
|
|
|
|
// We emulate a SD card where the archive bit has never been cleared, as it would be on
|
|
|
|
|
// most user SD cards.
|
|
|
|
|
// Some homebrews (blargSNES for instance) are known to mistakenly use the archive bit as a
|
|
|
|
|
// file bit.
|
|
|
|
|
entry->is_archive = !file.isDirectory;
|
|
|
|
|
entry.is_archive = !file.isDirectory;
|
|
|
|
|
|
|
|
|
|
++current_entry;
|
|
|
|
|
++entries_read;
|
|
|
|
|
++children_iterator;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
return entries_read;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|