Main Site Contents Up Previous Next

Utility Functions


Cava::Packager::GetScriptCommand($scriptname, $perloptions, @args);

Accepts a script-name, a reference to Perl options or a scalar string containing Perl options, and any arguments to the script. Returns an appropriate command line whether the script is running packaged or under Perl.

Returns a string in a scalar context. An array in a list context;

Cava Packager allows you to package many scripts as executables, sharing the same packaged Modules and libraries. For example, in Cava Packager itself, two scripts are packaged:

packager.pl
console.pl

The console.pl script is called from packager.pl to scan and build projects. In development, our module tree is at ../cavalib relative to the script location. To run console.pl, we do:

my @commandparts = Cava::Packager::GetScriptCommand('console.pl', ['-I../cavalib'], @myargs);

Running under Perl this returns:

( $^X, '-I../cavalib', @myargs)

or in a scalar context

'$^X -I../cavalib arg1 arg2 arg3'

Running when packaged it returns:

( $fullpathtocavaconsoleexe, @myargs)

or in a scalar context

'/full/path/cavaconsole arg1 arg2 arg3'

In the packaged application, the Perl options are dropped. We also do not have to care what the packaged executable is called or where it is in the final distribution tree. If $^X or $pathtopackagedexecutable contains spaces, it is quoted. All other params are returned unaltered.


Cava::Packager::UserName();

Returns the current username. Under MS Windows, returns the current login. Under MacOSX and Linux, returns the effective user as given by (getpwuid($<))[0]


Cava::Packager::IsWindows();

Returns true if the OS is Windows. False otherwise.


Cava::Packager::IsLinux();

Returns true if the OS is Linux. False otherwise


Cava::Packager::IsMac();

Returns true if the OS is MacOSX. False otherwise.


Cava::Packager::IsPackaged();

Returns true if the application is running as a package cava app. False if running standard Perl.


Cava::Packager::IsGUI();

Returns true if the packaged executable was packed with the GUI flag set to true. False otherwise. Always returns false if running under standard Perl.





Contents Up Previous Next


Cava Packager Copyright © 2006-2012 Mark Dootson