We help IT Professionals succeed at work.

Anyone know of a library of functions for manipulating file paths ?

cweeks
cweeks asked
on
Hello,

I am looking for a set of functions written in C for manipulating file paths. Functions that could do the following would be nice.

Can tidy dir/.. occurances from paths
Convert absolute to relative
Convert relative to absolute
Tell if a path was absolute of relative
Return the file name portion
Return the path portion

And be cross platform, ie work on both linux and windows. I know it is asking a lot, but other languages such as Python have it built in, and it is available as a cpan module for perl.

Thanks in advance.
Comment
Watch Question

Commented:
There are no standard (ANSI C) functions to do that because an ANSI C program can be compiled and run on an OS that has no concept of path names, not to mention absolute/relative.

*Some* environments (e.g., Windows) provide functions to do what you need.  Check <stdlib.h> for the following (possibly without the leading underscore):
  _fullpath
  _makepath
  _splitpath

If you are compiling for Windows, you can use the following Win32 APIs:
  GetFullPathName
  GetLongPathName
  GetShortPathName
  GetVolumePathName
CERTIFIED EXPERT
Top Expert 2006

Commented:
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:
PAQed with A grade to alexo

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Sunny
EE Cleanup Volunteer

Explore More ContentExplore courses, solutions, and other research materials related to this topic.