s32 vfsHDD::OpenDir(const std::string& name) { LOG_WARNING(HLE, "OpenDir(%s)", name.c_str()); u64 entry_block; if (!SearchEntry(name, entry_block)) { return -1; } CHECK_ASSERTION(m_hdd_file.Seek(entry_block * m_hdd_info.block_size) != -1); vfsHDD_Entry entry; m_hdd_file.Read(&entry, sizeof(vfsHDD_Entry)); if (entry.type == vfsHDD_Entry_File) { return 1; } m_cur_dir_block = entry.data_block; ReadEntry(m_cur_dir_block, m_cur_dir); return 0; }
bool vfsHDD::RemoveEntry(const std::string& name) { u64 entry_block, parent_entry; if (!SearchEntry(name, entry_block, &parent_entry)) { return false; } vfsHDD_Entry entry; ReadEntry(entry_block, entry); if (entry.type == vfsHDD_Entry_Dir) { RemoveBlocksDir(entry.data_block); } else if (entry.type == vfsHDD_Entry_File) { RemoveBlocksFile(entry.data_block); } if (parent_entry) { u64 next = entry.next_block; ReadEntry(parent_entry, entry); entry.next_block = next; WriteEntry(parent_entry, entry); } WriteBlock(entry_block, g_null_block); return true; }
std::string PSFLoader::GetString(const std::string& key) { if(PSFEntry* entry = SearchEntry(key)) return entry->FormatString(); else return ""; }
u32 PSFLoader::GetInteger(const std::string& key) { if(PSFEntry* entry = SearchEntry(key)) return entry->FormatInteger(); else return 0; }
bool vfsHDD::Open(const std::string& path, u32 mode) { const char* s = path.c_str(); u64 from = 0; u64 pos = 0; u64 file_pos = -1; do { if (s[pos] == '\\' || s[pos] == '/' || s[pos] == '\0') // ??? { if (file_pos != -1) { return false; } if (from != -1) { if (pos - from > 1) { s32 res = OpenDir(std::string(s + from, pos)); if (res == -1) { return false; } else if (res == 1) { file_pos = from; } } from = pos; } else { from = pos; } } } while (s[pos++] != '\0'); if (file_pos == -1) { return false; } u64 file_block; if (!SearchEntry(std::string(s + file_pos), file_block)) { return false; } LOG_NOTICE(HLE, "ENTRY FOUND AT 0x%llx", file_block); m_file.Open(file_block); return vfsFileBase::Open(path, mode); }
bool vfsHDD::HasEntry(const std::string& name) { u64 file_block; if (!SearchEntry(name, file_block)) { return false; } return true; }
bool vfsHDD::Rename(const std::string& from, const std::string& to) { u64 entry_block; if (!SearchEntry(from, entry_block)) { return false; } vfsHDD_Entry entry; ReadEntry(entry_block, entry); WriteEntry(entry_block, entry, to); return true; }