• 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: Absolute Paths
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Absolute Paths


  • Subject: Re: Absolute Paths
  • From: RR <email@hidden>
  • Date: Sat, 25 May 2002 21:37:48 -0400

On Saturday, May 25, 2002, at 08:12 PM, email@hidden wrote:

I am stepping through a directory and picking certain files, but the paths
that are returned to me are relative. Is there anyway I can get the absolute
path of the file? I could attach the relative path to the guaranteed absolute
path of the directory, but I still want to know if there is a direct way to
get the absolute path of the file. Thank you.

I don't know if there's a Cocoa magic bullet for you here, but you could choose to do this using the Unix system call getcwd(). Type "man 3 getcwd"
in your command prompt for all the details. It returns the full path of the current working directory. This of course requires that the process calling getcwd() be currently running in the directory for which you require the full path.

#include <unistd.h> /* for getcwd() */
#include <stdlib.h> /* for malloc() */
#include <sys/param.h> /* for MAXPATHLEN */

char *path;

path = malloc(MAXPATHLEN);
getcwd(path, MAXPATHLEN);

You can then prepend the contents of the path variable into your relative paths. (Remember to free() path after you're finished with it.)

RR
_______________________________________________
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.

  • Follow-Ups:
    • Re: Absolute Paths
      • From: Ondra Cada <email@hidden>
References: 
 >Absolute Paths (From: email@hidden)

  • Prev by Date: Re: NSTimer and deep sleep
  • Next by Date: Re: Absolute Paths [Thank You]
  • Previous by thread: Absolute Paths
  • Next by thread: Re: Absolute Paths
  • Index(es):
    • Date
    • Thread