On 12 February 2010 07:50, OvermindDL1 <overminddl1@gmail.com> wrote:
On Thu, Feb 11, 2010 at 4:36 PM, Paul <elegant_dice@yahoo.com> wrote:
>
>
> On 11 February 2010 06:19, OvermindDL1 <overminddl1@gmail.com> wrote:
>>
>> On Wed, Feb 10, 2010 at 7:21 AM, Paul <elegant_dice@yahoo.com> wrote:
>
> This sounds like interacting with many C programs that open files could be a
> big problem...
>
> Take for example, zlib
> http://zlib.net/manual.html#Gzip
>
> fs::wpath my_path = whatever;
>
> gzFile f = gzopen( my_path.NARROW(), "r" );
>
> ??
>
> In zlib's case, I might be saved because I can call gzopen on a
> file-descriptor, but there are other libraries (one of which I am using)
> that will only accept a char* filename...
>
> What do I do?

You should submit a patch to fix those libraries to accept a file
handle instead of a file name, file handles are universal and work
properly everywhere, but yes, the C function calls can break horribly
on, say, a Japanese regional Windows computer (of which one of my
friends is and has set up, I love testing my programs on it to make
sure they still work).  Any library that accepts only 8-bit character
filenames is broken, they did not take into account regionalization at
all and need patches to be fixed (hence they should have something
that accepts a file handle since those *always* work, or at the very
least accept wide and narrow filenames).

But yes, do know that Windows 2000 and higher uses wchar natively for
*ALL* filesystem functions so it can support regionalization.


Ok so ... I have a wpath, and an interface that looks something like this:

xyz.openFile( const char* name );
xyz.openFileDesc( int fd );
xyz.openFileHandle( FILE * file );

How do I go from a wpath to a filedescriptor?
This doesn't work:

fs::ifstream file( path );
xyz.openFileDesc( file.fd() );

?  I've Googled with no luck...

thanks,
Paul