• 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: Relative file path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Relative file path


  • Subject: Re: Relative file path
  • From: j o a r <email@hidden>
  • Date: Mon, 24 Mar 2003 07:26:17 +0100

Look at NSURL, it has a couple of methods to work with relative path references (Yes, you can use NSURL also for local file paths).

When adding a new file, check it's relation to your "current file's directory" and then use this method to create the url to the new file relative to that using:
+ (id) URLWithString:(NSString *) URLString relativeToURL:(NSURL *) baseURL

If your question is how to find out where some file and your "current file's directory" intersect, you could look at [theURL absoluteString] for both url's and use this method of NSString to find the first point where they differ:
- (NSString *) commonPrefixWithString:(NSString *) aString options:(unsigned) mask

j o a r

Ps. Don't cross post!

On Monday, Mar 24, 2003, at 06:43 Europe/Stockholm, Ryan Zachary Hale wrote:

For my program, I have the user select a file, and I get the path. Currently, this is a absolute path, but I want to get the path relative to the current file's directory. So if I have the user select, for example, a CSS file to add to an HTML document, the link placed in the HTML code would reflect the path from the current document (like index.html).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Relative file path (From: Ryan Zachary Hale <email@hidden>)

  • Prev by Date: Re: How to get PrivateFramework's URL
  • Next by Date: Re: Newbie (EXE_BAD_ACCESS?)
  • Previous by thread: Relative file path
  • Next by thread: Does anyone have OpenStep 4.2?
  • Index(es):
    • Date
    • Thread