aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/path.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/path.cpp')
-rw-r--r--src/path.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/path.cpp b/src/path.cpp
index 409fc44..5c78fe9 100644
--- a/src/path.cpp
+++ b/src/path.cpp
@@ -18,7 +18,7 @@
namespace winapi {
namespace {
-std::wstring do_canonicalize(const std::wstring& path) {
+std::wstring do_canonicalize(std::wstring_view path) {
static constexpr std::size_t init_buffer_size = MAX_PATH;
static_assert(init_buffer_size > 0, "init_buffer_size must be positive");
@@ -28,8 +28,8 @@ std::wstring do_canonicalize(const std::wstring& path) {
while (true) {
if (buffer.size() > std::numeric_limits<DWORD>::max())
throw std::range_error{"Path buffer is too large"};
- const auto nch = ::GetFullPathNameW(
- path.c_str(), static_cast<DWORD>(buffer.size()), buffer.data(), NULL);
+ const auto nch =
+ ::GetFullPathNameW(path.data(), static_cast<DWORD>(buffer.size()), buffer.data(), NULL);
if (nch == 0) {
throw error::windows(GetLastError(), "GetFullPathNameW");
@@ -47,9 +47,9 @@ std::wstring do_canonicalize(const std::wstring& path) {
} // namespace
-CanonicalPath::CanonicalPath(const std::string& path) : m_path(canonicalize(path)) {}
+CanonicalPath::CanonicalPath(std::string_view path) : m_path{canonicalize(path)} {}
-std::string CanonicalPath::canonicalize(const std::string& path) {
+std::string CanonicalPath::canonicalize(std::string_view path) {
return narrow(do_canonicalize(widen(path)));
}