Files and Storage

RSS for tag

Ask questions about file systems and block storage.

Pinned Posts

Posts under Files and Storage tag

170 Posts
Sort by:
Post not yet marked as solved
0 Replies
56 Views
This documentation: Documentation/Bundle/Resources/Information Property List/Data and storage/NSSupportsPurgeableLocalStorage says: Property List Key NSSupportsPurgeableLocalStorage A Boolean value indicating whether the app continues working if the system purges the local storage. Under what conditions does the system "[purge] the local storage", and does this mean the entire local storage for the app? I can see how when a user deletes an app the local storage would be deleted, but then the app would not continue working, since it's no longer on the device.
Posted Last updated
.
Post not yet marked as solved
3 Replies
94 Views
Has anyone else seen in Ventura B3 where you have a URL path as a source and you want to use the filename for that, aka lastPathComponent in a destination URL, so you have something like: let destinationURL = destinationDIrectory.appendingPathExtension(sourceURL.lastPathComponent) and lastPathComponent is a file name but what you get for destinationURL is: destinationDirectory.lastPathComponent instead of destinationDirectory/lastPathComponent or is it just me?
Posted Last updated
.
Post marked as solved
4 Replies
105 Views
Hi, I'm trying to lock a file from objective-c (or plain C) so that other processes cannot read or write to it. So far, unsuccessfully. I've tried to use all APIs I can think of, but none locked the file: open then flock open then lockf open with O_EXLOCK open then fcntl (F_SETLK) open then NSDistributedLock I'm running macOS 11.6.1 on an APFS drive. For every API used, I was able to open and edit the file from command line using vi or just using cat on the file. Isn't there any way of preventing another process from accessing a file, until I'm done with it (ie. I closed the file, or the file handle is relinquished)? Thanks, Chris
Posted Last updated
.
Post not yet marked as solved
3 Replies
155 Views
Hello! Does anyone maintain local virtual servers with local domain names and SSL security? If so please read on. I use OPENSSL@3 installed by Homebrew in a MacOS Monterey environment with Xcode working in the background to create a series of keys and certificates (see below) so that I can open my local sites with the https:// prefix. For several days, sometimes a week, or even more everything works fine. I can type in addresses such as localhost/index.html.en, ali.ourseventh.local, etc. in any browser window (Firefox, Safari, Chrome, etc.), and after an initial browser objection, my local servers open as if they were labeled with the .org, .net., .com extensions on the WAN. This can go on for days, with daily reboots. And then, out of nowhere, I wake up one morning, start my computer, and discover that I can no longer access my locally installed virtually hosted websites. As it takes many, many minutes to recreate and reinstall all of my certificates, and I never no when it is going to happen, it can become extremely frustrating -- especially when I am very busy. In crude outline things work as follows: In the folder /usr/local/etc/openssl@3/certs/ I create a number of files with the following names and extensions localhost.crt localhost.csr localhost.key reg.cnf myCA.pem myCA.key I save one of the above certificates in my keychain. Enter the command " brew services restart httpd " in terminal Open any browser and everything works fine, and voilà! Everything works fine. Can you offer any suggestions as to what is interfering and how to correct for it? Roddy
Posted
by kiusau.
Last updated
.
Post not yet marked as solved
0 Replies
59 Views
I believe that if I rename a file, I'm supposed to do that inside a coordinated write on the parent directory - right? So say I have a file /path/to/folder/f1 and I want to rename it (in the same directory) as /path/to/folder/f2. I do a coordinated write (with the forMoving option) on the directory /path/to/folder. That passes me a possibly different path to the directory, right? Say I get /path/to/different. Question: what rename should I actually do? Do I need to construct from and to paths based on the different path that is passed to the accessor? I.e. do I rename from /path/to/folder/f1 to /path/to/folder/f2 or rename from /path/to/different/f1 to /path/to/different/f2 or some other combination? Do NSFileManager's renaming methods do anything special in this regard? Can I use e.g. std::filesystem::rename()? I am interested in both local documents that are visible e.g. in the Files app, and iCloud Drive documents, if that makes any difference. Thanks!
Posted
by endecotp.
Last updated
.
Post not yet marked as solved
9 Replies
705 Views
Hello, I have a question regarding how launchd handles NFS shares in macOS 10.15 and later. It seems that launchd daemons can't access network shares (NFS) any longer. Is it possible to enable NFS access for launch daemons?
Posted
by atanasK.
Last updated
.
Post not yet marked as solved
0 Replies
80 Views
I am trying to create an app that downloads files and stores these files in the document folder that can be seen inside the Files App. I added these to the Info.plist file <key>UIFileSharingEnabled</key> <true/> <key>LSSupportsOpeningDocumentsInPlace</key> <true/> I also added debugging code to test that the file is indeed inside the document folder. The code can see the file, but the Files app doesn't show my app document's folder by itself (not even after adding files manually). There is a special case that does show my app folder inside the Files app: when I move an existing file I have to my app document folder. That is the only way that the Files app shows my app document folder - but the strange part is that still it doesn't show the file I downloaded inside (only the file I moved manually). Also: I tested on the simulator using iPhone 12 Pro and on a real device: same result. I deleted and re-installed the app many times, and also restarted Xcode and restarted the real device - nothing changed. This is the code that downloads the file into my app document folder. func downloadFile(urlString: String, filename: String, completionHandler: @escaping (_ err: Error?) -> Void) {     let config = URLSessionConfiguration.default           guard let url = URL(string: urlString), let documentPathURL = getDestFileURL() else { return }           let request = URLRequest(url: url)     let session = URLSession(configuration: config)           os_log("getting download folder %{public}@", documentPathURL.path as CVarArg)     let fileManager = FileManager()     let task = session.downloadTask(with: request) { url, response, error in       if error != nil {         os_log("error: %{public}@", error! as CVarArg)         completionHandler(error)         return       }       guard let fileURL = url else { return }       let fileNameParts = filename.components(separatedBy: ".")        do {         var isDir:ObjCBool = true         // download folder exists?         if !FileManager.default.fileExists(atPath: documentPathURL.path, isDirectory: &isDir) {           os_log("creating new folder")           try FileManager.default.createDirectory(atPath: documentPathURL.path, withIntermediateDirectories: true, attributes: nil)         }         let savePathURL = documentPathURL.appendingPathComponent(fileNameParts[0]).appendingPathExtension(fileNameParts[1])         // dest file exists?         if FileManager.default.fileExists(atPath: savePathURL.path) {           os_log("removing existing file")           try FileManager.default.removeItem(atPath: savePathURL.path)         }         // all good? then move the file!         try fileManager.moveItem(at: fileURL, to: savePathURL)         os_log("from path %{public}@", fileURL.path)         os_log("to path: %{public}@", savePathURL.path)         // dest file exists?         if FileManager.default.fileExists(atPath: savePathURL.path) {           let files = try fileManager.contentsOfDirectory(atPath: documentPathURL.path)           try fileManager.setAttributes([FileAttributeKey.protectionKey : FileProtectionType.none, FileAttributeKey.posixPermissions: 0o777], ofItemAtPath: savePathURL.path)           let attrs = try fileManager.attributesOfItem(atPath: savePathURL.path)           os_log("list of files %{public}@", files as CVarArg)           os_log("attrs of file %{public}@", attrs as CVarArg)           os_log("move was a success")         }                   completionHandler(nil)       }       catch {         os_log("final error: %{public}@", error as CVarArg)         completionHandler(MyError.couldNotDownload)       } } Can anyone see something wrong or missing? Thanks
Posted
by pbrea.
Last updated
.
Post marked as solved
1 Replies
66 Views
I've completed a simple app that plays 3D video. Now, I'm trying to make it open files from the menu, as well as using the Cmd-O keyboard shortcut. But the "Open" menu item in the "File" menu is gray - I don't know exactly what this means, but it seems that the current form of the app doesn't support openning files. I've had a func application(_ application: NSApplication, openFile filename: String) -> Bool function in my app delegate, I've had a CFBundleDocumentTypes with an entry of the MIME type of "video/mp4". What am I doing wrong?
Posted Last updated
.
Post not yet marked as solved
4 Replies
3.2k Views
My app allows users to create their own documents. iOS stores them in/var/mobile/containers/Data/Application/FFFF/Documents/This folder is in the app bundle, yes?When the user installs an updated build from the app store, they would then lose all of their documents.How can the app be made to keep the user's documents when a newer build is downloaded from the app store?
Posted Last updated
.
Post not yet marked as solved
1 Replies
86 Views
Hello there , i am new to apple developing and I was wondering if there’s a native api or some way to access your iMessage chat history and maybe get it in Jason or xml format?
Posted Last updated
.
Post not yet marked as solved
0 Replies
103 Views
Hello, Recently we added a change in our app that changed the resource addition to Photos - Until now we called addResourceWithType:fileURL:options: with PHAssetResourceCreationOptions.shouldMoveFile set to YES, and when we changed it to NO (the default value) we observed much more asset creation failures. Specifically we see a new error code in the procedure - PHPhotosErrorNotEnoughSpace. One can clearly see a connection between adding more storage to the file system and an asset creation failure that is related to storage, but we are struggling to understand a few things: The storage of the device is always higher than the video size, usually by a great amount - We observed failures for devices with 120GB free storage, while the video size was 200MB. Generally we save quite a lot of resources to the file system, so it is quite surprising to see supposedly storage issues when adding a relatively low amount of extra storage. The asset creation is part of a bigger procedure of encoding a video to a file system, and then moving/copying it to Photos. Is it that big of a difference to copy a video of 100MB-200MB instead of moving it, such that the overall procedure failure will increase drastically? Appreciate any help.
Posted
by galk1d.
Last updated
.
Post not yet marked as solved
0 Replies
72 Views
Dear Experts, NSCoordinatedFile's coordinatedRead and coordinatedWrite methods supply a possibly-modified path to the accessor block. (I think it is only modified if there are concurrent accesses, so none of this is easy to test.) If I enumerate the contents of a directory inside a coordinatedRead on the directory, the paths that I get for the directory entries will include this possibly-modified parent path. (Unless maybe NSFileManager's enumeration methods have some magic to avoid that.) Is it OK for me to keep these "special" pathnames beyond the end of the coordinatedRead? If not, perhaps I need to get only the leafname from the directory enumeration and append that to the original directory path. Thoughts anyone?
Posted
by endecotp.
Last updated
.
Post not yet marked as solved
0 Replies
70 Views
I am developing a statistics application for the artists of my record label, I have only seen development APIs for the platform, but I have not found Apple for Artist, does anyone know if these exist? Thanks.
Posted
by 3WOW.
Last updated
.
Post not yet marked as solved
5 Replies
1.3k Views
I have an issue on importing files into my app when selected by the user through UIDocumentPickerViewController. The error I get is: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied". I'm testing on iPhone 11 with iOS 13.5.1. This is my implementation: func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]){                  urls.forEach { (url) in                          let access = url.startAccessingSecurityScopedResource()             var error: NSError? = nil             NSFileCoordinator().coordinate(readingItemAt: url, error: &amp;error) { (coorURL) in             do{                     let gZippedData = try Data(contentsOf: url)                     print(gZippedData)                     if access{                         url.stopAccessingSecurityScopedResource()                     }                 }catch{                     print(error.localizedDescription)                 }                     }                 }             }         }     } The value of access is true. why I can't access the file? what am I missing? Thank you for your help.
Posted
by totka.
Last updated
.
Post not yet marked as solved
0 Replies
68 Views
Dear All, Does anyone have any suggestions for an iPad text editor app that is well-behaved with respect to NSFileCoordinator / NSFilePresenter / UIDocument etc.? Specifically, I'd like something that I can run in iPad split screen mode alongside my test app. I'd like to be able to make changes to files using the text editor and see my test app pick them up, and vice-versa. I am currently trying an app called "Quick Text" which mostly works but it doesn't seem to pick up changes that I make in my test app unless I close and re-open the file at its end. I'm also soon going to reach its limit of "10 edits per week"! I have a couple of others to try, but maybe someone here has a suggestion?
Posted
by endecotp.
Last updated
.
Post not yet marked as solved
0 Replies
84 Views
Dear Experts, Should I use NSFileCoordinator coordinateWritingItemAtURL: around a call to NSFileManager trashItemAtURL: ? What options should I pass - NSFileCoordinatorWritingForDeleting, or ...ForMoving, or something else? I've attempted various combinations. If I don't use the NSFileCoordinator, then the change is not reflected in the Files app (open alongside my test app in iPad split screen mode). All attempts using NSFileCoordinator result in a deadlock inside trashItemAtURL - it is stuck waiting for a semaphore. I do have a FilePresenter for this file, but I am passing it to the NSFileCoordinator's init so that should not lead to deadlock. I believe I am doing everything on the main thread. The files are local, in the app's Documents directory. Any ideas anyone?
Posted
by endecotp.
Last updated
.
Post not yet marked as solved
0 Replies
68 Views
Dear Experts, We are required to remove our NSFilePresenters from the NSFileCoordinator when the app goes to the background and re-add them when it returns to the foreground. Does this mean that when we foreground, we need to manually check if our files have been modified, deleted, or moved in the meantime? Or is there some mechanism in NSFilePresenter/NSFileCoordinator that will report any such changes to us? Detecting that a file has been modified or deleted is not difficult, but I don't think it's possible to detect that it has moved. Changes to directories are also difficult. Any advice? What does UIDocument do in this case?
Posted
by endecotp.
Last updated
.