Skip to content

Commit

Permalink
Enable to read remote UNC locations on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Nov 29, 2018
1 parent c450582 commit cda81f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ namespace Sass {
wchar_t resolved[32768];
// windows unicode filepaths are encoded in utf16
std::string abspath(join_paths(get_cwd(), path));
std::wstring wpath(UTF_8::convert_to_utf16("\\\\?\\" + abspath));
if (!(abspath[0] == '/' && abspath[1] == '/')) {
abspath = "//?/" + abspath;
}
std::wstring wpath(UTF_8::convert_to_utf16(abspath));
std::replace(wpath.begin(), wpath.end(), '/', '\\');
DWORD rv = GetFullPathNameW(wpath.c_str(), 32767, resolved, NULL);
if (rv > 32767) throw Exception::OperationError("Path is too long");
Expand Down Expand Up @@ -434,7 +437,10 @@ namespace Sass {
wchar_t resolved[32768];
// windows unicode filepaths are encoded in utf16
std::string abspath(join_paths(get_cwd(), path));
std::wstring wpath(UTF_8::convert_to_utf16("\\\\?\\" + abspath));
if (!(abspath[0] == '/' && abspath[1] == '/')) {
abspath = "//?/" + abspath;
}
std::wstring wpath(UTF_8::convert_to_utf16(abspath));
std::replace(wpath.begin(), wpath.end(), '/', '\\');
DWORD rv = GetFullPathNameW(wpath.c_str(), 32767, resolved, NULL);
if (rv > 32767) throw Exception::OperationError("Path is too long");
Expand Down

0 comments on commit cda81f6

Please sign in to comment.