-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from davidanthoff/windows-support
Windows support
- Loading branch information
Showing
9 changed files
with
109 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ os: | |
- linux | ||
- osx | ||
julia: | ||
- 0.5 | ||
- 0.6 | ||
- nightly | ||
notifications: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
julia 0.5 | ||
julia 0.6 | ||
Compat 0.17.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,76 @@ | ||
immutable WindowsPath <: AbstractPath | ||
parts::Tuple | ||
parts::Tuple{Vararg{String}} | ||
drive::String | ||
root::String | ||
end | ||
|
||
WindowsPath() = WindowsPath(tuple(), "") | ||
WindowsPath() = WindowsPath(tuple(), "", "") | ||
|
||
WindowsPath(parts::Tuple) = WindowsPath(parts, "", "") | ||
|
||
function WindowsPath(str::AbstractString) | ||
if isempty(str) | ||
return WindowsPath(tuple("."), "") | ||
return WindowsPath(tuple("."), "", "") | ||
end | ||
|
||
drive, path = splitdir(str) | ||
tokenized = split(path, WIN_PATH_SEPARATOR) | ||
|
||
if isempty(tokenized[1]) | ||
tokenized[1] = WIN_PATH_SEPARATOR | ||
if startswith(str, "\\\\?\\") | ||
error("The \\\\?\\ prefix is currently not supported.") | ||
end | ||
|
||
return WindowsPath(tuple(map(String, tokenized)...), drive) | ||
end | ||
str = replace(str, POSIX_PATH_SEPARATOR, WIN_PATH_SEPARATOR) | ||
|
||
if startswith(str, "\\\\") | ||
error("UNC paths are currently not supported.") | ||
elseif startswith(str, "\\") | ||
tokenized = split(str, WIN_PATH_SEPARATOR) | ||
|
||
return WindowsPath(tuple(WIN_PATH_SEPARATOR, String.(tokenized[2:end])...), "", WIN_PATH_SEPARATOR) | ||
elseif contains(str, ":") | ||
l_drive, l_path = splitdrive(str) | ||
|
||
tokenized = split(l_path, WIN_PATH_SEPARATOR) | ||
|
||
l_root = isempty(tokenized[1]) ? WIN_PATH_SEPARATOR : "" | ||
|
||
if isempty(tokenized[1]) | ||
tokenized = tokenized[2:end] | ||
end | ||
|
||
if !isempty(l_drive) || !isempty(l_root) | ||
tokenized = tuple(string(l_drive, l_root), tokenized...) | ||
end | ||
|
||
return WindowsPath(tuple(String.(tokenized)...), l_drive, l_root) | ||
else | ||
tokenized = split(str, WIN_PATH_SEPARATOR) | ||
|
||
# The following should be implemented in the concrete types | ||
==(a::WindowsPath, b::WindowsPath) = parts(a) == parts(b) && drive(a) == drive(b) | ||
return WindowsPath(tuple(String.(tokenized)...), "", "") | ||
end | ||
end | ||
|
||
function ==(a::WindowsPath, b::WindowsPath) | ||
return lowercase.(parts(a)) == lowercase.(parts(b)) && | ||
lowercase(drive(a)) == lowercase(drive(b)) && | ||
lowercase(root(a)) == lowercase(root(b)) | ||
end | ||
Base.String(path::WindowsPath) = joinpath(parts(path)...) | ||
parts(path::WindowsPath) = path.parts | ||
drive(path::WindowsPath) = path.drive | ||
root(path::WindowsPath) = path.root | ||
|
||
function isabs(path::WindowsPath) | ||
if parts(path[1]) == WIN_PATH_SEPARATOR && !isempty(drive(path)) | ||
return true | ||
function Base.show(io::IO, path::WindowsPath) | ||
print(io, "p\"") | ||
if isabs(path) | ||
print(io, replace(anchor(path), "\\", "/")) | ||
print(io, join(parts(path)[2:end], "/")) | ||
else | ||
return false | ||
print(io, join(parts(path), "/")) | ||
end | ||
print(io, "\"") | ||
end | ||
|
||
function root(path::WindowsPath) | ||
if parts(path)[1] == WIN_PATH_SEPARATOR | ||
return WIN_PATH_SEPARATOR | ||
else | ||
return "" | ||
end | ||
function isabs(path::WindowsPath) | ||
return !isempty(drive(path)) || !isempty(root(path)) | ||
end | ||
|
||
expanduser(path::WindowsPath) = path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters