         return statInfo
     }
 
+    internal func _filePermissionsMask(mode : UInt32) -> Int {
+#if os(Windows)
+        return Int(mode & ~UInt32(ucrt.S_IFMT))
+#elseif canImport(Darwin)
+        return Int(mode & ~UInt32(S_IFMT))
+#else
+        return Int(mode & ~S_IFMT)
+#endif
+    }
+
     internal func _permissionsOfItem(atPath path: String) throws -> Int {
         let fileInfo = try _lstatFile(atPath: path)
-#if os(Windows)
-        return Int(fileInfo.st_mode & ~UInt16(ucrt.S_IFMT))
-#else
-        return Int(fileInfo.st_mode & ~S_IFMT)
-#endif
+        return _filePermissionsMask(mode: UInt32(fileInfo.st_mode))
     }
 
 

    open func attributesOfItem(atPath path: String) throws -> [FileAttributeKey : Any] {
        var result: [FileAttributeKey:Any] = [:]

#if os(Windows)
        let faAttributes: WIN32_FILE_ATTRIBUTE_DATA = try windowsFileAttributes(atPath: path)

        result[.size] = NSNumber(value: (faAttributes.nFileSizeHigh << 32) | faAttributes.nFileSizeLow)
        result[.modificationDate] = Date(timeIntervalSinceReferenceDate: TimeInterval(faAttributes.ftLastWriteTime))
        // FIXME(compnerd) what about .posixPermissions, .referenceCount, .systemNumber, .systemFileNumber, .ownerAccountName, .groupOwnerAccountName, .type, .immuatable, .appendOnly, .ownerAccountID, .groupOwnerAccountID
#else
   
#if os(Linux)
        let (s, creationDate) = try _statxFile(atPath: path)
        result[.creationDate] = creationDate

#endif
        result[.ownerAccountID] = NSNumber(value: UInt64(s.st_uid))
        result[.groupOwnerAccountID] = NSNumber(value: UInt64(s.st_gid))

        return result
    }

    /* attributesOfFileSystemForPath:error: returns an NSDictionary of key/value pairs containing the attributes of the filesystem containing the provided path. If this method returns 'nil', an NSError will be returned by reference in the 'error' parameter. This method does not traverse a terminal symlink.
     
        This method replaces fileSystemAttributesAtPath:.
