aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/file.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-16 01:14:29 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-16 01:14:29 +0300
commit1f7066186a040243fc3b4132f7b19af5d894bc5a (patch)
tree42470f6aebe62cec049c3d2c8a2248f27b4ffed2 /src/file.cpp
parentFile: add get_size/query_id (diff)
downloadwinapi-common-1f7066186a040243fc3b4132f7b19af5d894bc5a.tar.gz
winapi-common-1f7066186a040243fc3b4132f7b19af5d894bc5a.zip
File: make public child of Handle
Diffstat (limited to '')
-rw-r--r--src/file.cpp44
1 files changed, 22 insertions, 22 deletions
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