Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "File URI Slashes issue"

 
Line 33: Line 33:
 
  file:///<FONT COLOR=RED><path></FONT COLOR=RED>
 
  file:///<FONT COLOR=RED><path></FONT COLOR=RED>
  
 +
 +
 +
 +
<b><big>Examples</big></b>
  
 
<b>Example A – local file</b>
 
<b>Example A – local file</b>
  
The file URL:
+
The file URL
  
file:///C:/eclipse/eclipse.ini
+
&nbsp;&nbsp;&nbsp;&nbsp;<FONT FACE=VERDANA><b>file:///C:/eclipse/eclipse.ini</b></FONT>
  
 
which can also be writren as:
 
which can also be writren as:
  
file://localhost/C:/Constellation/eclipse/eclipse.ini
+
&nbsp;&nbsp;&nbsp;&nbsp;<FONT FACE=VERDANA><b>file://localhost/C:/Constellation/eclipse/eclipse.ini</b></FONT>
  
will make reference to the file <b>eclipse.ini</b> in the folder/directory <b>eclipse</b> of the hard disk drive <b>C</b>. Executing this file URL in Windows will open the following selected file.
+
will make reference to the file <b>eclipse.ini</b> in the folder/directory <b>eclipse</b> of the hard disk drive <b>C</b>. Executing this URL in Windows will open the following selected file.
  
 
[[Image:fileurislashesissue_2.jpg]]
 
[[Image:fileurislashesissue_2.jpg]]
Line 54: Line 58:
 
The file URL:
 
The file URL:
  
file://Gogul2/shareddocs/autostart.txt
+
&nbsp;&nbsp;&nbsp;&nbsp;<FONT FACE=VERDANA><b>file://Gogul2/shareddocs/autostart.txt</b></FONT>
  
will make reference to the file <b>autostart.txt</b> in the directory <b>shareddocs</b> in the host <b>Gogul2</b>. Executing this file URL in Windows will open the following selected file.
+
will make reference to the file <b>autostart.txt</b> in the directory <b>shareddocs</b> in the host <b>Gogul2</b>. Executing this URL in Windows will open the following selected file.
  
 
[[Image:fileurislashesissue_3.jpg]]
 
[[Image:fileurislashesissue_3.jpg]]
  
 +
Note this is a network resource, the file is located in a remote host.
  
  
<b>Bottom line</b>
+
<b><big>Bottom line</big></b>
  
 
File URIs can have two or three slashes; both are syntactically correct but semantically different. Three slashes (equivalent to omitting “localhost” between the second and third slash) is used to access local files. Two slashes (as long as the host is not “localhost”) is used to access files in a remote system.
 
File URIs can have two or three slashes; both are syntactically correct but semantically different. Three slashes (equivalent to omitting “localhost” between the second and third slash) is used to access local files. Two slashes (as long as the host is not “localhost”) is used to access files in a remote system.

Latest revision as of 17:46, 4 January 2007

File URIs - how many slashes?

Fileurislashesissue 1.jpg

URI: Uniform Resource Identifier; URL: Uniform Resource Locator; URN: Uniform Resource Name


A URI (uniform resource identifier) can be classified as a URL (locator) or a URN (name) or both. A Uniform Resource Locator (URL) is a URI that, in addition to identifying a resource, provides means of acting upon or obtaining a representation of the resource by describing its primary access mechanism or network "location". For example, the URL http://www.eclipse.org/ is a URI that identifies a resource (Eclipse's home page) and implies that a representation of that resource (such as the home page's current HTML code, as encoded characters) is obtainable via HTTP from a network host named www.eclipse.org. A Uniform Resource Name (URN) is a URI that identifies a resource by name in a particular namespace. A URN can be used to talk about a resource without implying its location or how to dereference it. For example, the URN urn:isbn:0-321-30502-7 is a URI that, like an International Standard Book Number (ISBN), allows one to talk about a book, but doesn't suggest where and how to obtain an actual copy of it.


The URI syntax is essentially a URI scheme name like "http", "ftp", "mailto", "file", etc., followed by a colon character, and then a scheme-specific part. The syntax and semantics of the scheme-specific part are determined by the specifications that govern the schemes.


File Scheme

The file scheme is used to designate files accessible on a particular host computer, it takes the following form:

file://<host>/<path>

where <host> is the fully qualified domain name of the system on which the <path> is accessible, and <path> is a hierarchical directory path of the form <directory>/<directory>/.../<name>.


As a special case, <host> can be the string "localhost" or the empty string; this is interpreted as “the machine from which the URL is being interpreted”. In such case the file URL takes the form:

file:///<path>



Examples

Example A – local file

The file URL

    file:///C:/eclipse/eclipse.ini

which can also be writren as:

    file://localhost/C:/Constellation/eclipse/eclipse.ini

will make reference to the file eclipse.ini in the folder/directory eclipse of the hard disk drive C. Executing this URL in Windows will open the following selected file.

Fileurislashesissue 2.jpg


Example B – remote file

The file URL:

    file://Gogul2/shareddocs/autostart.txt

will make reference to the file autostart.txt in the directory shareddocs in the host Gogul2. Executing this URL in Windows will open the following selected file.

Fileurislashesissue 3.jpg

Note this is a network resource, the file is located in a remote host.


Bottom line

File URIs can have two or three slashes; both are syntactically correct but semantically different. Three slashes (equivalent to omitting “localhost” between the second and third slash) is used to access local files. Two slashes (as long as the host is not “localhost”) is used to access files in a remote system.


Related links:

URI-Symtax: http://www.gbiv.com/protocols/uri/rfc/rfc3986.html URI-Schemes: http://www.iana.org/assignments/uri-schemes.html

Back to the top