Prevent accessing incomplete RPCS3.log.gz

Use permissions to make it inaccessible
On Windows, autodelete the file

Implement fs::unread for this purpose
Rename fs::unshare to fs::lock
Fix fs::lock correctness
This commit is contained in:
Nekotekina 2018-03-17 00:34:16 +03:00
parent b232409cc5
commit f66d5adf5f
3 changed files with 49 additions and 14 deletions

View file

@ -25,7 +25,8 @@ namespace fs
create,
trunc,
excl,
unshare,
lock,
unread,
__bitset_enum_max
};
@ -36,7 +37,8 @@ namespace fs
constexpr auto create = +open_mode::create; // Create file if it doesn't exist
constexpr auto trunc = +open_mode::trunc; // Clear opened file if it's not empty
constexpr auto excl = +open_mode::excl; // Failure if the file already exists (used with `create`)
constexpr auto unshare = +open_mode::unshare; // Prevent opening the file twice
constexpr auto lock = +open_mode::lock; // Prevent opening the file more than once
constexpr auto unread = +open_mode::unread; // Aggressively prevent reading the opened file (do not use)
constexpr auto rewrite = open_mode::write + open_mode::create + open_mode::trunc;
@ -185,7 +187,7 @@ namespace fs
file() = default;
// Open file with specified mode
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
// Open memory for read
explicit file(const void* ptr, std::size_t size);
@ -400,7 +402,7 @@ namespace fs
{
m_dir = std::move(ptr);
}
std::unique_ptr<dir_base> release()
{
return std::move(m_dir);