Skip to content

Commit fda6f0c

Browse files
author
José Valim
committed
Move path related functions from File to Path
1 parent 173c0cf commit fda6f0c

40 files changed

+585
-516
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [Mix] Mix now starts the current application before run, iex, test and friends
1616
* [Mix] Mix now provides basic support for compiling `.erl` files
1717
* [Mix] `mix escriptize` only generates escript if necessary and accept `--force` and `--no-compile` as options
18+
* [Path] Introduce `Path` module to hold filesystem paths related functions
1819
* [String] Add `String.capitalize` and `String.slice`
1920

2021
* bug fix
@@ -25,6 +26,7 @@
2526

2627
* deprecations
2728
* [Dict] Deprecate `Binary.Dict` and `OrdDict` in favor of `HashDict` and `List.Dict`
29+
* [File] Deprecate path related functions in favor of the module `Path`
2830
* [Kernel] The `/>` operator has been deprecated in favor of `|>`
2931
* [Mix] `Mix.Project.sources` is deprecated in favor of `Mix.Project.config_files`
3032
* [OptionParser] `:flags` option was deprecated in favor of `:switches` to support many types

lib/eex/test/eex_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ defmodule EExText.Compiled do
1010
{ :erlang, 1, 2 }.tuple_to_list
1111
EEx.function_from_string :def, :string_sample, "<%= a + b %>", [:a, :b]
1212

13-
filename = File.expand_path("../fixtures/eex_template_with_bindings.eex", __FILE__)
13+
filename = Path.expand("../fixtures/eex_template_with_bindings.eex", __FILE__)
1414
EEx.function_from_file :defp, :private_file_sample, filename, [:bar]
1515
def file_sample(arg), do: private_file_sample(arg)
1616

@@ -271,13 +271,13 @@ foo
271271
end
272272

273273
test "evaluates the source from a given file" do
274-
filename = File.expand_path("../fixtures/eex_template.eex", __FILE__)
274+
filename = Path.expand("../fixtures/eex_template.eex", __FILE__)
275275
result = EEx.eval_file(filename)
276276
assert result == "foo bar.\n"
277277
end
278278

279279
test "evaluates the source from a given file with bindings" do
280-
filename = File.expand_path("../fixtures/eex_template_with_bindings.eex", __FILE__)
280+
filename = Path.expand("../fixtures/eex_template_with_bindings.eex", __FILE__)
281281
result = EEx.eval_file(filename, [bar: 1])
282282
assert result == "foo 1\n"
283283
end

lib/elixir/lib/code.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ defmodule Code do
3535

3636
@doc """
3737
Appends a path to Erlang VM code path.
38-
The path is expanded with `File.expand_path` before added.
38+
The path is expanded with `Path.expand` before added.
3939
"""
4040
def append_path(path) do
41-
:code.add_pathz(File.expand_path to_char_list(path))
41+
:code.add_pathz(Path.expand to_char_list(path))
4242
end
4343

4444
@doc """
4545
Prepends a path to Erlang VM code path.
46-
The path is expanded with `File.expand_path` before added.
46+
The path is expanded with `Path.expand` before added.
4747
"""
4848
def prepend_path(path) do
49-
:code.add_patha(File.expand_path to_char_list(path))
49+
:code.add_patha(Path.expand to_char_list(path))
5050
end
5151

5252
@doc """
5353
Deletes a path from Erlang VM code path.
54-
The path is expanded with `File.expand_path` before deleted.
54+
The path is expanded with `Path.expand` before deleted.
5555
"""
5656
def delete_path(path) do
57-
:code.del_path(File.expand_path to_char_list(path))
57+
:code.del_path(Path.expand to_char_list(path))
5858
end
5959

6060
@doc """
@@ -366,9 +366,9 @@ defmodule Code do
366366
file = to_binary(file)
367367

368368
file = if relative_to do
369-
File.expand_path(file, relative_to)
369+
Path.expand(file, relative_to)
370370
else
371-
File.expand_path(file)
371+
Path.expand(file)
372372
end
373373

374374
if File.regular?(file) do

0 commit comments

Comments
 (0)