- installed packages and dependencies are now saved into binary files
[scilab.git] / scilab / modules / atoms / macros / atoms_internals / atomsGetDepChilds.sci
index 5b7e6e5..9b79e89 100644 (file)
@@ -7,7 +7,7 @@
 // are also available at
 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
 
-// Returns true if a package is installed, false otherwise
+// Give the list of packages needed by this package (identified by its name and version)
 
 function packages = atomsGetDepChilds(name,version,allusers)
        
@@ -55,63 +55,27 @@ function packages = atomsGetDepChilds(name,version,allusers)
                end
        end
        
-       // Define the differents path of the file where are installed
+       // Load the installed_deps struct
        // =========================================================================
        
-       installed_deps_files = [];
-       user_file            = pathconvert(SCIHOME+"/atoms/installed_deps",%F);
-       alluser_file         = pathconvert(SCI+"/.atoms/installed_deps",%F);
-       
-       if fileinfo(user_file)<>[] then
-               installed_deps_files = [ installed_deps_files ; user_file "user" ];
+       if allusers then
+               // all packages
+               installed_deps = atomsLoadInstalleddeps("all");
+       else
+               // user packages
+               installed_deps = atomsLoadInstalleddeps(%F);
        end
        
-       if allusers & (fileinfo(alluser_file)<>[]) then
-               installed_deps_files = [ installed_deps_files ; alluser_file "allusers"];
+       // If name - version is not a field of the struct, the job is done
+       // =========================================================================
+       
+       if ~ isfield(installed_deps,name+" - "+version) then
+               return;
        end
        
-       // Loop on each "installed_deps" file specified as first input argument
+       // Return the matrix associated with the wanted package (name - version)
        // =========================================================================
        
-       found = 0;
-       
-       for i=1:size(installed_deps_files(:,1),"*")
-               
-               if found == 1 then
-                       break;
-               end
-               
-               // Get the installed package list in this file
-               installed_deps_lines = mgetl(installed_deps_files(i,1));
-               
-               // Loop on each lines
-               for j=1:size(installed_deps_lines,"*")
-                       
-                       // If this line is a "parent toolbox" or a blank line and the wanted toolbox is already found
-                       // Break the loop
-                       
-                       if (found == 1) & ..
-                               ( (regexp(installed_deps_lines(j),"/^\[(.)*\]$/","o") <> []) | isempty(installed_deps_lines(j)) ) then
-                               break;
-                       end
-                       
-                       // Yeah, the wanted toolbox has been found
-                       
-                       if installed_deps_lines(j) == "["+name+" - "+version+"]" then
-                               found = 1;
-                               continue;
-                       end
-                       
-                       // This line is a inevitably a toolbox
-                       if found == 1 then
-                               this_line           = stripblanks(installed_deps_lines(j));
-                               current_name_length = regexp(this_line,"/\s-\s/","o");
-                               current_name        = part(this_line,1:current_name_length-1);
-                               current_version     = part(this_line,current_name_length+3:length(this_line));
-                               packages            = [ packages ; current_name current_version];
-                       end
-                       
-               end
-       end
+       packages = installed_deps(name+" - "+version);
        
 endfunction