How to include resource files to maked executable?
Posted
#1
(In Topic #1039)
Regular

Code (gambas)
Posted
Guru

place your files in there.
access like
a .public folder gets compiled with the archive and it's contents available at runtime. do not use Application.Path just use ./
Note: using Picture.Load() will load from disk each time
using Picture["/path/to/pic.jpg"] loads using cache if already loaded once before using the same method.
Posted
Regular

All files inside your project, as long as they are not in the .hidden directory WILL be included automatically in your "executable" (which is an archive accessed by gbr3/gbx3 and not an executable btw).
Your problem is not understanding how to refer to files inside that archive. The answer lies in the way the runtime accesses "relative paths". See /lang/path - Gambas Documentation
In particular, it is usual to just put your images in the "Data" "folder" in the project, then they are accessible easily as
Code
Picture["./pic.jpg"]b
p.s. you can also use subdirs inside "Data" as well if you want to keep things even more tidy. e.g.
Code
Picture["./images/pic.jpg"
Posted
Regular

BruceSteers said
Make a folder in your projects main dir called .public and place your files in there.
The .public folder gets compiled with the archive and it's contents available at runtime.
Do not use Application.Path just use ./
Thank you. It's working.
Posted
Regular

thatbruce said
Your problem is understanding how to refer to files inside that archive. The answer lies in the way the runtime accesses "relative paths". See /lang/path - Gambas Documentation
In particular, it is usual to just put your images in the "Data" "folder" in the project, then they are accessible easily asCode
Picture["./pic.jpg"]
b
p.s. you can also use subdirs inside "Data" as well if you want to keep things even more tidy. e.g.Code
Picture["./images/pic.jpg"
So my files were included with my .gambas file all along. And I did not need that .public folder. Thank you for this clarification. This way of accessing my svg files is working splendidly.
Posted
Guru

Good luck.
Posted
Regular

IIRC "./" refers to the actual executable archive and if that is a library or a component then it is not the running project. In that case one has to refer to "../" - a fine point but a trap that did cause me some confusion when I was younger.
b
Posted
Guru

Ie. the .public folder is hidden and packs contents into archive okay.
a folder called .images that is hidden does not seem to work
a folder called images does.
Posted
Regular

Some years ago I wrote a wiki page about just what is in a Gambas project directory and in particular what happens to the contents when the executable archive is created. I can't find it anymore which is sad (it did take a fair bit of work to figure it all out at the time). IIRC!.. I thought that generally speaking, everything relevant except ".hidden" and its contents were included (of course the compiler and translator work files and directories were excluded :? )
Your comment makes me wonder now whether there are other "dot" files and directories that are excluded that we don't know about. So ".public" is but ".images" isn't. Strange, weird even.
bests
b
Posted
Guru

i put 2 files, one named icon.png the other .icon.png in a folder called img and also in a folder called .img. this was the result from ls -aR, then gba3 -l on the compiled executable …
<HIGHLIGHT highlight="shell">
bonus@bonus-G33M-DS2R:~/Desktop/_aa$ ls -aR
.:
. _aa.gambas content.txt .gambas .hidden .img .lang .settings .startup
.. .action .directory .gitignore .icon.png img .project .src
./.action:
. ..
./.gambas:
. .. FORM1
./.hidden:
. ..
./.img:
. .. .icon.png icon.png
./img:
. .. .icon.png icon.png
./.lang:
. ..
./.src:
. .. Form1.class Form1.class~ Form1.form Form1.form~
bonus@bonus-G33M-DS2R:~/Desktop/_aa$ gba3 -l ./_aa.gambas
.startup
.project
.action
.gambas
.lang
content.txt
img
.gambas/FORM1
img/icon.png
</HIGHLIGHT>
the only icon in the archive is the non-hidden img/icon.png
no .icon.png and no .img folder
Respects
Posted
Regular

(i anf trying to type thiss on a bus. and given up fixing mistaked)
b
1 guest and 0 members have just viewed this.


