Mail Archives: djgpp/1998/05/04/14:08:57
On Mon, 4 May 1998, Salvador Eduardo Tropea (SET) wrote:
> But that's much more simpler, in fact I'll use a simple routine to avoid this
> problem. Is just that we don't have to convert the first \\ to drive:/ if the
> first name belongs to a Novell server.
You can only do this if you are *sure* the double slash actually means the
UNC. An application can do that, but a general-purpose library function
cannot make such assumptions, since it doesn't know where did the file
name come from. For example, many Unix programs concatenate
dirname+"/"+filename, and if the directory is "/", you get two slashes in
a row. The DJGPP ports will do the same with backslashes, or you might
have "\\" converted to "//" by a program which blindly converts everything
to forward slashes, and only then passes the file names to library
functions. It's a mess.
> > many DOS calls don't support UNCs (so they *have* to be mapped).
>
> Well I didn't make any deep test, but I can open the files like this:
>
> fopen("\\SERVER\PATH\FILE.NAM","rb");
> fopen("\\server/path/file.nam","rb");
>
> Both under DOS and W95.
Under Windows, yes, but on MSDOS it depends on the redirector. Novell
generally supports it (because it intercepts DOS calls ahead of DOS), but
other redirectors typically don't support such names.
> I can workaround it, but the strange name comes just from _truename.
File names produced by _truename are not meant to be used as arguments to
other file-oriented library functions, precisely for this reason. Use
_fixpath if you need to pass the generated name to other functions.
_truename's primary purpose is to produce names which can be reliably
*compared* to other names, for example to decide whether two different
names actually refer to the same file.
If you have no choice but to use what _truename returns, you must do some
additional work to map the leading \\SERVER\PATH part back to the X:\
form. The usual way to achive that is to call _truename with "X:\" and
look at what it returns. Then you can combine the results of _truename
and _fixpath to a full name with a drive letter.
> We must take a look to the Novell's API, I guess is possible to know the name
> belongs to an attached server.
If you find a way to get this info from Novel API calls, please tell me.
I've looked several times for such a service, but in vain. It seems that
Novell redirector keeps this information internally but doesn't allow it
to be easily accessed.
> I'm just making: truename and then fixpath. The first to avoid problems in DOS
> when the user saves a file like this: "123456789.123". truename cuts the "9"
> but as a side effect converts the name in all upper case + back slashes, so I
> pass it to fixpath. Of course I'll just replace fixpath by my own function, but
> is a bad thing.
Using the trick above with passing X:\ to _truename, I think you can do
it more easily. But I agree that it's a mess. I just don't know any
good way out of it.
- Raw text -