vfs: add source location to exception
This commit is contained in:
+4
-4
@@ -194,13 +194,13 @@ bool vfs::unmount(std::string_view vpath)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir, std::string* out_path)
|
std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir, std::string* out_path, std::source_location src_loc)
|
||||||
{
|
{
|
||||||
// Just to make the code more robust.
|
// Just to make the code more robust.
|
||||||
// It should never happen because we take care to initialize Emu (and so also vfs_manager) with Emu.Init() before this function is invoked
|
// It should never happen because we take care to initialize Emu (and so also vfs_manager) with Emu.Init() before this function is invoked
|
||||||
if (!g_fxo->is_init<vfs_manager>())
|
if (!g_fxo->is_init<vfs_manager>())
|
||||||
{
|
{
|
||||||
fmt::throw_exception("vfs_manager not initialized");
|
fmt::throw_exception("vfs_manager not initialized.%s", src_loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& table = g_fxo->get<vfs_manager>();
|
auto& table = g_fxo->get<vfs_manager>();
|
||||||
@@ -377,13 +377,13 @@ std::string vfs::get(std::string_view vpath, std::vector<std::string>* out_dir,
|
|||||||
|
|
||||||
using char2 = char8_t;
|
using char2 = char8_t;
|
||||||
|
|
||||||
std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std::vector<std::string_view>* mount_path)
|
std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std::vector<std::string_view>* mount_path, std::source_location src_loc)
|
||||||
{
|
{
|
||||||
// Just to make the code more robust.
|
// Just to make the code more robust.
|
||||||
// It should never happen because we take care to initialize Emu (and so also vfs_manager) with Emu.Init() before this function is invoked
|
// It should never happen because we take care to initialize Emu (and so also vfs_manager) with Emu.Init() before this function is invoked
|
||||||
if (!g_fxo->is_init<vfs_manager>())
|
if (!g_fxo->is_init<vfs_manager>())
|
||||||
{
|
{
|
||||||
fmt::throw_exception("vfs_manager not initialized");
|
fmt::throw_exception("vfs_manager not initialized.%s", src_loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& table = g_fxo->get<vfs_manager>();
|
auto& table = g_fxo->get<vfs_manager>();
|
||||||
|
|||||||
+2
-2
@@ -16,10 +16,10 @@ namespace vfs
|
|||||||
bool unmount(std::string_view vpath);
|
bool unmount(std::string_view vpath);
|
||||||
|
|
||||||
// Convert VFS path to fs path, optionally listing directories mounted in it
|
// Convert VFS path to fs path, optionally listing directories mounted in it
|
||||||
std::string get(std::string_view vpath, std::vector<std::string>* out_dir = nullptr, std::string* out_path = nullptr);
|
std::string get(std::string_view vpath, std::vector<std::string>* out_dir = nullptr, std::string* out_path = nullptr, std::source_location src_loc = std::source_location::current());
|
||||||
|
|
||||||
// Convert fs path to VFS path
|
// Convert fs path to VFS path
|
||||||
std::string retrieve(std::string_view path, const vfs_directory* node = nullptr, std::vector<std::string_view>* mount_path = nullptr);
|
std::string retrieve(std::string_view path, const vfs_directory* node = nullptr, std::vector<std::string_view>* mount_path = nullptr, std::source_location src_loc = std::source_location::current());
|
||||||
|
|
||||||
// Escape VFS name by replacing non-portable characters with surrogates
|
// Escape VFS name by replacing non-portable characters with surrogates
|
||||||
std::string escape(std::string_view name, bool escape_slash = false);
|
std::string escape(std::string_view name, bool escape_slash = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user