I am creating an app using Swift for macOS. I was wondering if there was a way to determine if a file is being downloaded, for example like the one in the picture.
I have tried attributesOfItemAtPath, which returns the following keys:
NSFileAttributeKey(_rawValue: NSFileSystemFileNumber)
NSFileAttributeKey(_rawValue: NSFileHFSTypeCode)
NSFileAttributeKey(_rawValue: NSFileReferenceCount)
NSFileAttributeKey(_rawValue: NSFileOwnerAccountName)
NSFileAttributeKey(_rawValue: NSFileCreationDate)
NSFileAttributeKey(_rawValue: NSFileExtensionHidden)
NSFileAttributeKey(_rawValue: NSFileGroupOwnerAccountID)
NSFileAttributeKey(_rawValue: NSFileOwnerAccountID)
NSFileAttributeKey(_rawValue: NSFileModificationDate)
NSFileAttributeKey(_rawValue: NSFileSystemNumber)
NSFileAttributeKey(_rawValue: NSFileGroupOwnerAccountName)
NSFileAttributeKey(_rawValue: NSFilePosixPermissions)
NSFileAttributeKey(_rawValue: NSFileSize)
NSFileAttributeKey(_rawValue: NSFileType)
NSFileAttributeKey(_rawValue: NSFileHFSCreatorCode)
NSFileAttributeKey(_rawValue: NSFileExtendedAttributes)
NSFileAttributeKey(_rawValue: NSFileProtectionKey)
I found no relevant entry, so I tried to use this extension:
extension FileManager {
func getEntireSpotlightInformation(path: String) -> [AnyHashable : Any]? {
guard self.fileExists(atPath: path) else {
return nil
}
let cfPath = path as CFString
let ref = MDItemCreate(kCFAllocatorDefault, cfPath)
let attributes = MDItemCopyAttributeNames(ref) as? Array<String>
var returnValue: [AnyHashable : Any]! = Dictionary()
for (index, item) in attributes!.enumerated() {
//print("Eccoci - index = \(index) - AttributeName = \(item)")
let cfAttribute = item as CFString
let result = MDItemCopyAttribute(ref, cfAttribute)
returnValue[item] = result
}
return returnValue
}
}
Which returned the following keys:
kMDItemDateAdded
kMDItemContentCreationDate
kMDItemDocumentIdentifier
kMDItemInterestingDate_Ranking
kMDItemFSFinderFlags
kMDItemContentTypeTree
kMDItemContentType
kMDItemFSNodeCount
kMDItemDisplayName
kMDItemFSCreatorCode
kMDItemFSInvisible
kMDItemLogicalSize
_kMDItemDisplayNameWithExtensions
kMDItemFSIsExtensionHidden
kMDItemContentCreationDate_Ranking
kMDItemFSName
kMDItemContentModificationDate
kMDItemFSCreationDate
kMDItemFSOwnerGroupID
kMDItemPhysicalSize
kMDItemDownloadedDate
kMDItemKind
kMDItemDateAdded_Ranking
kMDItemFSOwnerUserID
kMDItemContentModificationDate_Ranking
kMDItemWhereFroms
kMDItemFSSize
kMDItemFSTypeCode
kMDItemFSContentChangeDate
kMDItemFSLabel
But, again, I don't see anything promising. Any help is greatly appreciated. Thanks