2016-04-14 00:59:00 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2018-09-11 18:02:19 +02:00
|
|
|
#include <vector>
|
2017-08-15 14:03:07 +02:00
|
|
|
#include <string>
|
2018-09-11 18:02:19 +02:00
|
|
|
#include <string_view>
|
2017-08-15 14:03:07 +02:00
|
|
|
|
2020-09-11 13:06:46 +02:00
|
|
|
struct lv2_fs_mount_point;
|
|
|
|
|
|
2016-04-14 00:59:00 +02:00
|
|
|
namespace vfs
|
|
|
|
|
{
|
2016-06-02 17:16:01 +02:00
|
|
|
// Mount VFS device
|
2018-09-11 18:02:19 +02:00
|
|
|
bool mount(std::string_view vpath, std::string_view path);
|
2016-06-02 17:16:01 +02:00
|
|
|
|
2018-09-11 18:02:19 +02:00
|
|
|
// Convert VFS path to fs path, optionally listing directories mounted in it
|
2020-01-04 18:10:37 +01:00
|
|
|
std::string get(std::string_view vpath, std::vector<std::string>* out_dir = nullptr, std::string* out_path = nullptr);
|
2017-10-11 02:19:32 +02:00
|
|
|
|
2020-03-14 14:01:55 +01:00
|
|
|
// Escape VFS name by replacing non-portable characters with surrogates
|
|
|
|
|
std::string escape(std::string_view name, bool escape_slash = false);
|
2017-10-11 02:19:32 +02:00
|
|
|
|
|
|
|
|
// Invert escape operation
|
2020-03-14 14:01:55 +01:00
|
|
|
std::string unescape(std::string_view name);
|
2019-04-07 11:58:08 +02:00
|
|
|
|
|
|
|
|
// Functions in this namespace operate on host filepaths, similar to fs::
|
|
|
|
|
namespace host
|
|
|
|
|
{
|
2020-10-01 21:00:57 +02:00
|
|
|
// For internal use (don't use)
|
2020-09-20 08:27:08 +02:00
|
|
|
std::string hash_path(const std::string& path, const std::string& dev_root);
|
|
|
|
|
|
2019-04-07 11:58:08 +02:00
|
|
|
// Call fs::rename with retry on access error
|
2020-09-11 13:06:46 +02:00
|
|
|
bool rename(const std::string& from, const std::string& to, const lv2_fs_mount_point* mp, bool overwrite);
|
2019-04-07 23:53:56 +02:00
|
|
|
|
|
|
|
|
// Delete file without deleting its contents, emulated with MoveFileEx on Windows
|
2019-09-25 03:57:56 +02:00
|
|
|
bool unlink(const std::string& path, const std::string& dev_root);
|
2019-09-14 17:34:02 +02:00
|
|
|
|
|
|
|
|
// Delete folder contents using rename, done atomically if remove_root is true
|
2020-09-11 13:06:46 +02:00
|
|
|
bool remove_all(const std::string& path, const std::string& dev_root, const lv2_fs_mount_point* mp, bool remove_root = true);
|
2019-04-07 11:58:08 +02:00
|
|
|
}
|
2016-04-14 00:59:00 +02:00
|
|
|
}
|