Re: psql \i handling ~ in specified file name - Mailing list pgsql-patches

From Andrew Dunstan
Subject Re: psql \i handling ~ in specified file name
Date
Msg-id 1664.24.211.141.25.1072020143.squirrel@www.dunslane.net
Whole thread Raw
In response to Re: psql \i handling ~ in specified file name  (Zach Irmen <zirmen@shaw.ca>)
List pgsql-patches
Zach Irmen said:
> "Tom Lane" <tgl@sss.pgh.pa.us> writes:
>> What happens if getenv("HOME") returns NULL?
>
> Yeah, the strdup fails. I'll take it out to fix that.
>
>> You also need to think about Windows
>
> Can I just ifndef WIN32 and not think about it? I'm not sure how that
> would work either.
>

If we are going to have a Windows port I don't think we should treat it as
a poor cousin.

This information is easily discoverable on MSDN in 5 minutes. The answer
is that you need to call NetUserGetInfo at level 11 to get a user's home
directory. See
http://msdn.microsoft.com/library/en-us/dnucmg/html/ucmgch09.asp and
http://msdn.microsoft.com/library/en-us/netmgmt/netmgmt/netusergetinfo.asp

(Thinks: using this requires linking with NetAPI32.dll - is that a legal
or practical problem for us?)

Also, I strongly recommend that the name be canonicalised - see initdb.c
for an example. Doing this reduces platform-specific code a lot. Windows
is quite able to handle filenames with a forward slash.

(Thinks again: when we have WIN32 done we need to trawl through the code
to try to abstract out as much as possible, so that people who
don't/won't/can't do Windows specific code won't have to bother.)

cheers

andrew



pgsql-patches by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: [GENERAL] Temporary tables and miscellaneous schemas
Next
From: "Magnus Hagander"
Date:
Subject: Re: psql \i handling ~ in specified file name