resourceValues
I can access the information of the folder I created with resourceValues. I wonder if the folder I created later password.
How can I use fileSecurity
? Is it ok to use fileSecurity ?
Create Folder:
func createNewDirectory(addPath: String, myFile: MyFile) {
guard let mainURL = takeMainDirectoryURL(addPath: addPath, myFile: myFile) else {
return
}
let path = mainURL.path
do {
try manager.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
} catch let error {
print("Error Description: \(error.localizedDescription)")
}
}
Get Folders:
func takeArrayOfItems() {
let foo = foo()
var infoFile = [MyFile]()
do {
for url in foo {
let resources = try url.resourceValues(forKeys: [.creationDateKey, .nameKey, .fileResourceTypeKey, .contentTypeKey, .isDirectoryKey, .isHiddenKey, .customIconKey, .effectiveIconKey])
infoFile.append(MyFile(fileName: resources.name ?? "", fileExtension: "", textForFile: "", image: nil, typeOfFile: resources.contentType?.preferredFilenameExtension ?? "emptyFolder", isLock: resources.isHidden ?? false, folderIcon: .init(rawValue: resources.contentType?.preferredFilenameExtension ?? "emptyFolder") ?? .empty, fileCreateDate: dateToString(date: resources.creationDate ?? Date())))
}
} catch let error {
print("error: \(error.localizedDescription)")
}
DispatchQueue.main.async { [weak self] in
self?.arrayOfFiles = infoFile
}
}