Re: Function to do runtime relative directory mapping

From: "Andrew Dunstan" <andrew(at)dunslane(dot)net>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Function to do runtime relative directory mapping
Date: 2004-05-06 11:50:09
Message-ID: 1659.24.211.141.25.1083844209.squirrel@www.dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-hackers-win32 pgsql-patches

Tony Reina said:
> pgman(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian) wrote in message > extern void
> canonicalize_path(char *path);
>> + #ifndef WIN32
>> + #define ISSEP(c) ((c) == '/')
>> + #else
>> + #define ISSEP(c) ((c) == '/' || (c) == '\\')
>> + #endif
>
>
> I've seen references to this "canonicalization" of the Windows \
> character for the win32 port. I don't claim to be a programming guru,
> but I recently read Jeff Cogswell's C++ for Dummies and he says (p. 546
> "Separating a path name") that you can use Unix-style / to
> separate directories in your programming and Windows will know what to
> do. In other words, you don't need \\ to separate directory names. /
> should work just fine.
>
> Perhaps MinGW and the gcc compiler on Windows behaves differently(?)
>
> Then again, perhaps there are other factors that I'm not considering.
>

It has nothing to do with the compiler - it's a function of the underlying
MSVCRT library. And you are correct. See initdb.c for an example - after
canonicalising it can and does happily use / as the separator. The only
trouble you have is in dealing with Windows command interpreters, when you
have to make sure that you quote the path (you have to do that anyway, as
the path might also include spaces).

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2004-05-06 12:06:10 Re: inconsistent owners in newly created databases?
Previous Message Vinay Jain 2004-05-06 08:47:49 Re: Is there any method to keep table in memory at startup

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Dave Page 2004-05-06 13:38:15 pg_autovacuum Win32 service patch
Previous Message Tony Reina 2004-05-06 08:22:45 Re: Function to do runtime relative directory mapping

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-05-06 12:07:34 Re: Dollar Quoting doc patch--resend.
Previous Message Tony Reina 2004-05-06 08:22:45 Re: Function to do runtime relative directory mapping