[Gambas-user] accessing "embedded" project files from Shell command

Tobias Boege taboege at ...626...
Thu Aug 28 22:14:20 CEST 2014


On Thu, 28 Aug 2014, Kevin Fishburne wrote:
> When you store data files in the project directory and compile the 
> program those files are contained within the resulting .gambas 
> executable. From within the program they can be accessed as though they 
> were in the current directory. Is it possible to access (read only) 
> those files using a command executed by Shell? For example:
> 
> Shell "cat ./FileInProject"
> 
> I'm making a very simple SoundFont previewer that calls fluidsynth with 
> the passed SoundFont and a MIDI file embedded in the project/executable.
> 
> I could load the embedded file then write it to the user's /tmp 
> directory and pass that to fluidsynth, but won't if I don't have to.
> 

No, the file is compiled into the .gambas archive. When your Gambas code
executes, the interpreter takes care of those relative paths and maps
them to the correct places in the (mmap'd?) archive file. An external
shell can't do that.

If there is some data you normally need during execution, it might be
better to provide an installation packages which puts these files to
/usr/share.

But otherwise you can "unpack" the archive once your program starts up
by recursively copying the "." directory (or any subdirectory of that)
from inside the Gambas process. We had a thread around here yesterday
or so which shows how to copy directories recursively. Then refer to the
files using the temporary location you unpacked them to.

Regards,
Tobi

PS: Or what Benoit said... BTW: is the .gambas file in a Gambas-specific
    archive format?

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list