Re: [Inkscape-devel] saving views
Using glib facilities, you can do this (assumes filename has been g_malloc()ed):
if (!g_path_is_absolute(filename)) { gchar *abs_filename, *current_dir;
current_dir = g_get_current_dir(); abs_filename = g_build_filename(current_dir, filename, NULL);
g_free(current_dir); g_free(filename); filename = abs_filename; }
Unfortunately this is not smart enough. If I open "../filename.svg", the resulting "absolute" pathname will have ".." in the middle. Which is why I was asking if there exists a smart absolute path function that normalizes paths. Or can't the OS return the absolute path of a given file?
_________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2f...
On Sat, 2003-12-20 at 21:12, bulia byak wrote:
Unfortunately this is not smart enough. If I open "../filename.svg", the resulting "absolute" pathname will have ".." in the middle. Which is why I was asking if there exists a smart absolute path function that normalizes paths. Or can't the OS return the absolute path of a given file?
I see. Good point. I don't think there are really any OS facilities for doing that, and certainly fewer portable ones.
Generally, you're just kind of expected to know what the rules for constructing a path are on your platform and do it yourself.
Sucks for cross-platform stuff.
The glib stuff I gave you at least take care of that much for you ... just they don't have anything for interpreting .. and friends.
There IS realpath(3), which is present at least on BSD and Linux and any SUSv2-conformant Unix, but I don't think that's more widely available despite being declared in stdlib.h (except on pre-libc6 Linux systems)...
-mental
On Dec 20, 2003, at 10:29 PM, MenTaLguY wrote:
On Sat, 2003-12-20 at 21:12, bulia byak wrote:
Unfortunately this is not smart enough. If I open "../filename.svg", the resulting "absolute" pathname will have ".." in the middle. Which is why I was asking if there exists a smart absolute path function that normalizes paths. Or can't the OS return the absolute path of a given file?
I see. Good point. I don't think there are really any OS facilities for doing that, and certainly fewer portable ones.
Generally, you're just kind of expected to know what the rules for constructing a path are on your platform and do it yourself.
Sucks for cross-platform stuff.
Hmmm... Java does have this.
Of course, they have two concepts. "Absolute", which includes the ".."s, and "Canonical", which does not.
The latter is what you want. Maybe we need to go add that to glib.
participants (3)
-
bulia byak
-
Jon A.Cruz
-
MenTaLguY