aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/io_win32.cc
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-11-30 17:32:11 +0100
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2017-12-07 15:31:49 +0100
commit57a01c7fbe89ca540e32a02c1f46b9e0478b3a8f (patch)
tree9c1dd50f36d47e03f17188b49e8ab38debac07cc /src/google/protobuf/stubs/io_win32.cc
parent65da9fd97f67a9499771b6294cf017248ece5661 (diff)
io_win32: add more encoding-related tests
Diffstat (limited to 'src/google/protobuf/stubs/io_win32.cc')
-rw-r--r--src/google/protobuf/stubs/io_win32.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/google/protobuf/stubs/io_win32.cc b/src/google/protobuf/stubs/io_win32.cc
index b5af494a..ad2d2d26 100644
--- a/src/google/protobuf/stubs/io_win32.cc
+++ b/src/google/protobuf/stubs/io_win32.cc
@@ -210,16 +210,20 @@ bool as_windows_path(const char* path, wstring* result) {
result->clear();
return true;
}
- if (is_separator(path[0]) || is_drive_relative(path)) {
- return false;
- }
-
wstring wpath;
if (!strings::utf8_to_wcs(path, &wpath)) {
return false;
}
+ if (has_longpath_prefix(wpath.c_str())) {
+ *result = wpath;
+ return true;
+ }
+ if (is_separator(path[0]) || is_drive_relative(path)) {
+ return false;
+ }
- if (!is_path_absolute(wpath.c_str()) && !has_longpath_prefix(wpath.c_str())) {
+
+ if (!is_path_absolute(wpath.c_str())) {
int size = ::GetCurrentDirectoryW(0, NULL);
if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return false;
@@ -396,6 +400,10 @@ bool utf8_to_wcs(const char* input, wstring* out) {
return mbs_to_wcs(input, out, true);
}
+bool wcs_to_utf8(const wchar_t* input, string* out) {
+ return wcs_to_mbs(input, out, true);
+}
+
} // namespace strings
} // namespace win32
} // namespace internal