From 1f7066186a040243fc3b4132f7b19af5d894bc5a Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 16 May 2021 01:14:29 +0300 Subject: File: make public child of Handle --- src/file.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 2b04f80..4f1d2a9 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -58,7 +58,7 @@ private: CreateFileParams() = default; }; -Handle open_file(const std::wstring& path, const CreateFileParams& params) { +File open_file(const std::wstring& path, const CreateFileParams& params) { SECURITY_ATTRIBUTES attributes; std::memset(&attributes, 0, sizeof(attributes)); attributes.nLength = sizeof(attributes); @@ -76,7 +76,7 @@ Handle open_file(const std::wstring& path, const CreateFileParams& params) { throw error::windows(GetLastError(), "CreateFileW"); } - return Handle{handle}; + return File{Handle{handle}}; } void remove_file(const std::wstring& path) { @@ -89,22 +89,38 @@ void remove_file(const std::wstring& path) { } // namespace -Handle File::open_r(const std::string& path) { +File File::open_r(const std::string& path) { return open_file(to_system_path(path), CreateFileParams::read()); } -Handle File::open_r(const CanonicalPath& path) { +File File::open_r(const CanonicalPath& path) { return open_file(to_system_path(path), CreateFileParams::read()); } -Handle File::open_read_attributes(const std::string& path) { +File File::open_read_attributes(const std::string& path) { return open_file(to_system_path(path), CreateFileParams::read_attributes()); } -Handle File::open_read_attributes(const CanonicalPath& path) { +File File::open_read_attributes(const CanonicalPath& path) { return open_file(to_system_path(path), CreateFileParams::read_attributes()); } +File File::open_w(const std::string& path) { + return open_file(to_system_path(path), CreateFileParams::write()); +} + +File File::open_w(const CanonicalPath& path) { + return open_file(to_system_path(path), CreateFileParams::write()); +} + +void File::remove(const std::string& path) { + remove_file(to_system_path(path)); +} + +void File::remove(const CanonicalPath& path) { + remove_file(to_system_path(path)); +} + std::size_t File::get_size() const { LARGE_INTEGER size; @@ -129,20 +145,4 @@ File::ID File::query_id() const { return {id}; } -Handle File::open_w(const std::string& path) { - return open_file(to_system_path(path), CreateFileParams::write()); -} - -Handle File::open_w(const CanonicalPath& path) { - return open_file(to_system_path(path), CreateFileParams::write()); -} - -void File::remove(const std::string& path) { - remove_file(to_system_path(path)); -} - -void File::remove(const CanonicalPath& path) { - remove_file(to_system_path(path)); -} - } // namespace winapi -- cgit v1.2.3