Changeset View
Changeset View
Standalone View
Standalone View
source/lib/file/vfs/vfs.cpp
Show All 26 Lines | |||||
#include "lib/file/file_system.h" | #include "lib/file/file_system.h" | ||||
#include "lib/file/common/file_stats.h" | #include "lib/file/common/file_stats.h" | ||||
#include "lib/file/common/trace.h" | #include "lib/file/common/trace.h" | ||||
#include "lib/file/archive/archive.h" | #include "lib/file/archive/archive.h" | ||||
#include "lib/file/io/io.h" | #include "lib/file/io/io.h" | ||||
#include "lib/file/vfs/vfs_tree.h" | #include "lib/file/vfs/vfs_tree.h" | ||||
#include "lib/file/vfs/vfs_lookup.h" | #include "lib/file/vfs/vfs_lookup.h" | ||||
#include "lib/file/vfs/vfs_populate.h" | #include "lib/file/vfs/vfs_populate.h" | ||||
#include "ps/Util.h" | |||||
#include <mutex> | #include <mutex> | ||||
#include <thread> | #include <thread> | ||||
static const StatusDefinition vfsStatusDefinitions[] = { | static const StatusDefinition vfsStatusDefinitions[] = { | ||||
{ ERR::VFS_DIR_NOT_FOUND, L"VFS directory not found" }, | { ERR::VFS_DIR_NOT_FOUND, L"VFS directory not found" }, | ||||
{ ERR::VFS_FILE_NOT_FOUND, L"VFS file not found" }, | { ERR::VFS_FILE_NOT_FOUND, L"VFS file not found" }, | ||||
{ ERR::VFS_ALREADY_MOUNTED, L"VFS path already mounted" } | { ERR::VFS_ALREADY_MOUNTED, L"VFS path already mounted" } | ||||
▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | public: | ||||
{ | { | ||||
std::lock_guard<std::mutex> lock(vfs_mutex); | std::lock_guard<std::mutex> lock(vfs_mutex); | ||||
std::wstring textRepresentation; | std::wstring textRepresentation; | ||||
textRepresentation.reserve(100*KiB); | textRepresentation.reserve(100*KiB); | ||||
DirectoryDescriptionR(textRepresentation, m_rootDirectory, 0); | DirectoryDescriptionR(textRepresentation, m_rootDirectory, 0); | ||||
return textRepresentation; | return textRepresentation; | ||||
} | } | ||||
virtual std::string HashRepresentation(const std::vector<std::string>& paths) const | |||||
{ | |||||
std::lock_guard<std::mutex> lock(vfs_mutex); | |||||
unsigned long crc; | |||||
for (const std::string& path : paths) | |||||
{ | |||||
VfsDirectory* directory; | |||||
WARN_IF_ERR(vfs_Lookup(path, &m_rootDirectory, directory, NULL)); | |||||
RecursiveHash(crc, *directory); | |||||
} | |||||
return Hexify(reinterpret_cast<u8*>(&crc), sizeof(decltype(crc))); | |||||
} | |||||
virtual Status GetRealPath(const VfsPath& pathname, OsPath& realPathname) | virtual Status GetRealPath(const VfsPath& pathname, OsPath& realPathname) | ||||
{ | { | ||||
std::lock_guard<std::mutex> lock(vfs_mutex); | std::lock_guard<std::mutex> lock(vfs_mutex); | ||||
VfsDirectory* directory; VfsFile* file; | VfsDirectory* directory; VfsFile* file; | ||||
WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, &file)); | WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, &file)); | ||||
realPathname = file->Loader()->Path() / pathname.Filename(); | realPathname = file->Loader()->Path() / pathname.Filename(); | ||||
return INFO::OK; | return INFO::OK; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator