Adds explicit handling for 'file' URIs to the uri
library.
Example
require 'uri'
require 'file-uri'
uri = URI.parse("file:///path/to/file.txt")
#=> #<URI::CoreFile file:/path/to/file.txt>
Also includes a Windows-specific version, which has extra handling for drive letters at the start of paths.
require 'uri'
require 'file-uri/win'
uri = URI.parse("file:c:/windows/path.txt")
#=> #<URI::WinFile file:/c:/windows/path.txt>
uri + "/absolute/path.txt"
#=> #<URI::WinFile file:/c:/absolute/path.txt>
Returns true
if this file URI is local.
The localhost
parameter instructs the library how to interpret
special values in the host field, to retain compatibility with various
other libraries and programs out there:
URI | :any | true | false |
---|---|---|---|
"file://localhost/" | local | local | non-local |
"file://example.com/" | local | non-local | non-local |
Returns a UNC filespace selector string for this file URI.
Raises a RuntimeError if this is a local URI (see #local?
)
Returns a file path for this file URI.
Raises a RuntimeError if this is not a local URI (see #local?
)
See Kernel#open
, URI::File#to_file_path