来自FSCopyURLForVolume的完整网址

编程入门 行业动态 更新时间:2024-10-27 22:31:01
本文介绍了来自FSCopyURLForVolume的完整网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我遇到了一个问题,获取一个文件的完整网址 FSCopyURLForVolume 。我正在使用此问题的代码从文件URL确定AFP共享但它不给我完整的网址。例如:

使用以下路径: /Volume/server/html/index.html

所有我回来的是url到基本mount: nfs:// real_server_name / vol

叶子目录和文件名已被关闭,完整路径在文件信息中可用,因此必须有一种方法来获取此信息。

编辑:

经过一些挖掘似乎想使用 kFSCatInfoParentDirID 和 kFSCatInfoNodeID 来获取父节点和节点(文件)id,但我不知道如何将它变成有用的东西。

<因为FSPathMakeRef,FSGetCatalogInfo和FSCopyURLForVolume已从Mac OS X 10.8中弃用。我现代化了Mac OS X挂载卷上的UNC网络路径的代码。

NSError * error = nil; //错误 NSURL * volumePath = nil; // result of UNC network mounting path NSString * testPath = @/ Volumes / SCAMBIO / testreport.exe; //文件路径测试 NSURL * testUrl = [NSURL fileURLWithPath:testPath]; //从文件路径创建NSURL NSString * mountPath = [testPath stringByDeletingLastPathComponent]; //只获取加载的卷部分,即/ Volumes / SCAMBIO NSString * pathComponents = [testPath substringFromIndex:[mountPath length]]; //获取在加载路径后开始的其余路径,即/testereport.exe [testUrl getResourceValue:& volumePath forKey:NSURLVolumeURLForRemountingKey error:& error]; //获取真正的UNC网络路径,即smb:// .... NSLog(@Path:%@%@,volumePath,pathComponents); //将结果写入调试控制台

结果是在我的case,路径: strong> smb://FRANCESCO@192.168.69.44/SCAMBIO/testreport.exe

您需要指定网络映射卷。

ciao。

I am running into an issue getting the full url for a file with FSCopyURLForVolume. I am using the code from this issue Determine AFP share from a file URL but it isn't giving me the full url. For example:

With a path like: /Volume/server/html/index.html

All I get back is url to the base mount: nfs://real_server_name/vol

Leaf directories and the file names are left off, the full path is available in the files info so there has to be a way to get this information.

EDIT:

After some more digging is seems like I want to use kFSCatInfoParentDirID and kFSCatInfoNodeID to get the parent and node(file) id but I'm not sure how to turn this into something useful.

解决方案

because the FSPathMakeRef, FSGetCatalogInfo and FSCopyURLForVolume are deprecated from Mac OS X 10.8 I modernised the code for get UNC network path on Mac OS X mounted volumes.

NSError *error=nil; //Error NSURL *volumePath=nil; //result of UNC network mounting path NSString* testPath =@"/Volumes/SCAMBIO/testreport.exe"; //File path to test NSURL *testUrl = [NSURL fileURLWithPath:testPath]; //Create a NSURL from file path NSString* mountPath = [testPath stringByDeletingLastPathComponent]; //Get only mounted volume part i.e. /Volumes/SCAMBIO NSString* pathComponents = [testPath substringFromIndex:[mountPath length]]; //Get the rest of the path starting after the mounted path i.e. /testereport.exe [testUrl getResourceValue:&volumePath forKey:NSURLVolumeURLForRemountingKey error:&error]; //Get real UNC network mounted path i.e. smb://.... NSLog(@"Path: %@%@", volumePath,pathComponents); //Write result to debug console

The result is in my case, Path: smb://FRANCESCO@192.168.69.44/SCAMBIO/testreport.exe

You need to specify your network mapped volume.

ciao.

更多推荐

来自FSCopyURLForVolume的完整网址

本文发布于:2023-11-01 07:28:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1548666.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:完整   网址   FSCopyURLForVolume

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!