Re: Serial Port Accessing / File handling in Local Network
On Dec 17, 9:11 pm, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
Paavo Helde <myfirstn...@osa.pri.ee> wrote
innews:Xns9CE4E8BB05AApaavo256@216.196.109.131:
Off-topic: '/' does not work with system() on Windows (used by OP),
which calls cmd.exe shell, which does not support forward slashes in
pathnames.
The '/' character is accepted only by lower level function
interfaces, like fopen() etc.
A correction: also cmd.exe and other utilities can accept forward
slashes in pathnames if one manages to convince them that this is a
single filename argument which has to be directly passed to a system
function. For that one can try enclosing the filename in double
quotes. Different commands/programs accept different things, though.
I was going to say that I use it rather regularly in cmd.exe, with no
problems. (Filename expansion doesn't take it into account, but
everything else does.) It's true that the Windows documentation says
to
use a '\', with a note that the file I/O functions in the Windows API
convert '/' to '\' (except when they don't). In practice, the real
problem with '/' is that it is conventionally used to signal an option
(like '-' under Unix); you should definitely avoid filenames that
start
with a '/' (but "c:/..." doesn't generally seem to cause problems).
Of course, you can always write it: "file://c:/...":-). (In URL's,
'/'
is the only allowed path separator.)
In practice, I'll stand by my original statement: a well written
program
should accept both '/' and '\' in input (and will pass the '/' on to
the
system, if that's all it's doing with the filename), and use '\' in
output (because it is the "standard"). The one exception is in argv:
if
argv[i] starts with a '/', it's an option, not a filename (and for
various historical reasons, a well written program will accept either
'/' or '-' as an option---most of Microsoft's code does).
(Internally,
you might prefer maintaining the name in an std::vector< std::string
,
and ignoring the issue:-).)
--
James Kanze