in reply to syntax for URI of files?

They generally contain three slashes, because you take a file path that starts with a slash (such as /etc/passwd) and then add the file:// to the beginning, so you get file:///etc/passwd. The vertical bar is what windows uses in place of :, since the : has a different meaning in a URI, so C:\foo.txt becomes file://C|/foo.txt.

Replies are listed 'Best First'.
Re: Re: syntax for URI of files?
by John M. Dlugosz (Monsignor) on Mar 06, 2003 at 16:15 UTC
    Mozilla is showing three slashes before the drive letter, meaning a leading slash before the drive letter. Hmm, and it's showing the colon as-is! IOW, file:///C:/foo.txt.

    So, if | is used for :, what's the meaning of : within a URI? I know it's used to separate the original service name from the rest, but don't recall any special meaning on the right side. Is that true for all colons in a file name (on systems where that is a legal part of a name, or has a special meaning to the file system)?

    And what do you do about |'s in the name that were there to begin with?

    —John

      So, if | is used for :, what's the meaning of : within a URI? I know it's used to separate the original service name from the rest, but don't recall any special meaning on the right side.

      I don't think it has a special meaning, but it's a reserved character for the entire URI. And yes, many browsers will let you get away with using ':' instead of '|'.

      And what do you do about |'s in the name that were there to begin with?

      You beat up the person who named a file with a '|' (:

      ----
      Reinvent a rounder wheel.

      Note: All code is untested, unless otherwise stated

      The reason there are three slashes is that there is an optional host name that comes between the second and third slash: e.g. file://novell01/departmentshare/me/myfile.txt