以编程方式共享文件夹

时间:2011-08-23 17:03:33

标签: objective-c cocoa macos file-sharing

我有一个OS X应用程序,允许用户选择任何文件夹。我需要以某种方式在网络上共享所选的文件夹。我一直在研究如何使用Objective-C共享文件夹;什么都没有帮助。

1 个答案:

答案 0 :(得分:3)

如果您指的是内置(AFP / SMB)文件共享服务,则可以使用Open Directory framework编辑kODRecordTypeSharePoints类型的记录。最好的办法是检查添加共享点时系统偏好设置的作用,然后只复制该格式。您可以使用dscl来检查它,例如:

% dscl . -list /SharePoints
Previous iTunes Libraries
% dscl . -read '/SharePoints/Previous iTunes Libraries'
dsAttrTypeNative:afp_guestaccess: 1
dsAttrTypeNative:afp_name:
 Previous iTunes Libraries
dsAttrTypeNative:afp_shared: 1
dsAttrTypeNative:directory_path:
 /Users/nicholas/Music/iTunes/Previous iTunes Libraries
dsAttrTypeNative:ftp_name:
 Previous iTunes Libraries
dsAttrTypeNative:sharepoint_group_id: 33FBCB64-3B80-4E8E-A262-CC2D885A0B0E
dsAttrTypeNative:smb_createmask: 644
dsAttrTypeNative:smb_directorymask: 755
dsAttrTypeNative:smb_guestaccess: 1
dsAttrTypeNative:smb_name:
 Previous iTunes Libraries
dsAttrTypeNative:smb_shared: 1
AppleMetaNodeLocation: /Local/Default
RecordName:
 Previous iTunes Libraries
RecordType: dsRecTypeStandard:SharePoints

dscl也有一种互动模式,对探索更有用。