aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/file.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-02-21 16:53:34 +0100
committerBjörn Gustavsson <[email protected]>2011-08-16 15:22:23 +0200
commit053fb064496043207cfa807c900077f9bbc4c7d1 (patch)
treee0de0000953388727538571bdf2c1cda28a7b27b /lib/kernel/src/file.erl
parent3347602be3c8a8bad3652c10e1e2db01315269e3 (diff)
downloadotp-053fb064496043207cfa807c900077f9bbc4c7d1.tar.gz
otp-053fb064496043207cfa807c900077f9bbc4c7d1.tar.bz2
otp-053fb064496043207cfa807c900077f9bbc4c7d1.zip
compiler: Don't create filenames starting with "./"
In the location information tables in the run-time system, source filenames that are the same as the module name plus ".erl" extension are not stored explicitly, thus saving memory. To take advantage of that optimization, avoid complicating the names of files in the current working directory; specifically, make sure that "./" is not prepended to the name.
Diffstat (limited to 'lib/kernel/src/file.erl')
-rw-r--r--lib/kernel/src/file.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index 5e4e1b0ba8..706c60caaf 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -1163,7 +1163,7 @@ path_open_first([Path|Rest], Name, Mode, LastError) ->
{error, _} = Error ->
Error;
FilePath ->
- FileName = filename:join(FilePath, Name),
+ FileName = fname_join(FilePath, Name),
case open(FileName, Mode) of
{ok, Fd} ->
{ok, Fd, FileName};
@@ -1176,6 +1176,11 @@ path_open_first([Path|Rest], Name, Mode, LastError) ->
path_open_first([], _Name, _Mode, LastError) ->
{error, LastError}.
+fname_join(".", Name) ->
+ Name;
+fname_join(Dir, Name) ->
+ filename:join(Dir, Name).
+
%%%-----------------------------------------------------------------
%%% Utility functions.