diff --git a/Sources/Foundation/FileManager+POSIX.swift b/Sources/Foundation/FileManager+POSIX.swift index b3d6317e01..cda41a8c17 100644 --- a/Sources/Foundation/FileManager+POSIX.swift +++ b/Sources/Foundation/FileManager+POSIX.swift @@ -650,7 +650,7 @@ extension FileManager { #if !os(WASI) // WASI doesn't have ownership concept // Set the file permissions using fchmod() instead of when open()ing to avoid umask() issues - let permissions = fileInfo.st_mode & ~S_IFMT + let permissions = fileInfo.st_mode & ~mode_t(S_IFMT) guard fchmod(dstfd, permissions) == 0 else { throw _NSErrorWithErrno(errno, reading: false, path: dstPath, extraUserInfo: extraErrorInfo(srcPath: srcPath, dstPath: dstPath, userVariant: variant)) diff --git a/Sources/Foundation/FileManager.swift b/Sources/Foundation/FileManager.swift index 962206fb2b..4cd41a8df4 100644 --- a/Sources/Foundation/FileManager.swift +++ b/Sources/Foundation/FileManager.swift @@ -886,6 +886,8 @@ open class FileManager : NSObject { return Int(mode & ~UInt32(ucrt.S_IFMT)) #elseif canImport(Darwin) return Int(mode & ~UInt32(S_IFMT)) +#elseif canImport(Android) + return Int(mode & ~mode_t(S_IFMT)) #else return Int(mode & ~S_IFMT) #endif