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
3 Replies
314 Views
I'm working on a MacOS application built in Unity3D. I'm using a native file browser plugin to open native MacOS file dialogs for selecting files. In order to generate PDFs, my app relies on using Chromium's Headless/command line functionality. On Windows, I can easily get the path to the included Microsoft Edge as that's standard, but on Mac, unless I guess and check (which I already do), there isn't a way to guarantee a Mac user has a Chromium-based browser installed. So I intend on allowing the user to set the path manually by selecting the .app file with a file dialog. But even when I specify .app to be a valid extension, they still don't appear selectable. I assume this is some sort of MacOS-specific limitation or default permissions, though I can't find much info on this online. Using C#/DotNet s there any way of allowing this behavior as needed? For some more info: I'm just running the application using System.Diagnostics.Process.Start() with command line arguments. Based on my experiments searching for Google Chrome (though Edge or Opera are just as usable), the path I'm looking for is: /Applications/ {{APP NAME}}.app/Contents/MacOS/{{APP NAME}} Because Contents isn't accessible by most users, I figured I would just automatically go in and grab the binary with the correct name once I have the path to the .app file. I know I could include some lightweight version of ChromeDriver with my app, but I'd rather keep everything as self-contained as possible, especially as so many people already have Chrome (or Opera, Edge, etc) installed. The challenge is that not everyone has it installed in the same place, hence my need to make it customizable. Any ideas or help would be appreciated! Thanks!
Posted
by
Post not yet marked as solved
3 Replies
360 Views
I have a very simple program, which works python kivy. In that program I read and write json files. Everything is fine with every simulator in Xcode Version 13.4. However when I connect my Phone it can read the json file but can't write in it. It says; `File "/Users/batuhan/programs/kivy-ios/2800-ios/YourApp/main.py", line 429, in secom PermissionError: [Errno 1] Operation not permitted: '/private/var/containers/Bundle/Application/C2508051-03DA-40EC-8587-A40D8B922055/2800.app/YourApp/savelist1.json' 2022-05-19 20:14:09.322995+0300 2800[3486:1776834] Application quit abnormally! 2022-05-19 20:14:09.416628+0300 2800[3486:1776834] Leaving` As I understand so far it is all about build settings in Xcode. Because as MacBook user I can write in that json file in simulator and everything works perfect. I need to give permission to write json file for every user, staff or everyone. I am just a beginner in Xcode, I think it is related with those settings; The json file is in same directory with main.py
Posted
by
Post not yet marked as solved
1 Replies
195 Views
I'm trying to get information about the current Mission Control Spaces, specifically the current space number. I can access this info by using "defaults read com.apple.spaces". The problem is that this info only seems to update when a new space is created or deleted. So if you read this and then change the current space or open a new window, that file will still be set to the previous space until a new space is created or deleted, which would then update the file. I can't see any other way to get this information. Is there any non-intrusive way to force the OS to update this plist file on demand (without relaunching the dock or Finder)? Or is there any other way to get the current space number any other way? Thanks
Posted
by
Post marked as solved
2 Replies
303 Views
So I created a program without selecting “use core data” and realized after trying to make a persistence data storage that it helps very much so I created a new program and selected it this time and copied everything over. It provided a file called “Persistence” and the contentView file had a bunch of stuff already filled in (Also something called the title of the program). I have the data I need saved to the persistent data storage narrowed down to a singular array, but none of the videos I found online showed this version of xcode that supplied a “Persistence” file when using core data so I’m unsure how to use it. I will provide the contentView and Persistence file for context. The array I need saved is called mainList in contentView. ContentView: import SwiftUI import CoreData struct ContentView: View {     var mainList = [RecipeList(),RecipeList(),RecipeList(),RecipeList(),RecipeList()]          @Environment(\.managedObjectContext) private var viewContext     @FetchRequest(         sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],         animation: .default)     private var items: FetchedResults<Item>     var body: some View {         NavigationView {             List {                 ForEach(items) { item in                     NavigationLink {                         Text("Item at \(item.timestamp!, formatter: itemFormatter)")                     } label: {                         Text(item.timestamp!, formatter: itemFormatter)                     }                 }                 .onDelete(perform: deleteItems)             }             .toolbar {                 ToolbarItem(placement: .navigationBarTrailing) {                     EditButton()                 }                 ToolbarItem {                     Button(action: addItem) {                         Label("Add Item", systemImage: "plus")                     }                 }             }             Text("Select an item")         }     }     private func addItem() {         withAnimation {             let newItem = Item(context: viewContext)             newItem.timestamp = Date()             do {                 try viewContext.save()             } catch {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     }     private func deleteItems(offsets: IndexSet) {         withAnimation {             offsets.map { items[$0] }.forEach(viewContext.delete)             do {                 try viewContext.save()             } catch {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 let nsError = error as NSError                 fatalError("Unresolved error \(nsError), \(nsError.userInfo)")             }         }     } } private let itemFormatter: DateFormatter = {     let formatter = DateFormatter()     formatter.dateStyle = .short     formatter.timeStyle = .medium     return formatter }() struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)     } } Persistence: import CoreData struct PersistenceController {     static let shared = PersistenceController()     static var preview: PersistenceController = {         let result = PersistenceController(inMemory: true)         let viewContext = result.container.viewContext         for _ in 0..<10 {             let newItem = Item(context: viewContext)             newItem.timestamp = Date()         }         do {             try viewContext.save()         } catch {             // Replace this implementation with code to handle the error appropriately.             // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.             let nsError = error as NSError             fatalError("Unresolved error \(nsError), \(nsError.userInfo)")         }         return result     }()     let container: NSPersistentCloudKitContainer     init(inMemory: Bool = false) {         container = NSPersistentCloudKitContainer(name: "ReciStorage")         if inMemory {             container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")         }         container.loadPersistentStores(completionHandler: { (storeDescription, error) in             if let error = error as NSError? {                 // Replace this implementation with code to handle the error appropriately.                 // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.                 /*                  Typical reasons for an error here include:                  * The parent directory does not exist, cannot be created, or disallows writing.                  * The persistent store is not accessible, due to permissions or data protection when the device is locked.                  * The device is out of space.                  * The store could not be migrated to the current model version.                  Check the error message to determine what the actual problem was.                  */                 fatalError("Unresolved error \(error), \(error.userInfo)")             }         })         container.viewContext.automaticallyMergesChangesFromParent = true     } } Image showing the thing named the title of the program that I’m certain is relevant to the persisting data storage: Also I’m unsure what I need to replace those comments with and what subclasses I should add to existing swift files like “codable” for example. Any help would be greatly appreciated.
Posted
by
Post marked as solved
2 Replies
230 Views
Hello community! I created an app with a golang shared library which runs a mkdir command at start. The app is working properly on emulator but not on physical device, looks like the emulator is properly sandboxing (wrapping) the shared library but in my iPhone I get a permission denied error (probably due to the app trying to write on File system) How can I reproduce the same sandboxing approach on my physical iPhone as in the emulator? Below you can see how the path for each looks like: Emulator installation path(All goo here): /Users/simbadmarino/Library/Developer/CoreSimulator/Devices/E6258FFC-CA3F-4B7F-BAAE-DDF717096A91/data/Containers/Data/Application/6BA771DD-BE68-454A-926E-A525188CBE38/.btfs Phone installation path(Permission errors here): /private/var/mobile/Containers/Data/Application/CB3B300F-07D8-4641-A6FA-4F584D4C6530/.btfs
Posted
by
Post marked as solved
3 Replies
264 Views
Hi, I wanted to know what level of NSFileProtection is provided by default in iOS in the user's documents directory of application container. Basically, if I am creating a file in this location - NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); What level of protection among NSFileProtectionType is provided? `
Posted
by
Post not yet marked as solved
3 Replies
291 Views
Hello, I am trying to get a FileHandle for a specific file on an external hard disk. My app is sandboxed and in order to be able to get a FileHandle I am showing a NSOpenPanel so the user can grant permission to access this disk. After the user has granted permissions, I use the following code to get the handle: guard let readDescriptor = try? FileDescriptor.open(readUrl.path, FileDescriptor.AccessMode.readWrite) else { return } I get the following error when this code runs: The operation couldn’t be completed. Operation not permitted What I don't understand is the fact that this code only fails on disks that have the MS-DOS file system. I have tested various USB sticks, SD cards and external hard drives. It works fine for the APFS, but once I format the device as MS-DOS, the code fails. Has anyone any idea why that is? Regards, Sascha
Posted
by
Post not yet marked as solved
5 Replies
303 Views
My app generates piecemeal near terabyte data distributed over one hundred files. Due to RAM and internal HD limitations I must store to an external HD in piecemeal fashion. That is to say, append fresh records directly to an existing file without reading-in the whole file, appending, and writing it out again. Ultimately (when data generation ceases) I will check each file to ensure uniqueness of member data structures. Is Core Data the tool I should use? If not, how do I append directly to disk-files without first reading it in?
Posted
by
Post not yet marked as solved
2 Replies
167 Views
Hi, I think I never thought about this but... let's say I have my iOS app (swift) and I have a ViewController with a WKWebView. If I open a link of a page with a pdf, where are the pdf and that page's files stored? Is there a way to clean the directory in which those files get stored? Is it something I shouldn't worry about? Thanks in advance
Post not yet marked as solved
3 Replies
171 Views
Hello forgive my beginner’s question—I urgently need to edit a database file (.fexdb), and in fact I can do so using BBEdit, but upon saving, the application to use that database (FontExplorer) no longer recognizes the file (also the icon has changed). It seems some metadata have been altered by BBEdit (I don’t even know if that is correct—is it?). Would anyone be so kind as to let me know (on a non-coder level) how to proceed? Thanks so much
Posted
by
Post marked as solved
2 Replies
190 Views
let applicationSupport = NSURL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0])     let launcherdir = applicationSupport.appendingPathComponent("MyApp") do { try FileManager.default.createDirectory(atPath: launcherdir!.path, withIntermediateDirectories: true, attributes: nil)                 } catch {                     print(error)                 }
Posted
by
Post not yet marked as solved
2 Replies
270 Views
I've noticed that on Monterey/Big Sur certain system and C++ functions in Logic no longer appear to work on files located outside of /Library/Audio/Plug-Ins/Components. For example, if you try to use std::ifstream on a file outside of the system plugin directory, it simply doesn't work (but still works fine in DAWs like Reaper, Ableton, ect). Certain graphics functions like NSOpenPanel appear to no longer work at all: Logic seems to prevent the window from opening, but still allows pop-up windows like CFUserNotificationDisplayAlert to display. Again, in other DAWs this all works fine. Has anyone noticed this, and if so, what's going on here? Is this the intended behavior for Logic now? It's not a huge deal, but some users like to install or place the sample directories of my plugins on different hard drives and things like that, and it seems like this is maybe no longer possible if they are using Logic? Tested in Logic 10.7.3 Monterey 12.3. Older AU SDK, but doubtful that's what has caused this.
Posted
by
Post not yet marked as solved
1 Replies
252 Views
How do I get updates about the file name change from the NSDocument window title? I noticed that despite file being property registered as a file presenter (by default), none of presentedItemDidChange, presentedSubitemDidChange, or presentedItemDidMove is called despite filename updates on the filesystem. the presentedItemURL does update value at some point. My subclass has autosave enabled, which makes title editing possible. override class var autosavesInPlace: Bool { true } [object Object]
Posted
by
Post not yet marked as solved
1 Replies
108 Views
Hello all! I was wondering how you choose which files types can be shared into your app? I'm trying to allow other apps to share a .OBJ file into our app, but our app is not appearing on the list of apps (even in "show more"). Thank you!
Posted
by
Post not yet marked as solved
0 Replies
119 Views
Hello, I've noticed, that when I close DocumentPicker by swiping from top to bottom (without picking a file or pressing cancel), no callback gets called. Currently I'm using didPickDocumentsAtURLs and documentPickerWasCancelled callbacks, neither of them get's called if DocumentPicker is closed by swiping. This is a problem, because while DocumentPicker is open (and a bit after that, while the file would get processed), I show a loading popup, which get's closed in one of the callbacks. In this case, I cant' find a callback to use and close the loading popup. Am I missing a callback, or is there some other issue?
Posted
by
Post not yet marked as solved
5 Replies
274 Views
I have a signed, notarized app that makes use of a privileged helper. In macOS 11 and 12, as noted in several places in the documentation, there was/is an increasing requirement for the user to grant permission for things over prior macOS releases. This is great, I'm on board. I've found that the privileged helper now needs the broad "Full Disk Access". How do I get the Finder to ask the user permission for this? My helper has the special text sections called "__info_plist" and "__launchd_plist" and I tried putting what I think should go into them in those but I didn't have any luck. Is there another section I need to know about or did I just mess something else up? I'm not using Xcode or Swift or ObjectiveC, everything is C++/C and the command line tools. My helper and Application use XPC to communicate with each other. Thanks! (after my helper fails it does show up in the Full Disk Access list, if you check that pref and try again it all works, I don't want my users to ever have to do that)
Posted
by