[M3devel] win32 path separators -- support forward and backward in libm3?

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Thu Jan 10 15:37:50 CET 2008


On Thu, Jan 10, 2008 at 01:58:50PM +0100, Olaf Wagner wrote:
> Quoting Jay <jayk123 at hotmail.com>:
> 
> >To a very large extent, Win32 accepts both / and \ equally as path   
> >delimiters.
> >CreateFile, DeleteFile, CreateDirectory, MoveFile, CopyFile,   
> >FindFirstFile, GetFileAttributes, the C runtime wrappers fopen,   
> >unlink/remove, stat, etc., those all work either way, or with a mix.
> >"Shell" functions like shlwapi.dll, commdlg32.dll, tend not to.
> >
> >In building NT386GNU, I run into places where cm3 is picking apart paths.
> >For whatever reason, it is being given paths with a mix of forward   
> >and backward slashes.
> >I find these paths ugly, but they work ok.
> >
> >I've been able to easily progress by changing   
> >m3-libs/libm3/src/os/WIN32/PathnameWin32.m3 to treat forward and   
> >backslashes the same.
> >I have not yet rebuilt the normal NT386 target with this change.
> >
> >An ok change?
> >
> >Or go and fix NT386GNU a) to be consistent, b) use backward slashes,  
> > c) translate at some place.
> >
> >?
> 
> In my opininion NT386GNU should be a POSIX target and thus use forward
> slashes as standard as POSIX defines. Offhand I wouldn't object to accept
> backward slashes as path delimiters, too. But you must heed that \
> is used as an escape character almost everywhere (and so should it be
> in pathname denotations then: a\\b\\c) or you loose much compatibility.
> 
> I still wonder if the decision to use \ on DOS/Windows was only made to
> be as incompatible as possible with Unix...

In the early days, DOS did not have directories, so there was no need of 
a slash or anything as a pathname separator.  Instead, it got used as a 
character to attach options to command names.  I think is also got used 
to attach options to filenames sometimes.

When someone got the bright idea that directories were a neat idea, it 
was too late.

Incidentally, in those days, Unix wasn't yet the big deal it is now.  
There were lots of other OS's to be compatible with -- or not.

-- hendrik




More information about the M3devel mailing list