aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-10-16 23:45:36 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-10-16 23:45:36 +0300
commit73c5cc279f6252afcefd30b40d67b7bbb5b540de (patch)
tree4c03402c126ab54955e6bffcc3462105e2661db6
parentCommandLine: saner API (diff)
downloadwinapi-common-73c5cc279f6252afcefd30b40d67b7bbb5b540de.tar.gz
winapi-common-73c5cc279f6252afcefd30b40d67b7bbb5b540de.zip
File: refactoring
-rw-r--r--include/winapi/file.hpp8
-rw-r--r--src/file.cpp8
-rw-r--r--src/stream.cpp12
-rw-r--r--test/unit_tests/process.cpp2
4 files changed, 15 insertions, 15 deletions
diff --git a/include/winapi/file.hpp b/include/winapi/file.hpp
index 221047b..fd34783 100644
--- a/include/winapi/file.hpp
+++ b/include/winapi/file.hpp
@@ -17,10 +17,10 @@ class File : private Handle {
public:
explicit File(Handle&& handle) : Handle{std::move(handle)} {}
- static Handle open_for_reading(const std::string&);
- static Handle open_for_reading(const CanonicalPath&);
- static Handle open_for_writing(const std::string&);
- static Handle open_for_writing(const CanonicalPath&);
+ static Handle open_r(const std::string&);
+ static Handle open_r(const CanonicalPath&);
+ static Handle open_w(const std::string&);
+ static Handle open_w(const CanonicalPath&);
using Handle::close;
diff --git a/src/file.cpp b/src/file.cpp
index a299d70..c6a4ff4 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -71,19 +71,19 @@ Handle open_file(const std::wstring& path, const CreateFileParams& params) {
} // namespace
-Handle File::open_for_reading(const std::string& path) {
+Handle File::open_r(const std::string& path) {
return open_file(to_system_path(path), CreateFileParams::read());
}
-Handle File::open_for_reading(const CanonicalPath& path) {
+Handle File::open_r(const CanonicalPath& path) {
return open_file(to_system_path(path), CreateFileParams::read());
}
-Handle File::open_for_writing(const std::string& path) {
+Handle File::open_w(const std::string& path) {
return open_file(to_system_path(path), CreateFileParams::write());
}
-Handle File::open_for_writing(const CanonicalPath& path) {
+Handle File::open_w(const CanonicalPath& path) {
return open_file(to_system_path(path), CreateFileParams::write());
}
diff --git a/src/stream.cpp b/src/stream.cpp
index f9285e6..76dd5a5 100644
--- a/src/stream.cpp
+++ b/src/stream.cpp
@@ -20,17 +20,17 @@ Stdout::Stdout() : Stream{Handle::std_out()} {}
Stderr::Stderr() : Stream{Handle::std_err()} {}
-Stdin::Stdin(const std::string& path) : Stream{File::open_for_reading(path)} {}
+Stdin::Stdin(const std::string& path) : Stream{File::open_r(path)} {}
-Stdin::Stdin(const CanonicalPath& path) : Stream{File::open_for_reading(path)} {}
+Stdin::Stdin(const CanonicalPath& path) : Stream{File::open_r(path)} {}
-Stdout::Stdout(const std::string& path) : Stream{File::open_for_writing(path)} {}
+Stdout::Stdout(const std::string& path) : Stream{File::open_w(path)} {}
-Stdout::Stdout(const CanonicalPath& path) : Stream{File::open_for_writing(path)} {}
+Stdout::Stdout(const CanonicalPath& path) : Stream{File::open_w(path)} {}
-Stderr::Stderr(const std::string& path) : Stream{File::open_for_writing(path)} {}
+Stderr::Stderr(const std::string& path) : Stream{File::open_w(path)} {}
-Stderr::Stderr(const CanonicalPath& path) : Stream{File::open_for_writing(path)} {}
+Stderr::Stderr(const CanonicalPath& path) : Stream{File::open_w(path)} {}
Stdin::Stdin(Pipe& pipe) : Stream{std::move(pipe.read_end())} {
pipe.write_end().dont_inherit();
diff --git a/test/unit_tests/process.cpp b/test/unit_tests/process.cpp
index aa09bf4..957a507 100644
--- a/test/unit_tests/process.cpp
+++ b/test/unit_tests/process.cpp
@@ -85,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE(echo_stdout_to_file, WithEchoExe) {
const auto process = Process::create(cmd_line, std::move(io));
process.wait();
BOOST_TEST(process.get_exit_code() == 0);
- const auto output = File::open_for_reading(CanonicalPath{"test.txt"}).read();
+ const auto output = File::open_r(CanonicalPath{"test.txt"}).read();
const auto utf8 = narrow(output);
BOOST_TEST(utf8 == "XXX\r\nYYY\r\nZZZ\r\n");
}