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

File URI Slashes issue

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