Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Sources/Foundation/FileManager+Win32.swift
Original file line number Diff line number Diff line change
@@ -269,20 +269,20 @@ extension FileManager {
}
}

try FileManager.default._fileSystemRepresentation(withPath: path) { fsr in
var saAttributes: SECURITY_ATTRIBUTES =
SECURITY_ATTRIBUTES(nLength: DWORD(MemoryLayout<SECURITY_ATTRIBUTES>.size),
lpSecurityDescriptor: nil,
bInheritHandle: false)
try withUnsafeMutablePointer(to: &saAttributes) {
if !CreateDirectoryW(fsr, $0) {
throw _NSErrorWithWindowsError(GetLastError(), reading: false, paths: [path])
try withNTPathRepresentation(of: path) { wszPath in
var saAttributes: SECURITY_ATTRIBUTES =
SECURITY_ATTRIBUTES(nLength: DWORD(MemoryLayout<SECURITY_ATTRIBUTES>.size),
lpSecurityDescriptor: nil,
bInheritHandle: false)
try withUnsafeMutablePointer(to: &saAttributes) { pSecurityAttributes in
guard CreateDirectoryW(wszPath, pSecurityAttributes) else {
throw _NSErrorWithWindowsError(GetLastError(), reading: false, paths: [path])
}
}
}
}

if let attr = attributes {
try self.setAttributes(attr, ofItemAtPath: path)
}
if let attributes {
try self.setAttributes(attributes, ofItemAtPath: path)
}
}