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

Why is fcopyfile faster than copyfile?
In my previous post I asked why copyfile is slower than the cp Terminal command. In this other post I asked how I can make copyfile faster by changing the block size. Now I discovered that the cp implementation on macOS is open source and that when copying regular files it doesn't use copyfile but fcopyfile. In a test I noticed that fcopyfile by default seems to be faster than copyfile. When copying a 7 GB file I get about the same results I observed when comparing filecopy to cp: copyfile: 4.70 s fcopyfile: 3.44 s When setting a block size of 16_777_216, copyfile becomes faster than fcopyfile: copyfile: 3.20 s fcopyfile: 3.53 s Is this expected and why is it so? I would have expected that they both have the same performance, and when changing the block size they would still have the same performance. Here is the test code. Change #if true to #if false to switch from fcopyfile to copyfile: import Foundation import System let source = "/path/to/source" let destination = "/path/to/destination" #if true let state = copyfile_state_alloc() defer { copyfile_state_free(state) } //var bsize = 16_777_216 //copyfile_state_set(state, UInt32(COPYFILE_STATE_BSIZE), &bsize) let sourceFd = try! FileDescriptor.open(source, .readOnly) let destinationFd = try! FileDescriptor.open(destination, .writeOnly) if fcopyfile(sourceFd.rawValue, destinationFd.rawValue, state, copyfile_flags_t(COPYFILE_ALL | COPYFILE_NOFOLLOW | COPYFILE_EXCL | COPYFILE_UNLINK)) != 0 { print(NSError(domain: NSPOSIXErrorDomain, code: Int(errno))) } try! sourceFd.close() try! destinationFd.close() #else source.withCString { sourcePath in destination.withCString { destinationPath in let state = copyfile_state_alloc() defer { copyfile_state_free(state) } // var bsize = 16_777_216 // copyfile_state_set(state, UInt32(COPYFILE_STATE_BSIZE), &bsize) if copyfile(sourcePath, destinationPath, state, copyfile_flags_t(COPYFILE_ALL | COPYFILE_NOFOLLOW | COPYFILE_EXCL | COPYFILE_UNLINK)) != 0 { print(NSError(domain: NSPOSIXErrorDomain, code: Int(errno))) } } } #endif
0
0
384
Jan ’24
Cannot modify files outside my iOS app's sandbox. Permissions issue.
I'm developing an iOS app (latest Swift, iOS, Xcode versions atm of writing) which needs to rename audio files (and later modify its metadata) located anywhere (local storage, external storage, cloud, etc). I'm bringing my own question in StackOverflow but I'd like to know better from the source so I came here. The trouble comes when testing on a physical device while trying to rename a file in some folder On My iPhone, the app does as intended when testing on the Simulator. On my physical iPhone I get an error logged saying that I don't have the permissions to do that. “filename.mp3” couldn’t be moved because you don’t have permission to access “randomFolder". I did my googling and asked GPTs about it, learned about FileCoordinator, UIDocumentPickerViewController⁠, startAccessingSecurityScopedResource. I also saw a couple of videos that I cannot reference in this forum. Some code I have in place: This is the document picker which I then call from a .sheet on another View. struct DocumentPicker: UIViewControllerRepresentable { @Binding var newName: String @EnvironmentObject private var bookmarkController: BookmarkController func makeUIViewController(context: Context) -> UIDocumentPickerViewController { let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes) documentPicker.delegate = context.coordinator return documentPicker } func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) { print("updateUIViewController documentPicker") } func makeCoordinator() -> Coordinator { Coordinator(self, newName) } class Coordinator: NSObject, UIDocumentPickerDelegate { var parent: DocumentPicker var newName: String init(_ parent: DocumentPicker, _ newName: String = "") { self.parent = parent self.newName = newName } func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { // save bookmark print("documentPicker \(urls[0])") parent.bookmarkController.addBookmark(for: urls[0]) // Rename the file var error: NSError? NSFileCoordinator().coordinate(readingItemAt: urls[0], options: [], error: &error) { coordinatedURL in do { // let data = try Data(contentsOf: newURL) print("urls[0]: \(urls[0])") print("coordinatedURL: \(coordinatedURL)") print("renamedURL: \(newName)") try renameFile(at: coordinatedURL, to: newName) } catch { print("Error: \(error.localizedDescription)") } } } } } Renaming function: /// Rename selected file from browser func renameFile(at fileURL: URL, to newName: String) throws { let fileExtension = fileURL.pathExtension let directory = fileURL.deletingLastPathComponent() // Create a new URL with the updated name and the original extension let renamedURL = directory.appendingPathComponent(newName).appendingPathExtension(fileExtension) try FileManager.default.moveItem(at: fileURL, to: renamedURL) } I have a BookmarkController in place so that my URLs are bookmarked for later use. Here it is: import SwiftUI import MobileCoreServices class BookmarkController: ObservableObject { @Published var urls: [URL] = [] init() { loadAllBookmarks() } func addBookmark(for url: URL) { print("adding bookmark for \(url)") do { guard url.startAccessingSecurityScopedResource() else { print("Failed to obtain access to the security-scoped resource.") return } defer { url.stopAccessingSecurityScopedResource() } let bookmarkData = try url.bookmarkData(options: .minimalBookmark, includingResourceValuesForKeys: nil) let uuid = UUID().uuidString try bookmarkData.write(to: getAppSandboxDir().appendingPathComponent(uuid)) urls.append(url) } catch { print("Error Adding Bookmark: \(error.localizedDescription)") } } func loadAllBookmarks() { // Get all the bookmark files let files = try? FileManager.default.contentsOfDirectory(at: getAppSandboxDir(), includingPropertiesForKeys: nil) // Map over the bookmark files self.urls = files?.compactMap { file in do { let bookmarkData = try Data(contentsOf: file) var isStale = false // Get the URL from each bookmark let url = try URL(resolvingBookmarkData: bookmarkData, bookmarkDataIsStale: &isStale) guard !isStale else { // Handle stale bookmarks return nil } print("loaded bookmark: \(url)") // Return URL return url } catch { print("Error Loading Bookmark: \(error.localizedDescription)") return nil } } ?? [] } private func getAppSandboxDir() -> URL { // TODO ver 0 index FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] } } When running on my device, I see url.startAccessingSecurityScopedResource throwing: Failed to obtain access to the security-scoped resource. I have also tried getting access to the parent directory like this: let parentURL = url.deletingLastPathComponent() and then using parentURL instead, but it also fails. Something I noticed is that my app is not shown in the Settings -> Privacy & Security -> Files and Folders list. My app didn't trigger any dialog to be added here given user consent. Fiddling with entitlements in Info.plist and Capabilities did not help either, but I'm not so sure about which ones should I add. So: Could it be that the problem I'm seeing about permissions and my app not appearing at the Files and Folders privacy settings on my iPhone are because my app is signed with a developer account which is not in the apple developer program? this is my last thought since I'm not understanding what else should I try. Any pointers and help will be much appreciated. Thanks!
3
0
603
Jan ’24
[iOS] AVPlayer won't play file after some time
I download a mp4 file into the date folder. I am able to run an AVPlayer and view the video in the app. After some time video won't play. If I enable UIFileSharingEnabled and check if file exists, I can see it's there but then it won't play even from accessing it through Files. If I copy the file from iOS to Mac then I can pay the video on Mac, but not anymore on iOS. If I delete the app, install again and download the video while UIFileSharingEnabled and if it's played in the app it can be played in the Files app, but again after some time it's not playable again... I can see only first frame. I can even see the length of video. It happens to multiple videos. Any clues?
3
0
545
Jan ’24
FileManager.enumerator and URL problem
I have the following pseudo code: func load(at packageURL: URL) { let realPackageURL = packageURL.resolvingSymlinksInPath() guard let it = fileMan.enumerator(at: realPackageURL) for case let fileURL as URL in it { print(fileURL) // Get filename relative to package root directory let relativeFileName = String(filePath.suffix(filePath.count - packagePath.count)) } } When called with "file:///tmp/some.app", the enumerated fileURL is actually file:///private/tmp/GIMP.app/Contents/ packageURL.resolvingSymlinksInPath() actually does nothing, I assume /tmp is a hard link. This makes it impossible to get a correct relative path. Is there any remedy for this?
2
0
379
Jan ’24
SQLite can't create database outside of "Application Support"
I have an application that takes XML data and converts it into database tables. It uses SQLite3 and SQLCipher. If I hard code the path to save the database to put it in my Application Support folder, it works perfectly -- creates the file (with [fm createFileAtPath: newPath contents: nil attributes: nil];) and then opens it with SQLite, it creates the tables and populates them, everything works as expected. If, however, I allow the user to save the database in the location of their choice, say in Documents or Downloads, the application creates the file (with createFileAtPath) but then when SQLite tries to create the tables, it fails with the error "unable to open database file" and error code 14 (which is a generic "couldn't open database" error.) Looking in the save directory, there is now a zero bytes file in that location. Everything that I've seen online indicates that this is a permissions/security issue, but no one seems to point to a solution -- I went so far as to put in code to run chmod on the database and the folder that it's in, even that didn't help. Your input is very much appreciated!
2
0
339
Jan ’24
Inferring High-Level Semantics from Low-Level Operations
This is a topic that comes up regularly, both in my Day Job™ with DTS and here on DevForums. This situation is a bit subtle, and it’s long past the time I should have written a proper explanation of it. If you have questions or comments, put them in a new thread here on DevForums. To ensure that I see your thread, tag it based on the technology you’re using. For example: If you’re working with Endpoint Security, use the Endpoint Security tag. If you’re building a Network Extension provider, use the Network Extension tag. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Inferring High-Level Semantics from Low-Level Operations Apple supports a number of APIs that let you observe low-level operations. For example: An Endpoint Security (ES) client can learn about low-level file system operations, like open and close. A Network Extension (NE) filter provider can learn about outgoing and incoming network packets. Folks using these APIs often want to infer high-level semantics from these low-level operations. For example: An ES client might want to prevent the Finder from copying files to an external drive. An NE filter provider might want to block Safari from fetching specific URLs. While DTS supports these APIs, we don’t support this sort of low-to-high inference. That’s because our goal is to help developers use Apple’s APIs in a sustainable way, and it’s impossible to do this inference in a way that will be binary compatible in the long term. Let me illustrate this with an example. Consider the NE scenario above. It’s easy for an NE packet filter to drop packets being sent to a specific host. However, that approach is very brittle. If something changes in the implementation path from Safari requesting a URL to how that’s rendered as IP packets, your product will break. A great example of such a change is iCloud Private Relay. This isn’t to say that such inference can’t be done at all, just that it’s not possible to do it in a sustainable way. Given that, here’s my advice: Try to work with high-level operations where possible. For example, ES recently added high-level log in and log out notifications, which means you no longer need to infer such events from lower-level ones. If the system doesn’t support the necessary high-level operations, file an enhancement request that describes your requirements. In the meantime, you can have a go at doing this inference yourself, but be aware that DTS can’t support you in that task.
0
0
393
Jan ’24
How detect cyclic symbolic links using NSFileManager?
My code is crashing Xcode (or even macOS kernel) during debugging - Xcode just vanishes from screen! // pseudo code public func hunt(in directory: URL) { let fileIterator = fileMan.enumerator(at: directory) // collect app packages into a list var packages = [URL]() for case let fileURL as URL in fileIterator { if fileURL.pathExtension == "app" { packages.append(fileURL) } } // FileWrappers var wrappers = [FileWrappers]() for packageURL in packages { //!!! The line below eventually crashes Xcode (or even macOS kernel once)! wrappers[packageURL] = try? FileWrapper(url: packageURL, options: .immediate) // NOTE: I need FileWrapper.matchesContents later in some code } } // unit test case func test() {} myObj.hunt(in: URL(fileURLWithPath: "/Applications")) } I suspect that the FileWrapper constructor is traversing directories and encounter cyclic symbolic links and eventually it crashes; since it's running at system runtime level, most probably it also crashes macOS kernel! So my question is that is there any way to detect cyclic symbolic links so that I can design my own logics similar to FileWrapper?
2
0
346
Jan ’24
Swift Playgrounds version of 'Copy Bundle Resources' build phase
Hi! I'm participating in the Swift Student Developer competition this year, which requires developers to present a Swift Playground to Apple. I'm used to making normal Xcode projects, and am having trouble finding a Swift Playgrounds version of the Copy Bundle Resources build phase (I don't think it is possible to edit build phases in a Swift Playground). I created a '.usdz' file from a 3D model I designed using Reality Converter and added it to the root of my Swift Playground project. I access the file programmatically from the App Bundle like so (fileName is a non-nullable String): guard let path = Bundle.main.path(forResource: fileName, ofType: "usdz") else { fatalError("Couldn't find the USDZ file.") } At runtime, this throws the Couldn't find the USDZ file error, as the file isn't being copied to the App Bundle. In a normal Xcode project, according to this StackOverflow question, I can get xcodebuild to copy my file over by specifying it in the Copy Bundle Resources build phase, however, in a Swift Playground (required by Apple), I am restricted from modifying Xcode's buildphases (the option is not present when clicking on the default target - the only options are General, Signing & Capabilites and Package Dependencies). How can I ensure that resources are copied over to the App Bundle at buildtime in a Swift Playground? If this is not possible, are there any other options besides using the Bundle.main.path API for accessing the USDZ file (to load a QuickLook preview) at runtime?
2
0
821
Jan ’24
Opening unknown filetypes on iPhone/iOS
Hey all, I'm using .NET MAUI's FilePicker to open a custom binary (assume a MIME type of application/octet-stream, with a .bin extension). FilePicker.Default.PickAsync works fine on all platforms (in my case, Windows, Android, MacCatalyst and iOS). I subsequently create a FileStream with the returned path (with FileMode.Open, FileAccess.Read). This works fine on Windows, Android, and MacCatalyst, but fails on iOS (for my Mac setup, I'm running VS Code on my MacBook and debugging my app on my iPhone 14 Pro attached via USB). On iOS, I wind up with an UnauthorizedAccessException whenever I try and create said FileStream object with the path to the binary file. Now, if I select a known filetype (say, an XML file) with FilePicker, then the FileStream object gets created successfully on all platforms. Obviously my binary is an unknown type, and I came to understand that, on iOS, I have to explicitly identify unknown file types in Platforms/iOS/Info.plist in order to open them. So I did that as follows: <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>CustomBinary</string> <key>CFBundleTypeRole</key> <string>Editor</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.mycompanyname.myappname.bin</string> </array> </dict> </array> <key>UTImportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>CustomBinary</string> <key>UTTypeIconFiles</key> <array/> <key>UTTypeIdentifier</key> <string>com.mycompanyname.myappname.bin</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>bin</string> <string>BIN</string> </array> <key>public.mime-type</key> <array> <string>application/octet-stream</string> </array> </dict> </dict> </array> Unfortunately, I still get the same exception. I've been spinning my wheels for several days now, and so just wanted to reach out to see if anyone with more iOS insight than I had an idea of how to solve this problem. The binary file itself is on my iPhone itself (i.e., it's in "Files->On My Phone"). Any help is appreciated! Wes
0
0
351
Jan ’24
Access file from File app works inside my application, but doesn't work if I launch my app from the File app
Hi! I've got an application that can handle json (export/import). To achieve that I created a new Document Type in the info.plist, filed the imported and exported Type Identifiers, and created a new UTType. At first I was trying on the simulator and everything worked fine. I was able to created files and store them in the File app, and then read them back. I also implemented the func scene(_ scene: UIScene, openURLContexts URLContexts: Set&lt;UIOpenURLContext&gt;) to handle documents opened from outside the application. Now when I moved on onto a real device, I noticed that I had to test the access with guard url.startAccessingSecurityScopedResource() else { throw ImportError.accessDenied } defer { url.stopAccessingSecurityScopedResource() } but I get a weird behavior : when opening a file from File app with my app launched, everything works fine. But if I try to launch my application (previously killed) from a file in the File app, startAccessingSecurityScopedResource always returns false I tried to add the NSFileCoordinator().coordinate(readingItemAt: url, error: &amp;error) { (url) in but I get the same behavior. I guess my files and UTType are correctly declared as I only see them from inside the `UIDocumentPickerViewController`` and from the File app, I see my application in the share sheet What am I missing here ? Thanks
1
0
935
Jan ’24
How to have JS Website interact with a mutable file
I learned that I can't have a file inside the bundle if I want it to be able to be changed while the app is running. If I have a file stored outside, how could I let an HTML website access that JS file? I'm using WKWebView to run a local website. The JS would need to be accessible by the website before it loads, because it is a configuration file that is needed on load.
0
1
310
Dec ’23
Difference between vfsStruct.f_fsid and fstat.st_ino ?
Hello, Anyone know of relevant documentation that captures the difference between vfsStruct.f_fsid and fstat.st_ino ? sys/stat.h declares: ino_t st_ino; /* [XSI] File serial number */ AND sys/statvfs.h declares: unsigned long f_fsid; /* Filesystem ID */ Based on some tests, it seems that the st_ino is the number/inode_number that the filesystem identifies the file-resource by ? I observed that this number gets a unique value when I copy a file even when the Finder/FS utilizes the Space-Saver feature of MacOS. This value is identical to the results returned by the command ls "-i" . When copying via Finder, I am seeing distinct st_ino values for source and destination files. f_fsid seems to be identifying the File differently though, perhaps taking into account what Data/attributes objects the file resource points to ? I observed that this number gets an identical value when I copy a file even when the Finder/FS utilizes the Space-Saver feature of MacOS. So, the value of f_fsid seems to be copied over to the destination file record. Also, I could not find a way to display f_fsid via the ls command. On a related note, Any documentation regarding MacOS Finder/FS's Space-Saver feature or how it is implemented ? Thanks, Vikram.S.Warraich
6
0
704
Jan ’24
Application Open URL not firing
In my Iphone app, I want to open json files that I have earlier saved. The function I mention below to open the file is not firing when I share a file to my app. I have implemented this in the info.plist file and this seems to work, because in Files I can share a .json file to may app. &lt;key&gt;CFBundleDocumentTypes&lt;/key&gt; &lt;array&gt; &lt;dict&gt; &lt;key&gt;CFBundleTypeName&lt;/key&gt; &lt;string&gt;JSON Document&lt;/string&gt; &lt;key&gt;LSHandlerRank&lt;/key&gt; &lt;string&gt;Alternate&lt;/string&gt; &lt;key&gt;LSItemContentTypes&lt;/key&gt; &lt;array&gt; &lt;string&gt;public.json&lt;/string&gt; &lt;/array&gt; &lt;/dict&gt; &lt;/array&gt; I have added the function to open the file in my AppDelegate file. func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -&gt; Bool { // Handle the file at the given URL // You can perform actions based on the file type or content print("Opening file!") } (the implementation is actually longer to work on the file). When I share a file to my app, the app itself is opening but this method 'application' is never called. I'm not sure whether I'm overlooking something. I have searched quite a while to see what I'm missing. Any help is greatly appreciated! Emile
1
0
406
Dec ’23
Making filecopy faster by changing block size
I'm using the filecopy function to copy many files and I noticed that it always takes longer than similar tools like cp or a Finder copy (I already did a comparison in my other post). What I didn't know before was that I can set the block size which apparently can have a big influence on how fast the file copy operation is. The question now is: what should I consider before manually setting the block size? Does it make sense to have a block size that is not a power of 2? Can certain block sizes cause an error, such as a value that is too large (for the Mac the code is running on, or for the source and target devices)? When should or shouldn't I deviate from the default? Is there a way to find out the optimal block size for given source and target devices, or at least one that performs better than the default? In the following sample code I tried to measure the average time for varying block sizes, but I'm not sure it's the best way to measure it, since each loop iteration can have wildly different durations. class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_ aNotification: Notification) { let openPanel = NSOpenPanel() openPanel.runModal() let source = openPanel.urls[0] openPanel.canChooseDirectories = true openPanel.canChooseFiles = false openPanel.runModal() let destination = openPanel.urls[0].appendingPathComponent(source.lastPathComponent) let date = Date() let count = 10 for _ in 0..&lt;count { try? FileManager.default.removeItem(at: destination) do { try copy(source: source, destination: destination) } catch { preconditionFailure(error.localizedDescription) } } print(-date.timeIntervalSinceNow / Double(count)) } func copy(source: URL, destination: URL) throws { try source.withUnsafeFileSystemRepresentation { sourcePath in try destination.withUnsafeFileSystemRepresentation { destinationPath in let state = copyfile_state_alloc() defer { copyfile_state_free(state) } // var bsize = Int32(16_777_216) var bsize = Int32(1_048_576) if copyfile_state_set(state, UInt32(COPYFILE_STATE_BSIZE), &amp;bsize) != 0 || copyfile_state_set(state, UInt32(COPYFILE_STATE_STATUS_CB), unsafeBitCast(copyfileCallback, to: UnsafeRawPointer.self)) != 0 || copyfile_state_set(state, UInt32(COPYFILE_STATE_STATUS_CTX), unsafeBitCast(self, to: UnsafeRawPointer.self)) != 0 || copyfile(sourcePath, destinationPath, state, copyfile_flags_t(COPYFILE_ALL | COPYFILE_NOFOLLOW | COPYFILE_EXCL)) != 0 { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) } } } } private let copyfileCallback: copyfile_callback_t = { what, stage, state, src, dst, ctx in if what == COPYFILE_COPY_DATA { if stage == COPYFILE_ERR { return COPYFILE_QUIT } var size: off_t = 0 copyfile_state_get(state, UInt32(COPYFILE_STATE_COPIED), &amp;size) let appDelegate = unsafeBitCast(ctx, to: AppDelegate.self) if !appDelegate.setCopyFileProgress(Int64(size)) { return COPYFILE_QUIT } } return COPYFILE_CONTINUE } private func setCopyFileProgress(_ progress: Int64) -&gt; Bool { return true } }
14
1
889
Jan ’24
Problems with csv-Import
I want to import a csv-file to my app. It works when I use the Simulator but when I try to import the same file on my iPad, the follwowing message occurs: UserInfo={NSFilePath=/private/var/mobile/Containers/Shared/AppGroup/4C49BACA-5490-45A4-A8DF-6D47711CFC34/File Provider Storage/LUSD 3.csv, NSUnderlyingError=0x2812068e0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}. Where do I find the right settings to enable the import of this csv-file?
2
0
572
Dec ’23
Getting metadata (identity) about an SMB volume's server
I like to find a way to identify network volumes, and whether they're run by certain servers, e.g. specifically whether they're on a Synology NAS. Reason is that Synology, while apparently supporting the Spotlight-over-SMB API, comes with a lot of bugs, requiring me to work around them when searching on those volumes with the macOS Spotlight API. I could, of course, ask the user to "configure" each mounted volume in my software, but I'd rather do this automagically, if possible, as it's less prone to user mistakes. So, my question is: Is there a way to learn a bit more about the server of a mounted network volume? E.g., if I could learn its IP address, I could try to connect to it via http protocol and then maybe get a useful response that identifies it as being from Synology. Or, alternatively, can I tell which SMB volumes are served by a Mac, so that I can at least assume that those handle Spotlight calls correctly, while I assume anything else is buggy (so far, AFAIK, Synology is the only other SMB server that supports Spotlight search). I've tried to find some data in the IORegistry, but that doesn't seem to store anything about network vols. The statfs function doesn't seem to give me anything for that either, nor do the various fcntl calls as far as I could tell. I also checked with the DA apis, e.g.: DASessionRef daSession = DASessionCreate (NULL); CFURLRef furl = CFURLCreateWithFileSystemPath(NULL, CFSTR("/Volumes/TheNAS"), kCFURLPOSIXPathStyle, true); DADiskRef daDisk = DADiskCreateFromVolumePath (NULL, daSession, furl); if (daDisk) { CFDictionaryRef daInfo = DADiskCopyDescription (daDisk); NSLog(@"%@", daInfo); } However, this only prints basic information: DAVolumeKind = smbfs; DAVolumeMountable = 1; DAVolumeName = TheNAS; DAVolumeNetwork = 1; DAVolumePath = "file:///Volumes/TheNAS/"; Where, then, does Finder's "Get Info" get the smb path from, for example?
8
0
959
May ’24