Hi,
I think I may be getting confused over what you are asking, so
apologies if the following doesn't answer your questions.
To use Cava::Pack::Resource.
put all the files you want to use under one folder. You can have as
complicated a directory structure under that folder as you wish. It
will all get packaged.
The changes you must make in your script are:
use Cava::Pack;
Cava::Pack::SetResourcePath('E:/Path/To/My/resource/Folder/anywhere/on/
filesystem');
you only have to do this once.
Then, to access the files, if you have a file
'E:/Path/To/My/resource/Folder/toolbar8/images/open.png'
you would do
my $filename = Cava::Pack::Resource('toolbar8/images/open.png');
This means your code will work both as a perl script or as a packaged
executable.
When packaging, just select 'E:/Path/To/My/resource/Folder' as the
resource directory.
Your current code may do:
my $filename = 'E:/Path/To/My/resource/Folder/toolbar8/images/
open.png';
or maybe you have a relative path because you always run the script
from within the directory where your script resides:
my $filename = '../toolbar8/images/open.png';
Neither is in any way portable.
The relative path assumes you always run the script from within the
directory where your script resides
So, if you do
perl.exe c:/full/path/to/my/perl/
script.pl
from anywhere but the directory that contains
script.pl, your relative
paths will fail.
Being lazy, I always create a package along the lines of:
package MyAppExport;
require Exporter;
use Cava::Pack;
Cava::Pack::SetResourcePath('E:/Path/To/My/resource/Folder/anywhere/on/
filesystem');
use base qw(Exporter);
our @EXPORT = qw( RF );
sub RF { Cava::Pack::Resource( shift ); }
This means that all I have to do at the top of my script is
use MyAppExport;
then, for file access
my $filename = RF('toolbar8/images/open.png');
There is nothing that says you are limited to using
Cava::Pack::Resource for packaging additional files.
All Cava::Packager does is create a directory structure.
Once Cava Packager has 'built' the dir structure, there's nothing to
stop you adding extra folders.
You could ignore Cava::Pack::Resource completely and add copies of all
your existing folders with your 'resource' files in at the right
relative location, and then
my $filename = '../myfolder/filename.ext';
would work with a packaged executable exactly as it does within your
perl script.
That is to say, so long as the current working directory is where the
executable or your script is when the executable or perl.exe is
executed, then all will be fine.
For the precise case you cite, just copy your res folder to the 'bin'
directory.
I'd have to say that I don't think this is practically useful.
I think that with any method of packaging a perl script you are going
to be faced with needing to change lines like
my $filename = '../myfolder/filename.ext';
Best Regards
Mark
On Nov 26, 12:03 am, "
aardvark...@gmail.com" <
aardvark...@gmail.com>
wrote: