Skip to content

Commit

Permalink
Use current directory's root for Dir.glob("/...") on Windows (cryst…
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil authored and Blacksmoke16 committed Dec 11, 2023
1 parent 0db5037 commit d89ce7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
1 change: 1 addition & 0 deletions spec/std/dir_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ describe "Dir" do
it "root pattern" do
{% if flag?(:windows) %}
Dir["C:/"].should eq ["C:\\"]
Dir["/"].should eq [Path[Dir.current].anchor.not_nil!.to_s]
{% else %}
Dir["/"].should eq ["/"]
{% end %}
Expand Down
7 changes: 1 addition & 6 deletions src/dir/glob.cr
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,7 @@ class Dir
end

private def self.root
# TODO: better implementation for windows?
{% if flag?(:windows) %}
"C:\\"
{% else %}
File::SEPARATOR_STRING
{% end %}
Path[Dir.current].anchor.not_nil!.to_s
end

private def self.dir?(path, follow_symlinks)
Expand Down

0 comments on commit d89ce7b

Please sign in to comment.