-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Windows] Fix FileManager.removeItem #2203
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
Conversation
gmittert
commented
May 1, 2019
- Get the fsr of the passed in path before using it
- Add the correct path to the directory stack
@swift-ci please test |
Foundation/FileManager+Win32.swift
Outdated
@@ -405,30 +405,37 @@ extension FileManager { | |||
guard alreadyConfirmed || shouldRemoveItemAtPath(path, isURL: isURL) else { | |||
return | |||
} | |||
let faAttributes = try windowsFileAttributes(atPath: path) | |||
let url = URL(fileURLWithPath: path) | |||
var fsrBuf: UnsafeMutableBufferPointer<WCHAR> = UnsafeMutableBufferPointer.allocate(capacity: path.length * 2) |
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.
Let's use an array instead
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.
Sounds good! Done.
@swift-ci please test |
1 similar comment
@swift-ci please test |
Foundation/FileManager+Win32.swift
Outdated
let url = URL(fileURLWithPath: path) | ||
var fsrBuf: [WCHAR] = Array<WCHAR>(repeating: 0, count: Int(MAX_PATH)) | ||
_CFURLGetWideFileSystemRepresentation(url._cfObject, false, &fsrBuf, Int(MAX_PATH)) | ||
let length = fsrBuf.firstIndex(where: {$0 == 0}) ?? (path.length * 2) |
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.
This is probably better written as:
let length = wcslen_s(&path, fsrBuf.count)
- Get the fsr of the passed in path before using it - Add the correct path to the directory stack
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
@swift-ci please test linux platform |
@swift-ci please test and merge |