Joakim
Joakim

Reputation: 11978

Is there any cross platform file IO / path util library for C?

Is there some C library that implements platform independent version of path operations?

Some examples that come to mind:

There are of course platform specific versions of these, but they hardly ever do exactly the same thing leading to chaos trying to match behaviour across platforms.

And I mean C, not C++, so boost doesn't count.

Also if there is none, are there any good sources/examples of differences between platforms, and other useful information that can be used to write such a library?

Upvotes: 4

Views: 3001

Answers (3)

likle
likle

Reputation: 1797

I know this is a rather old question, but I have been looking for something like this and couldn't find anything. So I wrote one, cwalk (reference) - for anyone who still finds it useful! :-)

Upvotes: 4

Joakim
Joakim

Reputation: 11978

I found the Apache Portable Runtime Project (APR) which does a lot more than just file I/O and path operations. And is not tied to any project like Gnome.

Another project that has portable functions for this with a nice API is CZMQ with the zfile and zsys classes, although the library itself focuses on other things.

Upvotes: 0

unwind
unwind

Reputation: 399959

The ever-nice glib family (part of GTK+) has some, at least.

Note that some of the functions you're describing, such as "getting absolute path from relative one" assumes the existence of a current directory, which is how that resolution is typically done. It's not a very "pure" function, since it relies on external state. In Windows, with its "split file system", there is even one current directory per volume (e.g. one for C:\, one for A:\ if you have it, and so on) per process.

Upvotes: 3

Related Questions