aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-04-30 07:11:45 +0200
committerBjörn Gustavsson <[email protected]>2016-04-30 07:25:25 +0200
commit126fb0a9046ac8c01889fd742d77d4e0bd34592a (patch)
treec15202b3ee7b8f441b44511ccd5b98f6f3f0ddd6 /lib/kernel
parent73b178c348c58783d470914d1cf105729d85f9bc (diff)
downloadotp-126fb0a9046ac8c01889fd742d77d4e0bd34592a.tar.gz
otp-126fb0a9046ac8c01889fd742d77d4e0bd34592a.tar.bz2
otp-126fb0a9046ac8c01889fd742d77d4e0bd34592a.zip
Introduce split_base/1 to split into name and version string
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/code_server.erl33
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index d1c603cef3..4f46be27db 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -381,12 +381,10 @@ choose_bundles(Bundles) ->
create_bundle(FullName, ArchiveExt) ->
BaseName = filename:basename(FullName, ArchiveExt),
- case split(BaseName, "-") of
- [_, _|_] = Toks ->
- VsnStr = lists:last(Toks),
+ case split_base(BaseName) of
+ {Name, VsnStr} ->
case vsn_to_num(VsnStr) of
{ok, VsnNum} ->
- Name = join(lists:sublist(Toks, length(Toks)-1),"-"),
{Name,VsnNum,FullName};
false ->
{FullName,[0],FullName}
@@ -472,9 +470,8 @@ make_path(BundleDir, [Bundle|Tail], Res) ->
Base = filename:basename(Bundle, Ext),
Ebin2 = filename:join([BundleDir, Base ++ Ext, Base, "ebin"]),
Ebins =
- case split(Base, "-") of
- [_, _|_] = Toks ->
- AppName = join(lists:sublist(Toks, length(Toks)-1),"-"),
+ case split_base(Base) of
+ {AppName,_} ->
Ebin3 = filename:join([BundleDir, Base ++ Ext,
AppName, "ebin"]),
[Ebin3, Ebin2, Dir];
@@ -633,6 +630,16 @@ discard_after_hyphen([H|T]) ->
discard_after_hyphen([]) ->
[].
+split_base(BaseName) ->
+ case split(BaseName, "-") of
+ [_, _|_] = Toks ->
+ Vsn = lists:last(Toks),
+ AllButLast = lists:droplast(Toks),
+ {join(AllButLast, "-"),Vsn};
+ [_|_] ->
+ BaseName
+ end.
+
check_path(Path) ->
PathChoice = init:code_path_choice(),
ArchiveExt = archive_extension(),
@@ -809,16 +816,12 @@ do_insert_name(Name, AppDir, Db) ->
true.
archive_subdirs(AppDir) ->
- Ext = archive_extension(),
Base = filename:basename(AppDir),
- Dirs =
- case split(Base, "-") of
- [_, _|_] = Toks ->
- Base2 = join(lists:sublist(Toks, length(Toks)-1), "-"),
- [Base2, Base];
- _ ->
- [Base]
+ Dirs = case split_base(Base) of
+ {Name, _} -> [Name, Base];
+ _ -> [Base]
end,
+ Ext = archive_extension(),
try_archive_subdirs(AppDir ++ Ext, Base, Dirs).
try_archive_subdirs(Archive, Base, [Dir | Dirs]) ->