Page 1 of 1

Packages()

Posted: Sat Sep 23, 2006 8:02 am
by innominabile
Now packages report name sopports_http and npcdesc
Have on report all info loaded in pkg.cfg ?

Posted: Mon Oct 09, 2006 5:44 pm
by Austin
None of that is really stored, with the exception of the package name, and its version.

The solution to use it would be make an include that uses file.em and read it in that way.

Code: Select all

use os;
use file;

/*
 * GetPackageCfgInfo(pkg_name)
 *
 * Purpose
 * Reads a pkg.cfg for a package and returns its information.
 *
 * Parameters
 * pkg_name:	Name of the package to retrieve the information for.
 *
 * Return Value
 * Returns a dictionary on success.
 * Returns an error on failure.
 *
 */

function GetPackageCfgInfo(pkg_name)
	var info := dictionary;
	var pkgfile := ReadFile(":"+pkg_name+":pkg.cfg");
	if ( pkgfile.errortext )
		return pkgfile; // Contains an error.
	endif

	foreach line in ( pkgfile )
		var parsed := SplitWords(line);
		var key := parsed[1];

		var pos := Find(line, parsed[2], Len(parsed[1])+1);
		var value := line[pos, Len(line)];

		info[key] := value;
		SleepMs(2);
	endforeach

	return info;
endfunction

Posted: Wed Oct 11, 2006 10:05 am
by innominabile
Thanks :-))) Very nice.