Skip to content

Commit ade2c25

Browse files
author
José Valim
committed
Handle when :file.get_cwd returns a binary
1 parent e2ba0bd commit ade2c25

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

lib/elixir/lib/file.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ defmodule File do
884884
"""
885885
def cwd() do
886886
case F.get_cwd do
887-
{ :ok, cwd } -> { :ok, to_string(cwd) }
887+
{ :ok, base } when is_binary(base) -> { :ok, base }
888+
{ :ok, base } -> { :ok, to_string(base) }
888889
{ :error, _ } = error -> error
889890
end
890891
end

lib/elixir/lib/path.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ defmodule Path do
243243
"""
244244
def relative_to_cwd(path) do
245245
case :file.get_cwd do
246+
{ :ok, base } when is_binary(base) -> relative_to(path, to_char_list(base))
246247
{ :ok, base } -> relative_to(path, base)
247248
_ -> path
248249
end

lib/elixir/lib/system.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ defmodule System do
9393
"""
9494
def cwd do
9595
case :file.get_cwd do
96-
{ :ok, list } -> String.from_char_list!(list)
96+
{ :ok, base } when is_binary(base) -> base
97+
{ :ok, base } -> String.from_char_list!(base)
9798
_ -> nil
9899
end
99100
end

0 commit comments

Comments
 (0)