File URI scheme

In programming, a file uniform resource identifier (URI) scheme is a specific format of URI, used to specifically identify a file on a host computer. While URIs can be used to identify anything, there is specific syntax associated with identifying files.[1][2]

Format

A file URI has the format

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. If host is omitted, it is taken to be "localhost", the machine from which the URL is being interpreted. Note that when omitting host, the slash is not omitted (while "file:///piro.txt" is valid, "file://simpen.txt" is not, although some interpreters manage to handle the latter).

RFC 3986 includes additional information about the treatment of ".." and "." segments in URIs.

Number of slash characters

  • The character sequence of two slash characters (//) after the string file: denotes that either a hostname or the literal term localhost follows,[3] although this part may be omitted entirely, or may contain an empty hostname.[4]
  • The single slash between host and path denotes the start of the local-path part of the URI and must be present.[5]
  • A valid file URI must therefore begin with either file:/path (no hostname), file:///path (empty hostname), or file://hostname/path.
  • file://path (i.e. two slashes, without a hostname) is never correct, but is often used.
  • Further slashes in path separate directory names in a hierarchical system of directories and subdirectories. In this usage, the slash is a general, system-independent way of separating the parts, and in a particular host system it might be used as such in any pathname (as in Unix systems).

There are two ways that Windows UNC filenames (such as \\server\folder\data.xml) can be represented. These are both described in RFC 8089, Appendix E as "non-standard". The first way (called here the 2-slash format) is to represent the server name using the Authority part of the URI, which then becomes file://server/folder/data.xml. The second way (called here the 4-slash format) is to represent the server name as part of the Path component, so the URI becomes file:////server/folder/data.xml. Both forms are actively used. Microsoft .NET (for example, the method new Uri(path)) generally uses the 2-slash form; Java (for example, the method new URI(path)) generally uses the 4-slash form. Either form allows the most common operations on URIs (resolving relative URIs, and dereferencing to obtain a connection to the remote file) to be used successfully. However, because these URIs are non-standard, some less common operations fail: an example is the normalize operation (defined in RFC 3986 and implemented in the Java java.net.URI.normalize() method) which reduces file:////server/folder/data.xml to the unusable form file:/server/folder/data.xml.[6]

Examples

Unix

Here are two Unix examples pointing to the same /etc/fstab file:

file://localhost/etc/fstab
file:///etc/fstab

The KDE environment uses URIs without an authority field:

file:/etc/fstab

Windows

Here are some examples which may be accepted by some applications on Windows systems, referring to the same, local file c:\WINDOWS\clock.avi

file://localhost/c:/WINDOWS/clock.avi
file:///c:/WINDOWS/clock.avi

Here is the URI as understood by the Windows Shell API:[7]

file:///c:/WINDOWS/clock.avi

Note that the drive letter followed by a colon and slash is part of the acceptable file URI.

Implementations

Windows

On Microsoft Windows systems, the normal colon (:) after a device letter has sometimes been replaced by a vertical bar (|) in file URLs. This reflected the original URL syntax, which made the colon a reserved character in a path part.

Since Internet Explorer 4, file URIs have been standardized on Windows, and should follow the following scheme. This applies to all applications which use URLMON or SHLWAPI for parsing, fetching or binding to URIs. To convert a path to a URL, use UrlCreateFromPath, and to convert a URL to a path, use PathCreateFromUrl.[7]

To access a file "the file.txt", the following might be used.

For a network location:

file://hostname/path/to/the%20file.txt

Or for a local file, the hostname is omitted, but the slash is not (note the third slash):

file:///c:/path/to/the%20file.txt

This is not the same as providing the string "localhost" or the dot "." in place of the hostname. The string "localhost" will attempt to access the file as UNC path \\localhost\c:\path\to\the file.txt, which will not work since the colon is not allowed in a share name. The dot "." results in the string being passed as \\.\c:\path\to\the file.txt, which will work for local files, but not shares on the local system. For example file://./sharename/path/to/the%20file.txt will not work, because it will result in sharename being interpreted as part of the DOSDEVICES namespace, not as a network share.

The following outline roughly describes the requirements.

  • The colon should be used, and should not be replaced with a vertical bar for Internet Explorer.
  • Forward slashes should be used to delimit paths.
  • Characters such as the hash (#) or question mark (?) which are part of the filename should be percent-encoded.
  • Characters which are not allowed in URIs, but which are allowed in filenames, must also be percent-encoded. For example, any of "{}`^ " and all control characters. In the example above, the space in the filename is encoded as %20.
  • Characters which are allowed in both URIs and filenames must NOT be percent-encoded.
  • Must not use legacy ACP encodings. (ACP code pages are specified by DOS CHCP or Windows Control Panel language setting.)
  • Unicode characters outside of the ASCII range must be UTF-8 encoded, and those UTF-8 encodings must be percent-encoded.

Use the provided functions if possible. If you must create a URL programmatically and cannot access SHLWAPI.dll (for example from script, or another programming environment where the equivalent functions are not available) the above outline will help.

Legacy URLs

To aid the installed base of legacy applications on Win32 PathCreateFromUrl recognizes certain URLs which do not meet these criteria, and treats them uniformly. These are called "legacy" file URLs as opposed to "healthy" file URLs.[8]

In the past, a variety of other applications have used other systems. Some added an additional two slashes. For example, UNC path \\remotehost\share\dir\file.txt would become file:////remotehost/share/dir/file.txt instead of the "healthy" file://remotehost/share/dir/file.txt.

Web pages

File URLs are rarely used in Web pages on the public Internet, since they imply that a file exists on the designated host. The host specifier can be used to retrieve a file from an external source, although no specific file-retrieval protocol is specified; and using it should result in a message that informs the user that no mechanism to access that machine is available.

References

  1. ^ Kerwin, Matthew (February 2017). The "file" URI Scheme (Report). Internet Engineering Task Force.
  2. ^ "What is a Uniform Resource Identifier (URI)?". WhatIs.com. Retrieved 2023-09-12.
  3. ^ RFC 8089, Section 2
  4. ^ RFC 3986, Section 3.2.2
  5. ^ RFC 3986, Section 3.3
  6. ^ RFC 8089, Appendix E
  7. ^ a b Risney, Dave (2006). "File URIs in Windows". IEBlog. Microsoft Corporation. Retrieved 2020-10-02.
  8. ^ The Bizarre and Unhappy Story of 'file:' URLs - Free Associations - Site Home - MSDN Blogs. Blogs.msdn.com (2005-05-19). Retrieved on 2014-03-08.


Read other articles:

BaronOlivier De SchutterOlivier De Schutter (2010).Lahir20 Juli 1968 (umur 55)PekerjaanCendekiawan hukum yang mengkhususkan diri dalam hak ekonomi dan sosialDikenal atasPelapor Khusus Perserikatan Bangsa-Bangsa untuk hak atas pangan Olivier, Baron De Schutter (lahir 20 Juli 1968) adalah seorang cendekiawan hukum Belgia yang mengkhususkan diri dalam hak ekonomi dan sosial. Ia menjabat sebagai Pelapor Khusus Perserikatan Bangsa-Bangsa untuk hak atas pangan dari 2008 sampai 2014.[1]...

 

 

Tautomerisme keto–enol.Bentuk keto (kiri); bentuk enol (kanan). Dalam kimia organik, tautomerisme keto–enol merujuk pada kesetimbangan kimia antara bentuk keto (suatu keton atau aldehida) dan bentuk enol (suatu alkohol).[1] Bentuk enol dan keto dikatakan merupakan tautomer satu sama lain. Interkonversi dua bentuk tersebut melibatkan perpindahan atom hidrogen alfa dan penataan ulang elektron yang terikat; karenanya, isomerisme dapat dikelompokkan sebagai tautomerisme.[2] Su...

 

 

ε Canis Majoris Lokasi ε Canis Majoris (dilingkari) Data pengamatan Epos J2000      Ekuinoks J2000 Rasi bintang Canis Major Asensio rekta 06h 58m 37.6s Deklinasi −28° 58' 19 Magnitudo tampak (V) 1.51 Ciri-ciri Kelas spektrum B2 Iab Indeks warna U−B −0.93 Indeks warna B−V −0.13 AstrometriKecepatan radial (Rv)+27.3 km/sGerak diri (μ) RA: 2.63 mdb/thn Dek.: 2.29 mdb/thn Paralaks (π)7,57±0,57 mdbJarak430 ±...

Gold DiggerSingel oleh Kanye West featuring Jamie Foxxdari album Late RegistrationDirilis5 Juli 2005 (2005-07-05)FormatDigital downloadCompact DiscDirekam2004GenreHip hop, R&BDurasi3:28LabelRoc-A-Fella, Def JamPenciptaKanye West, Ray Charles, Renald RichardProduserKanye West, Jon BrionKronologi singel Brand New(2005) Gold Digger Heard 'Em Say(2005) Slow Jamz(2003) Gold Digger(2005) Georgia(2005) Gold Digger adalah lagu dari rapper asal Amerika yaitu Kanye West berkolaborasi dengan Ja...

 

 

Sungai Yongding永定河Sungai Yongding yang mengering di bawah Jembatan Marco PoloDAS Sungai HaiCiri-ciri fisikHulu sungaiPegunungan Guancen - lokasiCounty Ningwu, Provinsi Shanxi Muara sungaiSungai Hai - koordinat39°09′44″N 117°10′34″E / 39.1623°N 117.1762°E / 39.1623; 117.1762Koordinat: 39°09′44″N 117°10′34″E / 39.1623°N 117.1762°E / 39.1623; 117.1762Panjang650 kilometer (400 mi)Daerah Aliran S...

 

 

Mackenzie CrookCrook in 2009LahirPaul James Crook29 September 1971 (umur 52)Maidstone, Kent, EnglandPekerjaanActor, writer, director, comedianTahun aktif1996–presentSuami/istriLindsay Crook ​(m. 2001)​Anak2 Paul James Mackenzie Crook[1] (lahir 29 September 1971) adalah pemeran, penulis, sutradara, dan pelawak tunggal berkebangsaan Inggris. Namanya dikenal melalui perannya sebagai Gareth Keenan dalam The Office, Ragetti dalam Pirates of the Cari...

Este artigo ou secção contém uma lista de referências no fim do texto, mas as suas fontes não são claras porque não são citadas no corpo do artigo, o que compromete a confiabilidade das informações. Ajude a melhorar este artigo inserindo citações no corpo do artigo. (Julho de 2013) Tratado de Florença Tratado de Florença (1844)Trocas territoriais entre os Ducados de Parma (amarelo) e Modena (verde) Local de assinatura Florença, Grão-ducado da Toscana Signatário(a)(s) Leopoldo...

 

 

57-cell Tipo 4-politopo regular abstracto Celdas 57 hemidodecaedros Caras 171 {5} Aristas 171 Vértices 57 Figura de vértice Hemicosaedro Tipo de Schläfli {5,3,5} Grupo de simetría Orden 3420L2(19) abstracto Dual Autodual Propiedades Regular En matemáticas, un 57 celdas (o pentacontacaiheptacorón) es un 4-politopo regular abstracto autodual (un tipo de polícoro, es decir, de politopo en cuatro dimensiones). Sus 57 celdas son hemidodecaedros, y posee 57 vértices, 171 aristas y 171 caras...

 

 

село Село Соколамолд./рум. Socola Основні дані 47°54′06″ пн. ш. 28°49′01″ сх. д. / 47.90167° пн. ш. 28.81694° сх. д. / 47.90167; 28.81694Координати: 47°54′06″ пн. ш. 28°49′01″ сх. д. / 47.90167° пн. ш. 28.81694° сх. д. / 47.90167; 28.81694Країна  МолдоваРай...

هذه المقالة يتيمة إذ تصل إليها مقالات أخرى قليلة جدًا. فضلًا، ساعد بإضافة وصلة إليها في مقالات متعلقة بها. (يوليو 2019) بيوتر هيرتل معلومات شخصية الميلاد 19 مايو 1936  وودج  الوفاة 19 نوفمبر 2010 (74 سنة) [1]  وودج  مواطنة بولندا  عضو في الأكاديمية السينمائية البولندية&#...

 

 

British music festival Radio 2 in the ParkGenreAdult contemporaryDatesSeptemberLocation(s)Hyde Park, London (2011–2019)Victoria Park, Leicester (2023)Years active2011–presentAttendance45,000Websitewww.bbc.co.uk/events/e4jqwh Radio 2 in the Park (formally known as Radio 2 Live, Radio 2 Live in Hyde Park and Radio 2's Festival in a Day) is a British music festival that took place from 2011 to 2019 in Hyde Park in London. It was due to be held in Leeds in September 2022, but it was cancelled...

 

 

Special merit Grammy award Technical Grammy AwardAwarded forContributions of outstanding technical significance to the recording fieldCountryUnited StatesPresented byThe Recording AcademyFirst awarded1994Websitewww.grammy.com/awards/technical-awards The Technical Grammy Award is a Special Merit Grammy Award presented to individuals or companies who have made contributions of outstanding technical significance to the recording field. The award was first presented in 1994 to Dr. Thomas G. Stock...

Fijian politician Semi KoroilavesauKoroilavesau in 2022Minister for FisheriesIn office21 November 2018 – 24 December 2022Succeeded byKalaveti RavuMinister for Employment, Productivity and Industrial RelationsIn office16 October 2015 – 21 November 2018Succeeded byParveen Bala Personal detailsNationalityFijianPolitical partyFijiFirst Semi Tuleca Koroilavesau (born 1958)[1] is a Fijian politician and Member of the Parliament of Fiji. He served the Minister for Fishe...

 

 

English singer-songwriter Matt MalteseBackground informationBirth nameMatthew Jonathan Gordon MalteseBorn (1997-10-06) October 6, 1997 (age 26)OriginReading, EnglandGenres Indie rock indie pop alternative pop chamber pop Occupation(s) Musician singer-songwriter Instrument(s) Piano vocals organ[1] Years active2015–presentLabels Nettwerk Music Group Atlantic Records UK Café Bleu Recordings sevenfoursevensix Websitematt-maltese.comMusical artist Matthew Jonathan Gordon Maltese (b...

 

 

Taktikzentrum des Heeres— TZH — Verbandsabzeichen Aufstellung 1. Oktober 1980 Staat Deutschland Deutschland Streitkräfte Bundeswehr Teilstreitkraft Heer Typ Zentrum des Heeres Stärke 30 Unterstellung Offizierschule des Heeres Standort Dresden Führung Kommandeur Oberst i. G. Henning Klement Das Taktikzentrum des Heeres (TZH) ist eines der Zentren des Heeres mit Sitz in Dresden. Es ist der Offizierschule des Heeres angegliedert. Inhaltsverzeichnis 1 Aufgaben 2 Geschichte 3 Verb...

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Honda J engine – news · newspapers · books · scholar · JSTOR (June 2017) (Learn how and when to remove this template message) Reciprocating internal combustion engine Honda J engineOverviewManufacturerHonda Motor ManufacturingProduction1996–presentLayoutConfi...

 

 

Defunct administrative unit in Derbyshire, United Kingdom (1894–1974) For the town, see Dronfield. DronfieldDronfield Urban District shown within Derbyshire in 1970.Area • 19111,045 acres (4.23 km2) • 19613,452 acres (13.97 km2) Population • 19113,943 • 196111,303 History • Created1894 • Abolished1974 • Succeeded byNorth East Derbyshire StatusUrban DistrictGovernmentDronfield Urban District Co...

 

 

9th Emperor of Japan Emperor Kaika開化天皇Emperor of JapanReign158 BC – 98 BC (traditional)[1]PredecessorKōgenSuccessorSujinBorn208 BC[2]Died98 BC (aged 110)BurialKasuga no Izakawa no saka no e no misasagi (春日率川坂上陵) (Nara)SpouseIkagashikome-no-MikotoIssueamong others...Emperor SujinPosthumous nameChinese-style shigō:Emperor Kaika (開化天皇)Japanese-style shigō:Wakayamato-nekohiko-ōbibi no Sumeramikoto (稚日本根子彦大日日天皇)HouseImperial...

The re-erected Four Columns The Four Columns (Les Quatre Columnes in Catalan) are four Ionic columns originally created by Josep Puig i Cadafalch in Barcelona, Spain. They were erected in 1919, where the Magic Fountain of Montjuïc now stands. They symbolized the four stripes of the Catalan senyera, and they were intended to become one of the main icons of Catalanism. Because of this, they were demolished in 1928 during Primo de Rivera's dictatorship, when all public Catalanist symbols were s...

 

 

Australian television series The Living RoomThe revamped logo of The Living Room, which has been in use since May 2020.GenreLifestyleDeveloped byCaroline SwiftDirected byJon OlbBrent FergusonKate Douglas-WalkerAdam KotcharianPresented byAmanda KellerStarringBarry Du BoisChris BrownMiguel MaestreCountry of originAustraliaOriginal languageEnglishNo. of seasons10No. of episodes367 (list of episodes)ProductionExecutive producers Paul Rudd Allison Whitlock Virginia Hodgson Sarah Thornton Caroline ...

 

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!