hSuite File
Locations
for hSuite Standalone Compilation
About Assets All files that you need to exist 'before' you start your app must be under [source] , [data] , or [databases] of you project base. These are called 'supported' directories. [data] and [databases] must be indicated via hSuite options. All the above files are known as Assets files. They are read-only and are embedded into the package as a virtual file-system. Internally, this VFS is a file that pretends to be a disk drive. Files outside these supported directories will not get copied to assets, so will not exist before your app runs. However, files outside these supported directories can be created 'after' your app runs. And they can even have the same names and paths as the Assets files. The difference is that they will be created on the 'real ' file system.
Files can be created by your app code e.g using the
TEXT and BYTE commands. Assets vs Real
FilesThese files will created on the real file system (not Assets) on external storage (sdcard). App created files are more flexible. They are writable and can be put anywhere under the [app_path] directory. This is the directory just above [source], [data] and [databases]. ( In fact, you even have write-access to [app_path]'s parent [com.rfo.myApp] ) which is the start of scoped-storage. You can also create paths that are identical to Assets paths in supported directories (see below). If an App creates a file with the same name as one in Assets e.g <..>/data/cartman.png then you will have two different files of the same name on the same path. The general rule for most commands is to first look on the real file system (sdcard). If it doesn't exist, then Basic will look inside Assets. e.g FILE.OPEN, FILE.TYPE.. etc The Exceptions to this rule is
a)
RUN
- Only looks in Assets b) FILE.EXISTS - Only looks in real file system (sdcard i.e external).
Files to load at
startup
Legacy Basic and perhaps other apk makers have a
feature that supports copying files from read-only
assets to the real-file-system during apk creation.
These files will be copied to external storage (sdcard)
at every
program startup !!, overwriting any changes you
may have made. This is undesirable in many
situations.
hSuite does not support this feature,
due to the confusion it creates.
If you need files that need copying from assets to
external storage (sdcard), then the program must
do this
itself ,
e.g
file.exists
e, "settings.dat"
% looks only on
sdcard/data if !e then % if not exist on sdcard /data byte.open r,fv, "settings.dat" % get it from assets if fv<>-1 then byte.copy fv,"settings.dat" % make a copy to sdcard/data endif The above manual method is much clearer and user-controllable. File.Exists only looks in file system. Does not look into /assets/ File.Type first looks in the file system, if not found then looks in /assets/ file.exists e, paths$ % look only in the file system if e then print "file is on sdcard" else % not in file system file.type typ$, path$ if typ$="x" then print "file does not exist anywhere" else print "file is in assets" endif endif |
||||||||||
-End. |