~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/kernel/src/code.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-07 15:07:37 UTC
  • mfrom: (1.2.1 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090507150737-i4yb5elwinm7r0hc
Tags: 1:13.b-dfsg1-1
* Removed another bunch of non-free RFCs from original tarball
  (closes: #527053).
* Fixed build-dependencies list by adding missing comma. This requires
  libsctp-dev again. Also, added libsctp1 dependency to erlang-base and
  erlang-base-hipe packages because the shared library is loaded via
  dlopen now and cannot be added using dh_slibdeps (closes: #526682).
* Weakened dependency of erlang-webtool on erlang-observer to recommends
  to avoid circular dependencies (closes: #526627).
* Added solaris-i386 to HiPE enabled architectures.
* Made script sources in /usr/lib/erlang/erts-*/bin directory executable,
  which is more convenient if a user wants to create a target Erlang system.
* Shortened extended description line for erlang-dev package to make it
  fit 80x25 terminals.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%% ``The contents of this file are subject to the Erlang Public License,
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
 
5
%% 
 
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
 
%% retrieved via the world wide web at http://www.erlang.org/.
 
10
%% retrieved online at http://www.erlang.org/.
6
11
%% 
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
11
16
%% 
12
 
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
 
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
 
%% AB. All Rights Reserved.''
15
 
%% 
16
 
%%     $Id$
 
17
%% %CopyrightEnd%
17
18
%%
18
19
-module(code).
19
20
 
367
368
 
368
369
-spec which(string(), string(), [string()]) -> 'non_existing' | string().
369
370
 
370
 
which(_,_,[]) ->
 
371
which(_, _, []) ->
371
372
    non_existing;
372
 
which(File,Base,[Directory|Tail]) ->
 
373
which(File, Base, [Directory|Tail]) ->
373
374
    Path = if
374
375
               Base =:= "." -> Directory;
375
376
               true -> filename:join(Directory, Base)
380
381
                true ->
381
382
                    filename:append(Path, File);
382
383
                false ->
383
 
                    which(File,Base,Tail)
 
384
                    which(File, Base, Tail)
384
385
            end;
385
386
        _Error ->
386
 
            which(File,Base,Tail)
 
387
            which(File, Base, Tail)
387
388
    end.
388
389
 
389
390
%% Search the code path for a specific file. Try to locate
390
391
%% it in the code path cache if possible.
391
392
 
392
 
-spec where_is_file(Filename :: string()) -> string() | atom().
 
393
-spec where_is_file(Filename :: string()) -> 'non_existing' | string().
393
394
 
394
395
where_is_file(File) when is_list(File) ->
395
396
    case call({is_cached,File}) of
400
401
            filename:join(Dir, File)
401
402
    end.
402
403
 
403
 
-spec(where_is_file/2 :: (Path :: string(), Filename :: string()) -> string() | atom()).
 
404
-spec where_is_file(Path :: string(), Filename :: string()) -> string() | atom().
404
405
 
405
406
where_is_file(Path, File) when is_list(Path), is_list(File) ->
406
407
    CodePath = get_path(),
416
417
            which(File, ".", Path)
417
418
    end.
418
419
 
419
 
-spec(set_primary_archive/2 :: (ArchiveFile :: string(), ArchiveBin :: binary()) -> 'ok' | {'error', atom()}).
 
420
-spec set_primary_archive(ArchiveFile :: string(), ArchiveBin :: binary()) -> 'ok' | {'error', atom()}.
420
421
 
421
422
set_primary_archive(ArchiveFile0, ArchiveBin) when is_list(ArchiveFile0), is_binary(ArchiveBin) ->
422
423
    ArchiveFile = filename:absname(ArchiveFile0),
433
434
    
434
435
%% Search the entire path system looking for name clashes
435
436
 
436
 
-spec(clash() -> 'ok').
 
437
-spec clash() -> 'ok'.
437
438
 
438
439
clash() ->
439
440
    Path = get_path(),
440
441
    Struct = lists:flatten(build(Path)),
441
442
    Len = length(search(Struct)),
442
 
    io:format("** Found ~w name clashes in code paths ~n",[Len]).
 
443
    io:format("** Found ~w name clashes in code paths ~n", [Len]).
443
444
 
444
445
%% Internal for clash/0
445
446