From: Dave H. <dhy...@br...> - 2004-11-10 22:00:47
|
Hi Phil, > With a small exception: /path/to/a/file is not legal, while > \path/to/a/file is. That is, you can't use / to refer to the root dir. > I mean at least WinXP, don't know if other versions perform the same > way... From the Windows OS perspective (not necessarily MinGW or Cygwin), /path/to/file and \path\to\file both refer to the same file. They both look on the current drive and then look in a directory called path starting at the root of the current drive. I verified it under Windows XP by writing the following little program (which I called catfile) and compiling using Visual C++ (I used cl directly from the command line). #include <stdio.h> int main( int argc, char **argv ) { char line[ 200 ]; FILE *fs; if (( fs =3D fopen( argv[1], "rb" )) =3D=3D NULL ) { fprintf( stderr, "Unable to open '%s'\n", argv[1] ); return 1; } while ( fgets( line, sizeof( line ), fs )) { printf( "%s", line ); } fclose( fs ); return 0; } And then excuting this from the MS-DOS command prompt: C: mkdir \xyx dir > \xyz\file catfile /xyz/file Repeat but change the current drive to be somewhere else (like on a network share), and it will look for the file on that drive instead of on the C drive. In the DOS days, everybody was used to the fact that each drive had its own current directory. People who have never used DOS, but only used Windows or newer, often are unaware that each drive has a notion of current directory (where in unix land there is only one current directory). It has always been the case (under MS-DOS and under all of the windows flavours) that the OS itself treats \ and / interchangably. The most common cause of the misconception is that the command line processor that Microsoft provides (COMMAND.COM or CMD.EXE) doesn't support / so people make the mistake of assuming that the OS itself behaves the same way. But if you write your own program and call the OS (like I did with catfile above) you'll find that they do in fact work interchangeably. -- Dave Hylands Vancouver, BC, Canada http://www.DaveHylands.com/=20 |