Files and Storage

RSS for tag

Ask questions about file systems and block storage.

Posts under Files and Storage tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Loading JSON data to table view
Hi everyone, I am unable to load contents of my manually created JSON file to a table view. I am not sure what might be wrong with my code and that is why I am requesting for assistance. Here is the link to my GitHub repository: https://github.com/leonardsangoroh/AfricanCountriesInfo/tree/main Any form of help will be highly appreciated. Thank you in advance :)
1
0
275
Feb ’24
how to read a file under project directory for both development and runtime?
For example I created a project aaa. aaa source folder is called aaa. that is aaa aaa/aaa then I put a data file in aaa/aaa/some.data now i want to test data in aaa/aaaTests/aaaTests.swift How can i access aaa/aaa/some.data in aaaTests.swift? If I want to access some.data inside aaa/aaa/ContentView.swift, how to write the code? I have been searching google and bing for days, but find no example answering my questions. Can anyone help me out? Thanks in advance.
1
0
553
Feb ’24
Desktop dokuments are invisible but exist
So ever since I restarted my M1 Mac, I have encountered a peculiar issue where files on the desktop or in Finder are not visible, despite their existence being confirmed via Terminal and other applications like VS Code. This can be quite frustrating, especially when it disrupts workflow and access to crucial files. That problem could also happen after updating the Mac too. Resolve 1: You toggle the iCloud settings on and off by going to Settings > Profile > iCloud > iCloud drive > Desktop and Dokuments Folders. after that restart the Mac and it's fixed. this worked for the most people but it did not for me. Resolve 2: open the Terminal and Navigate the the Desktop Directory by typing in: cd ~/Desktop To enshure your in the directory you can see the ..desktop % behind the cursor, and after that, set the visibility to True, by typing in: chflags nohidden * This should fix the issue.
0
0
245
Feb ’24
External Disk Mount outside / volumes
Hi Everyone, We are facing distribution of external disk which is attached as /Volume/Untitled in the MAC machine. Ideally, this external disk shouldn't be part of the root. We're facing one issue when we add anything in the external disk, it first add in the root because this external disk is like an extension of the root one. That's why we're not able to get the benefit of the external disk, facing full storage crunch in all the machine. Can anyone please suggest a work around. Our requirement is we are looking to mount external disk as aseperate mount point (i.e /externaldisk instead of default /volumes/Untitled). Thank you
1
0
217
Feb ’24
macOS load file progress indication
My app generates many files as large as 12 GB (limited by memory) and I use Picker() to select which to reload with FileManager(). The larger files can take three minutes to load (M2 Mini Pro) and it would be nice to have progress indication like Apple's App Store downloads with the mini spinner, file size and bytes loaded. From what I've read in "Developer Documentation", I must use a URLdelegate instance I have created, not the shared delegate, when effecting a URL download. "Downloading files in the Background" shows iOS code, not macOS, and it also uses a "shared" delegate. A post, here, dated years ago said what I seek is not possible and I have not found recent sample code to show otherwise. Can anyone shed light on this? Thanks
1
0
315
Feb ’24
NSFileProvider Extension crash on MacOS 14.4 Beta
NSFileProvider Extension based on Xamarin.Mac constantly crashes starting on MacOS 14.4 Beta Steps to Reproduce: Create simple Xamarin.Mac solution and add FileProviderExtension project Storage appears in Locations section in Finder Expected Behavior: Cloud storage shows folders content Actual Behavior: Cloud storage doesn't show folder content, just infinite running spinner FileProviderExtension process constantly crashes. It occurs only in OSX starting from 14.4 beta. Please review crash report and help me understand whats wrong and how to fix it. Simple project written with Swift and Xcode works without any issues. May be it’s related to issue described here https://forums.macrumors.com/threads/fileproviderctl-on-sonoma-14-4-here-we-f-ng-go-again.2418353. Thanks in advance! Environment-Info.log CrashReport.txt
9
0
775
Apr ’24
Clarification on Disk Space APIs - volumeAvailableCapacityForImportantUsageKey
Our application uses Disk Space API, specifically volumeAvailableCapacityForImportantUsageKey to determine the available free space on the device. However, we are facing challenges in understanding the reasoning criteria that an application needs to satisfy to use this API effectively. As part of our application requirement, we present an information modal to the user when disk space is low. Additionally, we log available disk space information and upload the logs to the cloud under certain conditions. We initially thought that E174.1 from the Privacy Manifest Files documentation fits our purpose. However, we are concerned about potentially violating the guideline: "Information accessed for this reason, or any derived information, may not be sent off-device." Could someone please provide additional clarity on how to navigate this fine line and ensure that our application aligns with the recommended practices and guidelines while handling disk space-related functionality? Thank you in advance for any insights or guidance you can provide! NOTE: We upload the logs to our server for troubleshooting and it may happen without user knowledge. Logs are encrypted and may contain the disk free space information
1
1
811
Feb ’24
About the key"Supports opening documents in place"and the Container Import of Xcode 15.2
when I use Xcode14 build on the iOS16, the keys"Supports opening documents in place"and"Application supports iTunes file sharing"works normally, it has a App folder in"My iPhone".But it's strange that when I update my Xcode and iOS to 15.2 and 17.2, it s don't working.not only there is not a App folder in"My iPhone",but also the container doesn't works too.More specifically speaking, I download the container from the device and add files into "Documents"folder. when I try to replace the container, it has no respond, and files cannot be founded in the device as well. But when I try to download the container from the device again, I found that the files is already there. Environment: MacBook Pro 2017 with macOS 13.6.3 Xcode 15.2 iPad Air 5 with iOS 17.2
1
0
512
Feb ’24
Unable to read Internal APFS SSD drive
We are trying to read disk sectors raw Data. Sample code can be found at the bottom. For external drive, it is working fine. We are able to see raw data which is not zero. For internal ssd APFS drive, We only get data filled with zeroes. We have tried with System Integrity Protection enabling and disabling. Please let us know Why same API failing for internal APFS drive? Is there any specific API available for reading raw data of internal APFS drive? #include <fcntl.h> #include <unistd.h> #include <iomanip> int main() { // Adjust this to your disk device on macOS const char* diskPath = "/dev/rdisk1"; //internal SSD device on macOS // Size of a sector (usually 4096 bytes for most disks on macOS) const int sectorSize = 4096; // Number of sectors you want to read const int numSectors = 8; // Starting sector number off_t startSector = 0; // Open the disk device using low-level file I/O int diskFile = open(diskPath, O_RDONLY); if (diskFile == -1) { std::cerr << "Error opening disk file." << std::endl; return 1; } // Read multiple sectors into a buffer char buffer[numSectors * sectorSize]; ssize_t bytesRead = pread(diskFile, buffer, numSectors * sectorSize, startSector * sectorSize); // Close the disk file close(diskFile); if (bytesRead != numSectors * sectorSize) { std::cerr << "Error reading sectors." << std::endl; return 1; } // Display the contents of the sectors in hex for (int i = 0; i < numSectors * sectorSize; ++i) { std::cout << std::hex << std::setw(2) << std::setfill('0') << (int)(unsigned char)buffer[i] << " "; if ((i + 1) % 16 == 0) { std::cout << std::endl; } } return 0; }
0
0
460
Feb ’24
MacOS Sonoma cron job doesn't have access to ~/.Trash even though it has full system access
MacOS Sonoma Version 14.2.1 I am running a python script via crontab, and the script runs, but I get an error when trying to iterate the ~/.Trash directory: PermissionError: [Errno 1] Operation not permitted: '/Users/me/.Trash' I have enabled full disk access for: /usr/sbin/cron, /usr/bin/crontab, and terminal.app, but still have the same problem. If I run the script directly, it works fine, but when cron runs it, I get the error above. ~/.Trash is the only directory that I've found to have problems with. I've tried both using absolute path and relative to my home directory . I have tried a few different crontab entries, but get the same result from all of them (I've ran each version directly and each works fine when not ran via cron). */5 * * * * /Users/me/miniforge3/envs/dev/bin/fclean &gt;&gt; /dev/null 2&gt;&amp;1 */5 * * * * /Users/me/miniforge3/envs/dev/bin/python /Users/me/miniforge3/envs/dev/bin/fclean &gt;&gt; /dev/null 2&gt;&amp;1 */5 * * * * /Users/me/miniforge3/envs/dev/bin/python /Users/me/path/to/file.py &gt;&gt; /dev/null 2&gt;&amp;1 if it's helpful the python function that's raising the permission issue is: def clean_folder(folder: Path, _time: int = days(30)) -&gt; None: """ If a file in the specified path hasn't been accessed in the specified days; remove it. Args: folder (Path): Path to folder to iterate through _time (int): optional time parameter to pass as expiration time. Returns: None """ for file in folder.iterdir(): if expired(file, _time): try: rm_files(file) except PermissionError as permission: logging.exception(permission) continue except Exception as _err: logging.exception(_err) continue ``
2
0
699
Feb ’24
How do I prevent my app's folders or files from being displayed or searched in the Files app?
How do I prevent my app's folders or files from being displayed or searched in the Files app? Currently, the app is set to display internal files and folders in the "Files" app, Apple's default app. Is there a way to turn this on and off within the app code so that our app's files or folders are not searched within the Files app? All files and folders in the Documents path and their subfolders and files are eligible.
1
0
358
Feb ’24
Troubleshooting Custom File Extension Recognition in iOS 17 with AirDrop and UIDocumentPickerViewController
Since the release of iOS 17, my application is no longer recognized as the default option for opening my custom file extension via AirDrop. I understand that Apple has modified AirDrop functionality to integrate more closely with the Files app. However, within the Files app, my file package is erroneously identified as a folder, thus ignoring my specified file extension. Additionally, my attempts to utilize UIDocumentPickerViewController for opening these files have been unsuccessful, as it fails to recognize the file type. I have explored various approaches with UIDocumentPickerViewController, including the following implementation: let importCustomFiles = UIAlertAction(title: "Import custom file", style: .default) { _ in let myExtensionType = UTType(filenameExtension: "MyExtension")! let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [myExtensionType]) pickerViewController.delegate = self pickerViewController.allowsMultipleSelection = false pickerViewController.shouldShowFileExtensions = true self.present(pickerViewController, animated: true, completion: nil) } Below is an excerpt from my Info.plist file, detailing the relevant configurations for my custom file extension: &lt;!-- MyExtension Document Type --&gt; &lt;key&gt;CFBundleDocumentTypes&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;CFBundleTypeIconFiles&lt;/key&gt; &lt;array&gt; &lt;string&gt;MyApp File Icon&lt;/string&gt; &lt;/array&gt; &lt;key&gt;CFBundleTypeName&lt;/key&gt; &lt;string&gt;Angles MyExtension&lt;/string&gt; &lt;key&gt;LSHandlerRank&lt;/key&gt; &lt;string&gt;Default&lt;/string&gt; &lt;key&gt;LSItemContentTypes&lt;/key&gt; &lt;array&gt; &lt;string&gt;au.com.mycompany.myapp.MyExtension&lt;/string&gt; &lt;/array&gt; &lt;key&gt;LSTypeIsPackage&lt;/key&gt; &lt;true/&gt; &lt;/dict&gt; &lt;/array&gt; &lt;!-- Exported Type Declaration for MyExtension --&gt; &lt;key&gt;UTExportedTypeDeclarations&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;UTTypeConformsTo&lt;/key&gt; &lt;array&gt; &lt;string&gt;public.directory&lt;/string&gt; &lt;/array&gt; &lt;key&gt;UTTypeDescription&lt;/key&gt; &lt;string&gt;Custom file extension for MyExtension files&lt;/string&gt; &lt;key&gt;UTTypeIconFiles&lt;/key&gt; &lt;array&gt; &lt;string&gt;MyApp File Icon&lt;/string&gt; &lt;/array&gt; &lt;key&gt;UTTypeIdentifier&lt;/key&gt; &lt;string&gt;au.com.mycompany.myapp.MyExtension&lt;/string&gt; &lt;key&gt;UTTypeTagSpecification&lt;/key&gt; &lt;dict&gt; &lt;key&gt;public.filename-extension&lt;/key&gt; &lt;array&gt; &lt;string&gt;myextension&lt;/string&gt; &lt;/array&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/array&gt; &lt;!-- Imported Type Declaration for MyExtension --&gt; &lt;key&gt;UTImportedTypeDeclarations&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;UTTypeConformsTo&lt;/key&gt; &lt;array&gt; &lt;string&gt;public.directory&lt;/string&gt; &lt;/array&gt; &lt;key&gt;UTTypeDescription&lt;/key&gt; &lt;string&gt;Custom file extension for MyExtension files&lt;/string&gt; &lt;key&gt;UTTypeIdentifier&lt;/key&gt; &lt;string&gt;au.com.mycompany.myapp.MyExtension&lt;/string&gt; &lt;key&gt;UTTypeTagSpecification&lt;/key&gt; &lt;dict&gt; &lt;key&gt;public.filename-extension&lt;/key&gt; &lt;array&gt; &lt;string&gt;myextension&lt;/string&gt; &lt;/array&gt; &lt;/dict&gt; &lt;/dict&gt; &lt;/array&gt; I am seeking assistance in resolving this issue so that my application can properly recognize and open files with my custom extension, both via AirDrop and within the Files app. Any insights or suggestions would be greatly appreciated.
1
0
498
Jan ’24
Determine the user name that was used to login to a network server
When using the mount command on macOS, I can see mounted network servers like this: //tt@mynas.local/NAS on /Volumes/NAS (smbfs, nodev, nosuid, mounted by thomas) In this example "thomas" is my macOS user name, under which I mounted the "NAS" volume. But there's also the "tt" name before the "@" - and that's what I'm interested in getting - that's the user name known to the server, i.e. the name I logged in on the server when the connection prompt appeared. How do I get this name (tt) via macOS APIs? I can get it via "mount", but that requires parsing and is inefficient, and so I like to avoid that if possible. man mount mentions getfsent(), but in my testing it only lists internal volumes, not network volumes.
2
0
444
Feb ’24
Determine the original network volume name in case it's been renamed automatically due to a name conflict
On macOS, if I mount two volumes whose name is the same, the second one gets renamed, by appending "-1" to its name. I need a method to determine the original volume name, i.e. without such a suffix. (Of course, I cannot blindly remove any "-" plus digits because the volume may actually be named like this.) I can find the original name when using the mount command in Terminal: //tt@192.168.61.121/NAS2 on /Volumes/NAS2 (smbfs, nodev, nosuid, mounted by tt) //tt@QNAS%28AFP%29._afpovertcp._tcp.local/NAS2 on /Volumes/NAS2-1 (afpfs, nodev, nosuid, mounted by tt) Here, I can tell that "/Volumes/NAS2-1" was originally named "NAS2" on the network. How do I determine the share's name without invoking such tools, but via CF or other macOS functions, with providing the path or URL of the mounted volume (such as "/Volumes/NAS2-1")?
1
0
347
Jan ’24
ShareSheet failing but only for US users
I have an app that shares a text file using the iOS ShareSheet. This app has functioned as intended until the release of iOS17 but I now have reports of zero length files ... but only from users based in the US! I have test reports from UK and Europe that show no issues. I have tested the original implementation, that uses UIDocumentInteractionController, and alternatives such as UIActivityViewController e.g.: UIActivityViewController* avc = [[UIActivityViewController alloc] initWithActivityItems:@[self.temporaryURL] applicationActivities:nil]; [self presentViewController:avc animated:YES completion:^{ }]; Like many reports on the forums, there are a lot of errors (from the Sharing library) in the console such as: Failed to request default share mode for fileURL:file:///private/var/mobile/Containers/Data/Application.... or Only support loading options for CKShare and SWY types. But in my testing the file shares without problems. The file to be shared is located in the NSTemporaryDirectory() Has anyone else seen this strange behaviour? If so, does anyone know how to fix it?
3
0
1.1k
Jan ’24
Share Extension can access files from the Photos app but not the Files app
Share Extension can access files from the Photos app but not the Files app. In case of the Photos app the file url is something like file:///var/mobile/... In case of the Files app the url stars with file:///private/var/mobile/... The following error is thrown in case of the Files app Error Domain=NSCocoaErrorDomain Code=260 "The file “file.pdf” couldn’t be opened because there is no such file." However the file is there, it was selected via the Files app and the share button was used to launch the Share Extension. Also the access to the file is within the following block url.startAccessingSecurityScopedResource() ... url.stopAccessingSecurityScopedResource() Another issue is that the Share Extension does not appear in the Settings / Privacy / Files and Folders. Here are the apps which have the "Applications that have requested access to files and folders will appear here". What is the solution to allow the Share extension access the files from the Files app ?
0
0
411
Jan ’24
Combating `kFSEventStreamEventFlagMustScanSubDirs`
Hello! In our application we use FSEventStream to track the file system changes, this is required to keep up-to-date cached view on the file system and manage auxiliary state like indices. To get support for tracking symlinks that may point outside of the directory of interest, we have set up an FSEventStream that is watching the root ('/') of the file system. Now, the issue is, the application receives a significant amount of MustScanSubDirs events with the UserDropped flag raised, which creates a non-trivial load on the system by our application as we need to check if all the auxiliary state is still adequate. Tangentially, it was noted that the count of these events is higher on Apple Silicon systems in comparison to the older generation Intel MacBooks. The MustScanSubDirs events inevitably come en masse during a high file system load, which is not surprising by itself, but we are looking for a way to reduce the count. Interestingly, in some cases we have observed a steady stream of such events even after our load test which creates/deletes files would complete, for at least several minutes after. What we have tried: Given it has the UserDropped flag, which indicates that our application cannot keep up with the stream, we have completely removed any work from the event processing callback, reducing it to an event counter increment. For the same reason as above, set the priority of the thread that backs the processing run loop to soft real-time. Instruments' System Trace showed that now our thread is always scheduled within several microseconds after it was awaken by fseventsd and was never preempted. Use DispatchQueue instead of the deprecated RunLoop combination with FSEventStream. The expectation was that it would reduce context switches. Experimented with serial and concurrent dispatch queues with high QoS. Reduce the scope down to the directory of interest instead of watching the file system root. Different combinations of kFSEventStreamCreateFlag* flags with different values of the latency parameter (from 0 to 5 seconds). Recreate the FSEventStream after a MustScanSubDirs event, starting at the event ID directly preceding it (the last non-dropped event). The expectation was that reading from the event log would allow to bypass the "keep up" requirements. None of that helped to definitively lower the count of MustScanSubDirs events. What's worse, as mentioned above, even after the load test would complete, occasionally, we'd continue to receive such events for a while after, without our test generating any load, and judging from the count of events in total during that period, no other application was creating a massive load either. So far we have only observed that when watching the file system root. The (6) somewhat helps with the issue, recreating the stream can allow our application to proceed further at some point, without generating a new MustScanSubDirs event following the last successfully read event, but it also has drawbacks, as the application can "stuck" for a longer periods of time (30-60 seconds) recreating the stream at the same event ID and repeatedly receiving MustScanSubDirs event immediately. Eventually it would get through that event (hopefully without losing anything in the process) and will start receiving new events again. Although, it will very soon encounter the next MustScanSubDirs event and can stuck on it, too. In the end, we're looking for the answer to the following questions: How exactly FSEventStream decides that MustScanSubDirs should be sent? Why do we get UserDropped events even if our application seemingly can keep up with the stream of events? Are there any other knobs that can help with reducing the count of such events? Is it possible to somehow increase buffers or affect fseventsd in some other way to help our application to "keep up"? Or can we do something on the application side? Is there any other API that doesn't require root privileges to reliably track file system events? We are aware of kqueue, but it doesn't suit well as it requires to set up a watch for every individual subdirectory and/or file and can easily max out the count of permitted open file descriptors. What has changed with the Apple Silicon to increase the count of such events? The assumption was the heterogeneous cores and changes to the scheduling procedure, but we still receive a lot even with real-time threads. Thanks!
0
0
250
Jan ’24
Uninstall FortiClient using a script on macOS
Hi all, I'm trying to uninstall FortiClient on macbook with M1/M2 processor using a script from this article: https://community.fortinet.com/t5/FortiClient/Technical-Tip-Uninstall-FortiClient-using-a-script-on-... I only added two lines to change flags. Here is my script: #!/bin/sh # Uninstall FortiClient.sh pkill FortiClient pkill FortiClientAgent pkill FctMiscAg launchctl unload /Library/LaunchDaemons/com.fortinet* chflags -hv noschg /Applications/FortiClient.app chflags -hv noschg /Applications/FortiClientUninstaller.app rm -Rfv /Applications/FortiClient.app rm -Rfv /Applications/FortiClientUninstaller.app rm -Rfv /Library/Application\ Support/Fortinet rm -Rfv /Library/Internet\ Plug-Ins FortiClient_SSLVPN_Plugin.bundle rm -Rfv '/Library/LaunchDaemons/com.fortinet.forticlient.vpn.plist' rm -Rfv '/Library/LaunchDaemons/com.fortinet.forticlient.wf.plist' rm -Rfv '/Library/LaunchDaemons/com.fortinet.forticlient.fmon.plist' rm -Rfv '/Library/LaunchDaemons/com.fortinet.forticlient.epctrl.plist' rm -Rfv '/Library/LaunchDaemons/com.fortinet.forticlient.appfw.plist' rm -Rfv '/Library/LaunchDaemons/com.fortinet.forticlient.fssoagent_launchdaemon.plist' localAccounts=$(dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }') for user in $localAccounts ; do rm -Rfv /Users/"$user"/Library/Application\ Support/Fortinet/ done But I got error that deleting FortiClient.app and FortiClient.app\Content is not permitted, because application is locked. At this time, FortiClientUninstaller.app has been deleted successfully: chflags: /Applications/FortiClient.app: Operation not permitted /Applications/FortiClientUninstaller.app and rm -Rfv /Applications/FortiClient.app rm: /Applications/FortiClient.app/Contents: Operation not permitted rm: /Applications/FortiClient.app: Operation not permitted Could someone help me with this issue, please? I need to uninstall FortiClient using a script via MDM on multiply devices
1
0
632
Jan ’24
iOS app local storage persistency when updating app (Xamarin -> Flutter)
Currently in our published version of iOS app (built in Xamarin.Forms) we are storing some local data (settings etc.) as json and other files in the device. We are planning to do a major update when we re-create the whole app using Flutter. My question is: As long as bundle ID will be the same for the Flutter build as was for the Xamarin.Forms build and the app version of the Flutter build will be higher (than the previously one) will the update in the App Store will act just as a regular update of the app (so the user will theoretically even not notice that the newer version was built with different approach)? Will the update keep or delete the local files stored by the previous version of the app? Even that the older version is build of the Xamarin.Forms and the newer one will be build of the Flutter? Of course the Flutter version will direct to same paths and files as the previous Xamarin version. The files are stored in paths: /var/mobile/Containers/Data/Application//Library/MyApp/ e.g.: .../Library/MyApp/settings.json .../Library/MyApp/Media/caches.json .../Library/MyApp/Media/Settings/settings.json ... etc. Some settings are also stored in .plist NSUserDefaults.StandardUserDefaults as key/value pairs. Is there any official documentation about those 2 my questions? So far I have only found some info about bundle ID in general but no article directly answered me those 2 questions (mentioned above).
2
0
890
Jan ’24