Skip to content

Commit 8de7486

Browse files
committed
more 32 bit android fixes
1 parent 9a06b52 commit 8de7486

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Sources/Foundation/FileHandle.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ open class FileHandle : NSObject {
321321
}
322322

323323
let readBlockSize: Int
324-
if statbuf.st_mode & S_IFMT == S_IFREG {
324+
if Int(statbuf.st_mode) & Int(S_IFMT) == Int(S_IFREG) {
325325
// TODO: Should files over a certain size always be mmap()'d?
326326
if options.contains(.alwaysMapped) {
327327
// Filesizes are often 64bit even on 32bit systems

Sources/Foundation/FileManager+POSIX.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -879,10 +879,10 @@ extension FileManager {
879879
do {
880880
return try _fileSystemRepresentation(withPath: path, { fsRep in
881881
var s = try _lstatFile(atPath: path, withFileSystemRepresentation: fsRep)
882-
if (s.st_mode & S_IFMT) == S_IFLNK {
882+
if (s.st_mode & mode_t(S_IFMT)) == mode_t(S_IFLNK) {
883883
// don't chase the link for this magic case -- we might be /Net/foo
884884
// which is a symlink to /private/Net/foo which is not yet mounted...
885-
if isDirectory == nil && (s.st_mode & S_ISVTX) == S_ISVTX {
885+
if isDirectory == nil && (s.st_mode & mode_t(S_ISVTX)) == mode_t(S_ISVTX) {
886886
return true
887887
}
888888
// chase the link; too bad if it is a slink to /Net/foo
@@ -892,7 +892,7 @@ extension FileManager {
892892
}
893893

894894
if let isDirectory = isDirectory {
895-
isDirectory.pointee = ObjCBool((s.st_mode & S_IFMT) == S_IFDIR)
895+
isDirectory.pointee = ObjCBool((s.st_mode & mode_t(S_IFMT)) == S_IFDIR)
896896
}
897897

898898
return true
@@ -956,7 +956,7 @@ extension FileManager {
956956
let parentS = try _lstatFile(atPath: path, withFileSystemRepresentation: parentFsRep)
957957

958958
// Check if the parent is 'sticky' if it exists.
959-
if (parentS.st_mode & S_ISVTX) == S_ISVTX {
959+
if (parentS.st_mode & mode_t(S_ISVTX)) == S_ISVTX {
960960
let s = try _lstatFile(atPath: path, withFileSystemRepresentation: fsRep)
961961

962962
// If the current user owns the file, return true.
@@ -1070,7 +1070,7 @@ extension FileManager {
10701070
defer { fsRep1.deallocate() }
10711071

10721072
let file1 = try _lstatFile(atPath: path1, withFileSystemRepresentation: fsRep1)
1073-
let file1Type = file1.st_mode & S_IFMT
1073+
let file1Type = file1.st_mode & mode_t(S_IFMT)
10741074

10751075
// Don't use access() for symlinks as only the contents should be checked even
10761076
// if the symlink doesnt point to an actual file, but access() will always try
@@ -1082,7 +1082,7 @@ extension FileManager {
10821082
let fsRep2 = try __fileSystemRepresentation(withPath: path2)
10831083
defer { fsRep2.deallocate() }
10841084
let file2 = try _lstatFile(atPath: path2, withFileSystemRepresentation: fsRep2)
1085-
let file2Type = file2.st_mode & S_IFMT
1085+
let file2Type = file2.st_mode & mode_t(S_IFMT)
10861086

10871087
// Are paths the same type: file, directory, symbolic link etc.
10881088
guard file1Type == file2Type else {

Sources/Foundation/FileManager.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ public struct FileAttributeType : RawRepresentable, Equatable, Hashable {
13471347
}
13481348
#else
13491349
internal init(statMode: mode_t) {
1350-
switch statMode & S_IFMT {
1350+
switch statMode & mode_t(S_IFMT) {
13511351
case mode_t(S_IFCHR): self = .typeCharacterSpecial
13521352
case mode_t(S_IFDIR): self = .typeDirectory
13531353
case mode_t(S_IFBLK): self = .typeBlockSpecial

Sources/Foundation/Process.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ open class Process: NSObject {
726726
throw _NSErrorWithErrno(errno, reading: true, path: launchPath)
727727
}
728728

729-
let isRegularFile: Bool = statInfo.st_mode & S_IFMT == S_IFREG
729+
let isRegularFile: Bool = statInfo.st_mode & mode_t(S_IFMT) == S_IFREG
730730
guard isRegularFile == true else {
731731
throw NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError)
732732
}

0 commit comments

Comments
 (0)