• 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
Re: Server Path URL question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Server Path URL question


  • Subject: Re: Server Path URL question
  • From: "Daniel Brieck Jr." <email@hidden>
  • Date: Fri, 17 Aug 2007 21:50:53 -0400

Hello all,

I have made some changes to incorporate CFURLCreateStringByReplacingPercentEscapes() into the program after taking a look at the CFURLref.pdf . I am getting the following error when I try to build it, and I am not sure why. I have to be missing something here. Is it possible that there is a type in- compatibility on CFStringRef path that I am passing in or is it something else?

getServerURL.m:32: error: parse error before 'CFAllocatorRef'

error is on this line (or close by)  in the implementation file:

//error line
noPercentsPath = CFURLCreateStringByReplacingPercentEscapes (CFAllocatorRef NULL , CFStringRef path, CFStringRef (CFSTR(" ")) );



Thank you, Daniel J. Brieck Jr.



------------------------------------------------------------------------ -------------------------------------------------------

#import <Cocoa/Cocoa.h>
#import <CoreFoundation/CoreFoundation.h>
#import <CoreServices/CoreServices.h>

@interface NSApplication (getServerURL)

- (NSString *) urlStringForServerVolume:(const char *) path;

@end

------------------------------------------------------------------------ -------------------------------------------------------

#import "getServerURL.h"


@implementation NSApplication (getServerURL)


- (NSString *) urlStringForServerVolume:(const char *) path { OSStatus err; FSRef ref; FSCatalogInfo catInfo; CFURLRef url; CFStringRef str; NSString * result;

       CFStringRef * noPercentsPath;



       assert(path != NULL);

// checking for any percent escape sequences and replacing them with their character equivalents
noPercentsPath = CFURLCreateStringByReplacingPercentEscapes (CFAllocatorRef NULL , CFStringRef path, CFStringRef (CFSTR(" ")) );


err = FSPathMakeRef( (const UInt8 *) noPercentsPath, &ref, NULL);
assert(err == noErr);
err = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
assert(err == noErr);
err = FSCopyURLForVolume(catInfo.volume, &url);
assert(err == noErr);
str = CFURLGetString(url);
assert(str != NULL);
result = [NSString stringWithString:(NSString *) str];
assert(result != nil);
CFRelease(url);


       return result;
}

@end
------------------------------------------------------------------------ -------------------------------------------------------
On Aug 17, 2007, at 1:24 PM, Becky Willrich wrote:


Jim's spotted the problem. More generally, if you have a URL and are trying to produce a path to go in to some file system call (like FSPathMakeRef(), or any of the Objective-C path: methods), you should use one of the URL routines with the words "FileSystem" in the name. All of these will do the correcting necessary to convert a URL path to a path suitable for the file system.

Hope that helps,
REW


On Aug 17, 2007, at 10:07 AM, Jim Luther wrote:

In a URI (URL), many characters are illegal that are legal in file system paths. Those characters are percent-encoded. See rfc3986 <http://www.ietf.org/rfc/rfc3986.txt> for the latest specification on URIs.

Some of the routines in CFURL replace percent-encoded characters, some don't. Depending on the routines you use to convert a URL to a string, you make have to percent-decode characters yourself. I think you need to use CFURLCopyFileSystemPath() which replaces percent-encoded characters.

- Jim

_______________________________________________ Do not post admin requests to the list. They will be ignored. Macnetworkprog mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: SMB CIFS AFP ETC... Server Path URL question (From: "Daniel Brieck Jr." <email@hidden>)
 >Re: SMB CIFS AFP ETC... Server Path URL question (From: Quinn <email@hidden>)
 >Re: Server Path URL question (From: "Daniel Brieck Jr." <email@hidden>)
 >Re: Server Path URL question (From: Jim Luther <email@hidden>)
 >Re: Server Path URL question (From: Becky Willrich <email@hidden>)

  • Prev by Date: Re: Developing drivers for a USB-based network device. . .?
  • Next by Date: Re: Developing drivers for a USB-based network device. . .?
  • Previous by thread: Re: Server Path URL question
  • Next by thread: SimpleDial & SCNetworkConnectionGetStatus
  • Index(es):
    • Date
    • Thread