Skip to content

phluid61/file-uri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

de0bfd0 · Dec 6, 2019

History

27 Commits
Dec 6, 2019
May 18, 2019
Feb 7, 2019
Dec 6, 2016
Dec 6, 2016
Dec 8, 2016
Dec 6, 2016
May 18, 2019
May 18, 2019
Dec 6, 2016
Dec 6, 2016
May 18, 2019

Repository files navigation

file-uri – the "file" URI scheme

Adds explicit handling for 'file' URIs to the uri library.

Build Status Gem Version

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>

URI::File

local?( localhost: true )

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

to_unc( localhost: true )

Returns a UNC filespace selector string for this file URI.

Raises a RuntimeError if this is a local URI (see #local?)

to_file_path( localhost: true )

Returns a file path for this file URI.

Raises a RuntimeError if this is not a local URI (see #local?)

open( [mode [, perm]] [, opt]) → io or nil

open( [mode [, perm]] [, opt]) {|io| block } → obj

See Kernel#open, URI::File#to_file_path

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages