@@ -49,9 +49,10 @@ namespace Sass {
49
49
50
50
// return the current directory
51
51
// always with forward slashes
52
+ // always with trailing slash
52
53
std::string get_cwd ()
53
54
{
54
- const size_t wd_len = 1024 ;
55
+ const size_t wd_len = 4096 ;
55
56
#ifndef _WIN32
56
57
char wd[wd_len];
57
58
std::string cwd = getcwd (wd, wd_len);
@@ -69,7 +70,10 @@ namespace Sass {
69
70
bool file_exists (const std::string& path)
70
71
{
71
72
#ifdef _WIN32
72
- std::wstring wpath = UTF_8::convert_to_utf16 (path);
73
+ // windows unicode filepaths are encoded in utf16
74
+ std::string abspath (join_paths (get_cwd (), path));
75
+ std::wstring wpath (UTF_8::convert_to_utf16 (" \\\\ ?\\ " + abspath));
76
+ std::replace (wpath.begin (), wpath.end (), ' /' , ' \\ ' );
73
77
DWORD dwAttrib = GetFileAttributesW (wpath.c_str ());
74
78
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
75
79
(!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)));
@@ -388,7 +392,9 @@ namespace Sass {
388
392
BYTE* pBuffer;
389
393
DWORD dwBytes;
390
394
// windows unicode filepaths are encoded in utf16
391
- std::wstring wpath = UTF_8::convert_to_utf16 (path);
395
+ std::string abspath (join_paths (get_cwd (), path));
396
+ std::wstring wpath (UTF_8::convert_to_utf16 (" \\\\ ?\\ " + abspath));
397
+ std::replace (wpath.begin (), wpath.end (), ' /' , ' \\ ' );
392
398
HANDLE hFile = CreateFileW (wpath.c_str (), GENERIC_READ, FILE_SHARE_READ, NULL , OPEN_EXISTING, 0 , NULL );
393
399
if (hFile == INVALID_HANDLE_VALUE) return 0 ;
394
400
DWORD dwFileLength = GetFileSize (hFile, NULL );
0 commit comments