473,327 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

FAQ: slashes in your filenames???

Why does the faq make this statement regarding slashes in paths:

"This is because the library routines
on these operating systems handle "/"
and "\" interchangeably. "

http://www.parashift.com/c++-faq-lit...html#faq-15.16

This seems like completely the wrong answer for this question. Rather than
saying that you should use forward slash as a delimiter, it should say
something to the effect of "refer to your operating system documentation on how
to specify paths/subdirectories, remembering that in a string literal in C++
the back-slash (\) character modifies the following character, and therefore
operating systems that use a backslash as a directory delimiter should be
encoded as '\\'.

Comments?
Jul 22 '05 #1
10 1998
Julie <ju***@nospam.com> spoke thus:
This seems like completely the wrong answer for this question. Rather than
saying that you should use forward slash as a delimiter, it should say
something to the effect of "refer to your operating system documentation on how
to specify paths/subdirectories, remembering that in a string literal in C++
the back-slash (\) character modifies the following character, and therefore
operating systems that use a backslash as a directory delimiter should be
encoded as '\\'.


FWIW, I've been bitten by / vs. \ issues in the past. Whether or not
that behavior is conforming, I'd say it's safer just to use the
delimiter that the implementation prefers...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #2
Julie wrote:
Why does the faq make this statement regarding slashes in paths:

"This is because the library routines
on these operating systems handle "/"
and "\" interchangeably. "

http://www.parashift.com/c++-faq-lit...html#faq-15.16

This seems like completely the wrong answer for this question. Rather than
saying that you should use forward slash as a delimiter, it should say
something to the effect of "refer to your operating system documentation on how
to specify paths/subdirectories, remembering that in a string literal in C++
the back-slash (\) character modifies the following character, and therefore
operating systems that use a backslash as a directory delimiter should be
encoded as '\\'.


It doesn't seem likely that using '/' instead of '\\' will /hurt/ you in
any way -- and it should make the code a bit more portable. For full
portability, I don't think you can assume anything about the directory
separator (or even assume that there are directories, but no one is
likely to complain if you decide to only support systems that support
directories, I think).

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #3
Julie wrote:
Why does the faq make this statement regarding slashes in
paths:

"This is because the library routines
on these operating systems handle "/"
and "\" interchangeably. "

http://www.parashift.com/c++-faq-lit...html#faq-15.16
This seems like completely the wrong answer for this
question. Rather than saying that you should use forward
slash as a delimiter, it should say something to the
effect of "refer to your operating system documentation
on how to specify paths/subdirectories, remembering that
in a string literal in C++ the back-slash (\) character
modifies the following character, and therefore operating
systems that use a backslash as a directory delimiter
should be encoded as '\\'.

Comments?


Using the forward slash is very portable. As the answer
correctly states, even operating systems that natively use
"\" (Windows, DOS, OS/2, etc.) provide library routines that
understand "/". So the "/" is very portable -- certainly
better than "\".

So I wouldn't call it "completely the wrong answer," but I
would add a disclaimer that nothing is guaranteed by the
standard about directory delimiters. In fact, nothing is
guaranteed about a directories (or even a filesystem)
existing at all.
Jul 22 '05 #4
Derek <no**@cheese.com> spoke thus:
Using the forward slash is very portable. As the answer
correctly states, even operating systems that natively use
"\" (Windows, DOS, OS/2, etc.) provide library routines that
understand "/". So the "/" is very portable -- certainly
better than "\".


I'm sure you're correct, but as I said, for whatever reason forward
slashes proved to be problematic on my Windows implemenation, so I
use back slashes. Most people's mileage will vary...

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #5
Derek wrote:

Julie wrote:
> Why does the faq make this statement regarding slashes in
> paths:
>
> "This is because the library routines
> on these operating systems handle "/"
> and "\" interchangeably. "
>
> http://www.parashift.com/c++-faq-lit...html#faq-15.16
>
> This seems like completely the wrong answer for this
> question. Rather than saying that you should use forward
> slash as a delimiter, it should say something to the
> effect of "refer to your operating system documentation
> on how to specify paths/subdirectories, remembering that
> in a string literal in C++ the back-slash (\) character
> modifies the following character, and therefore operating
> systems that use a backslash as a directory delimiter
> should be encoded as '\\'.
>
> Comments?

Using the forward slash is very portable. As the answer
correctly states, even operating systems that natively use
"\" (Windows, DOS, OS/2, etc.) provide library routines that
understand "/". So the "/" is very portable -- certainly
better than "\".
Doesn't matter about the relative portability of delimiters -- as far as I
know, the standard doesn't say anything about directory delimiters in file
names.

Therefore, the statement in the FAQ that you should use one form over another
is inherently wrong as it pertains the language.
So I wouldn't call it "completely the wrong answer," but I
would add a disclaimer that nothing is guaranteed by the
standard about directory delimiters. In fact, nothing is
guaranteed about a directories (or even a filesystem)
existing at all.


If it isn't 100% correct, then it is completely wrong, especially when there is
a 100% correct answer.
Jul 22 '05 #6
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com

Doesn't matter about the relative portability of delimiters -- as far
as I know, the standard doesn't say anything about directory
delimiters in file names.

Therefore, the statement in the FAQ that you should use one form over
another is inherently wrong as it pertains the language.


A quick skim over the FAQ should convince you that it departs in many
respects from a pure guide to what is in the standard. There are references
to platforms, compilers, garbage collection and even stuff like LaTeX and
HTML. Perhaps there should be a clearer delimitation between what pertains
to the standard and what does not, but I don't think we should expect the
same legal precision from it that we expect from the standard.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #7
Julie wrote:
Using the forward slash is very portable. As the
answer correctly states, even operating systems that
natively use "\" (Windows, DOS, OS/2, etc.) provide
library routines that understand "/". So the "/" is
very portable -- certainly better than "\".
Doesn't matter about the relative portability of
delimiters -- as far as I know, the standard doesn't say
anything about directory delimiters in file names.


Relax, it's just a FAQ, not the standard itself. Relative
portability DOES matter to those of us programming in
the real world. And because the standard won't touch
OS-specific issues, I think the FAQ is a perfect place for
real-world answers to real-world questions.
Therefore, the statement in the FAQ that you should use
one form over another is inherently wrong as it pertains
the language.
So I wouldn't call it "completely the wrong answer,"
but I would add a disclaimer that nothing is guaranteed
by the standard about directory delimiters. In fact,
nothing is guaranteed about directories (or even a
filesystem) existing at all.


If it isn't 100% correct, then it is completely wrong,
especially when there is a 100% correct answer.


Yes, the 100% correct answer is that you shouldn't use
files or paths in a portable program because a filesystem
might not exist if the code is ever compiled to run on a
microwave's embedded processor. Not very useful.
Jul 22 '05 #8
Julie wrote:
Using the forward slash is very portable. As the
answer correctly states, even operating systems that
natively use "\" (Windows, DOS, OS/2, etc.) provide
library routines that understand "/". So the "/" is
very portable -- certainly better than "\".
Doesn't matter about the relative portability of
delimiters -- as far as I know, the standard doesn't say
anything about directory delimiters in file names.


Relax, it's just a FAQ, not the standard itself. Relative
portability DOES matter to those of us programming in
the real world. And because the standard won't touch
OS-specific issues, I think the FAQ is a perfect place for
real-world answers to real-world questions.
Therefore, the statement in the FAQ that you should use
one form over another is inherently wrong as it pertains
the language.
So I wouldn't call it "completely the wrong answer,"
but I would add a disclaimer that nothing is guaranteed
by the standard about directory delimiters. In fact,
nothing is guaranteed about a directories (or even a
filesystem) existing at all.


If it isn't 100% correct, then it is completely wrong,
especially when there is a 100% correct answer.


Yes, the 100% correct answer is that you shouldn't use
files or paths in a portable program because a filesystem
might not exist if the code is ever compiled to run on a
microwave's embedded processor. Not very useful.
Jul 22 '05 #9
Sorry -- pressed the wrong button and responded to the wrong
thread.
Jul 22 '05 #10
Again. *sigh* :)
Jul 22 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Randell D. | last post by:
Folks, I'm using Apache/1.3.28 (SuSE 7.1, kernal 2.4) with PHP/4.3.2. I have the following code to help cleanse form data. function cleanData($sourceData, &$cleanData) { foreach($myData as...
6
by: Handover Phist | last post by:
Specefically, how do they work? php.net describes them as a collection of variables and functions working with these variables. So far I'm doing this with collections of function and include'';...
13
by: lawrence | last post by:
A user writes this sentence: "It was the New Urbanist's nightmare of sprawl run amok." They input that and my PHP script hits it with addslashes() and then the sentence gets put in the database....
4
by: Jan Pieter Kunst | last post by:
Q. How do I use addslashes() and stripslashes() when dealing with HTML forms and database INSERTs, UPDATEs and SELECTs? A. It depends on the setting of the php.ini directive "magic_quotes_gpc"....
5
by: Aloysio Figueiredo | last post by:
I need to replace every ocurrence of '/' in s by '\/' in order to create a file named s. My first attempt was: s = '\/'.join(s.split('/')) but it doesn't work: >>> s = 'a/b' >>> s =...
16
by: droog | last post by:
Hello! I have just started learning python and encountered a problem. All I wanted to do, was to open a text file search and count the number of occurances of a single word and print that count....
10
by: Carlos Ribeiro | last post by:
Hello all. I'm sending this to the list because I would like to know if someone else has ever stumbled across this one, and also because one possible solution is to patch, or simply "decorate",...
7
by: Alex | last post by:
I'm new to Oracle, so this question may sound silly. I have been given a list of Oracle tables (they may be views, I'm not sure) that are available to me. I can run simple SQL select statements...
10
by: Julie | last post by:
Why does the faq make this statement regarding slashes in paths: "This is because the library routines on these operating systems handle "/" and "\" interchangeably. " ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.