FAQ: slashes in your filenames???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Julie

    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 . "



    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?
  • Christopher Benson-Manica

    #2
    Re: FAQ: slashes in your filenames???

    Julie <julie@nospam.c om> spoke thus:
    [color=blue]
    > 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 '\\'.[/color]

    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)cybers pace.org | don't, I need to know. Flames welcome.

    Comment

    • Kevin Goodsell

      #3
      Re: FAQ: slashes in your filenames???

      Julie wrote:
      [color=blue]
      > 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 '\\'.
      >[/color]

      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.

      Comment

      • Derek

        #4
        Re: FAQ: slashes in your filenames???

        Julie wrote:
        [color=blue]
        > Why does the faq make this statement regarding slashes in
        > paths:
        >
        > "This is because the library routines
        > on these operating systems handle "/"
        > and "\" interchangeably . "
        >
        >[/color]
        http://www.parashift.com/c++-faq-lit...html#faq-15.16[color=blue]
        >
        > 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?[/color]

        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.

        Comment

        • Christopher Benson-Manica

          #5
          Re: FAQ: slashes in your filenames???

          Derek <none@cheese.co m> spoke thus:
          [color=blue]
          > 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 "\".[/color]

          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)cybers pace.org | don't, I need to know. Flames welcome.

          Comment

          • Julie

            #6
            Re: FAQ: slashes in your filenames???

            Derek wrote:[color=blue]
            >
            > Julie wrote:
            >[color=green]
            > > Why does the faq make this statement regarding slashes in
            > > paths:
            > >
            > > "This is because the library routines
            > > on these operating systems handle "/"
            > > and "\" interchangeably . "
            > >
            > >[/color]
            > http://www.parashift.com/c++-faq-lit...html#faq-15.16[color=green]
            > >
            > > 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?[/color]
            >[/color]
            [color=blue]
            > 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 "\".[/color]

            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.
            [color=blue]
            > 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.[/color]

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

            Comment

            • John Carson

              #7
              Re: FAQ: slashes in your filenames???

              "Julie" <julie@nospam.c om> wrote in message
              news:407B1389.5 7C237A0@nospam. com[color=blue]
              >
              > 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.[/color]

              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)

              Comment

              • Derek

                #8
                Re: FAQ: slashes in your filenames???

                Julie wrote:[color=blue][color=green]
                > > 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 "\".[/color]
                >
                > 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.[/color]

                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.
                [color=blue]
                > Therefore, the statement in the FAQ that you should use
                > one form over another is inherently wrong as it pertains
                > the language.
                >[color=green]
                > > 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.[/color]
                >
                > If it isn't 100% correct, then it is completely wrong,
                > especially when there is a 100% correct answer.[/color]

                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.

                Comment

                • Derek

                  #9
                  Re: FAQ: slashes in your filenames???

                  Julie wrote:
                  [color=blue][color=green]
                  > > 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 "\".[/color]
                  >
                  > 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.[/color]

                  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.
                  [color=blue]
                  > Therefore, the statement in the FAQ that you should use
                  > one form over another is inherently wrong as it pertains
                  > the language.
                  >[color=green]
                  > > 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.[/color]
                  >
                  > If it isn't 100% correct, then it is completely wrong,
                  > especially when there is a 100% correct answer.[/color]

                  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.

                  Comment

                  • Derek

                    #10
                    Re: FAQ: slashes in your filenames???

                    Sorry -- pressed the wrong button and responded to the wrong
                    thread.

                    Comment

                    • Derek

                      #11
                      Re: FAQ: slashes in your filenames???

                      Again. *sigh* :)

                      Comment

                      Working...