Re: Detecting shared folders

2010-11-20 Thread Greg Nelson
Via the shell I can think of a couple ways to get the info:

If on a server:
sharing -l

Server or client
dscl . list /SharePoints
Take that list of share points and run this per sharepoint
dscl . read /SharePoints/sharepoint name 
directory_path

Hope this helps,
- Greg

On Nov 15, 2010, at 5:01 AM, Leo wrote:

 Hi,
 
 I wonder if it's possible to detect a shared folder? That is a folder that
 is shared via File Sharing.
 
 Am I missing something obvious?
 
 I couldn't find an appropriate folder attribute in either Cocoa or
 AppleScript. Or any other way to distinguish a shared folder from other
 folders.
 
 I also assume there must be a list of all shared folders in one of the Unix
 special directories. Or a way to retrieve it with a shell command. I did
 some extensive research, couldn't find anything.
 
 Any help would be appreciated!
 
 Thanks,
 Leo
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/nelsongreg%40gmail.com
 
 This email sent to nelsong...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Detecting shared folders

2010-11-18 Thread Leo

Greg and Ken:

Thanks a lot for answering my question about shared folders, that's exactly
what I needed!

Best,
Leo


 From: Greg Nelson nelsong...@gmail.com
 Date: Wed, 17 Nov 2010 00:01:24 -0500
 To: Leo le...@rogers.com, cocoa-dev@lists.apple.com
 Subject: Re: Detecting shared folders

 From: Ken Thomases k...@codeweavers.com
 Date: Wed, 17 Nov 2010 00:33:02 -0600
 To: Leo le...@rogers.com
 Cc: cocoa-dev@lists.apple.com
 Subject: Re: Detecting shared folders

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Detecting shared folders

2010-11-16 Thread Leo
Hi,

I wonder if it's possible to detect a shared folder? That is a folder that
is shared via File Sharing.

Am I missing something obvious?

I couldn't find an appropriate folder attribute in either Cocoa or
AppleScript. Or any other way to distinguish a shared folder from other
folders.

I also assume there must be a list of all shared folders in one of the Unix
special directories. Or a way to retrieve it with a shell command. I did
some extensive research, couldn't find anything.

Any help would be appreciated!

Thanks,
Leo
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Detecting shared folders

2010-11-16 Thread Ken Thomases
On Nov 15, 2010, at 4:01 AM, Leo wrote:

 I wonder if it's possible to detect a shared folder? That is a folder that
 is shared via File Sharing.

It would seem to be possible, since the Finder puts a banner in the window for 
shared folders.

 Am I missing something obvious?

Not obvious, no.

 I couldn't find an appropriate folder attribute in either Cocoa or
 AppleScript. Or any other way to distinguish a shared folder from other
 folders.

There are some flags in Carbon File Manager structures about file system items 
that are supposed to indicate the shared status, but they don't seem to be 
supported any longer.  I used Apple's FSMegaInfo to dump the info, as in:

/path/to/FSMegaInfo -vvv FSGetCatalogInfo -kFSCatInfoGettableInfo path


 I also assume there must be a list of all shared folders in one of the Unix
 special directories. Or a way to retrieve it with a shell command. I did
 some extensive research, couldn't find anything.

I doubt there's one single list.  It depends on the specific sharing protocol 
and the configuration of the server for that protocol.  I found that 
/etc/smb.conf includes /var/db/samba/smb.shares, and that file lists the shares 
in a manner which matches the settings in the Sharing preference pane.  
However, that would probably not apply if you don't share via SMB and only 
share via AFP.

Hmm.  I went hunting for the AFP configuration and think I did find the master 
list.  Try this command:

dscl /Local/Default -list SharePoints

Then, take one of the listed share points and do these on it:

dscl /Local/Default -read SharePoints/share point name
dscl /Local/Default -read SharePoints/share point name directory_path

Be sure to quote the share point name if it contains spaces or other characters 
that the shell will interpret.  Since the dscl command is just a front-end to 
Directory Services, there should be a way to do this directly via those APIs.

Some experimentation shows that these records are not modified as you enable 
and disable file sharing protocols or even all of file sharing.  So, you'd have 
to test if file sharing is even enabled before paying attention to them.  I 
believe that toggling file sharing servers on or off amounts to enabling and 
disabling the corresponding service in launchd.  So, I think you may be able to 
query their status with SMJobCopyDictionary() and the relevant identifier (e.g. 
com.apple.AppleFileServer or org.samba.smbd).

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com