-
Notifications
You must be signed in to change notification settings - Fork 217
use Win32 file APIs and widePath for file ops to support long filenames #1004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this!
} | ||
if (RemoveDirectoryW(wpath.data())) { | ||
return 0; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary } else {
. Just use }
and the rest of the body can follow.
2a26b43
to
e0c6ead
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor nits, but looks good to me.
lib/Basic/PlatformUtility.cpp
Outdated
llvm::SmallVector<wchar_t, MAX_PATH> wPath; | ||
if (llvm::sys::path::widenPath(path, wPath)) | ||
return std::string(); | ||
CreateDirectoryW(wPath.data(), NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to log the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a lot of logging... Are you thinking just a fprintf maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah ... at least we would have something to go on if it ever failed.
e0c6ead
to
3ff8d69
Compare
@swift-ci test |
3ff8d69
to
c9736f5
Compare
@swift-ci test |
c9736f5
to
bb4eef8
Compare
@swift-ci test |
@swift-ci please smoke test |
llvm::SmallVector<llvm::UTF16, 20> wFileName; | ||
llvm::convertUTF8ToUTF16String(fileName, wFileName); | ||
return SetCurrentDirectoryW((LPCWSTR)wFileName.data()); | ||
llvm::SmallVector<wchar_t, MAX_PATH> wFileName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is MAX_PATH? Note that the true max path (with the \\?\
prefix) is 32767, not 260.
Or is that just an initial allocation size, and it grows dynamically as needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is just the initial size
#else | ||
return ::rmdir(path); | ||
#endif | ||
} | ||
|
||
int sys::stat(const char *fileName, StatStruct *buf) { | ||
#if defined(_WIN32) | ||
return ::_stat(fileName, buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@compnerd Would it be simpler to use _wstat, _wrmdir, etc., vs the Win32 functions? They support long paths too, as they are just wrappers around Win32 anyways.
No description provided.