• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Trouble with FSMountServerVolumeSync
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trouble with FSMountServerVolumeSync


  • Subject: Trouble with FSMountServerVolumeSync
  • From: email@hidden
  • Date: Wed, 07 Sep 2005 04:40:13 +0000

So, I am trying to mount a volume programmatically.  I understand the easiest way to do this under OS X is to use FSMountServerVolumeSync.  I do not want to fork a process and do mount_afp, because I want the refnum so I can eject the drive later.

So here is the command:
OSStatus FSMountServerVolumeSync (
   CFURLRef url,
   CFURLRef mountDir,
   CFStringRef user,
   CFStringRef password,
   FSVolumeRefNum * mountedVolumeRefNum,
   OptionBits flags
);

If I pass NULL for mountDir the command works perfectly under Tiger, but fails with a -36 under Panther.  Therefor my assumption is I need to fill this in with something valid.  Below is my feeble and obviously incorrect attempt, because I get the same error:
-(OSErr)MountAFPVolume:(NSString *) m_serverAddress :(NSString *)m_volumeName :(NSString *) m_userName
	:(NSString *) m_passWord :(FSVolumeRefNum *)refNum
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

	NSFileManager *fileManager = [[NSFileManager defaultManager] autorelease];

	NSString *pathToMount = [[[NSString alloc] initWithFormat:@"/Volumes/%@", m_volumeName] autorelease];

	if ([fileManager fileExistsAtPath:pathToMount] == NO)
	{
		[fileManager createDirectoryAtPath:pathToMount attributes: nil];
	} else
	{
		NSLog(@"The mount location already exists!");
		[pool release];
		return;
	}

	NSString *urlStringOfVolumeToMount = [[[NSString alloc] initWithFormat:@"afp://%@:%@@%@/%@", m_userName, m_passWord, m_serverAddress, m_volumeName] autorelease];

	OSErr error;

	CFURLRef CFUrl = CFURLCreateWithFileSystemPath( kCFAllocatorDefault, (CFStringRef) urlStringOfVolumeToMount, kCFURLPOSIXPathStyle, TRUE);
	CFURLRef CFMountPath = CFURLCreateWithFileSystemPath( kCFAllocatorDefault, (CFStringRef) pathToMount, kCFURLPOSIXPathStyle, TRUE);

	CFStringRef CFusername = (CFStringRef) m_userName;
	CFStringRef CFpassword = (CFStringRef) m_passWord;

	error = FSMountServerVolumeSync(CFUrl, CFMountPath, CFusername, CFpassword, refNum, FALSE);

	[pool release];

	return error;
}

Any ideas?  Also any clue why it works fine on Tiger and fails on Panther?

Thanks,
Kris
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: [cocoa scripting] getting script class attribute name
  • Next by Date: Cocoa Controls
  • Previous by thread: Re: mousedown in a view
  • Next by thread: Cocoa Controls
  • Index(es):
    • Date
    • Thread