File management¶
libcasio manages the file formats through a file API where you can open and decode a file, and export data into a file. A file is primarily represented by its type and platform:
-
type
casio_filetype_t
¶ An enumeration defining various file types that file formats libcasio can read and write can represent. The values in this enumeration are defined as flags so that such a value can also represent multiple file types with no ambiguity.
-
casio_filetype_addin
¶ An add-in, i.e. a binary application which executes natively onto the calculator from the storage filesystem(s). The platform cannot be
casio_filefor_none
for this type.
-
casio_filetype_add_in
¶ An alias for
casio_filetype_addin
.
-
casio_filetype_mcs
¶ A main memory backup, see Main filesystems for more details about what a main memory is.
-
casio_filetype_eact
¶ An e-activity, i.e. rich document for storing courses for example.
-
casio_filetype_e_activity
¶ An alias for
casio_filetype_eact
.
-
casio_filetype_eactivity
¶ An alias for
casio_filetype_eact
.
-
casio_filetype_picture
¶ A picture, e.g.
*.g3p
files.
-
casio_filetype_pict
¶ An alias for
casio_filetype_picture
.
-
casio_filetype_lang
¶ A language file, which contains message translations with IDs, e.g.
*.g1l
or*.g3l
files.
-
casio_filetype_fkey
¶ A function key file, which contains function key pictures with IDs in the same fashion than language files, e.g.
*.g1n
files.
-
casio_filetype_storage
¶ A storage filesystem backup, typically
*.g1s
files.
-
-
type
casio_filefor_t
¶ An enumeration defining various platforms for which the file formats libcasio can read and write can be made for. The values in this enumeration are defined as flags so that such a value can also represent multiple file platforms with no ambiguity.
-
casio_filefor_none
¶ No platform in particular; this value always evaluates as zero, so that any other value in this enumeration can make it precise.
-
casio_filefor_fx
¶ The fx-9860G family of calculators, OS 1.x and OS 2.x.
-
casio_filefor_cp
¶ The Classpad family of calculators, e.g. the fx-CP400.
-
casio_filefor_cg
¶ The Prizm family of calculators, including the fx-CG10, fx-CG20 and fx-CG50 (Graph 90+E).
-
casio_filefor_cas
¶ Ancient calculators supporting the CAS40 and CAS50 protocols.
-
casio_filefor_casemul
¶ The CasEmul software.
-
It is represented by the following object:
-
type
casio_file_t
¶ A decoded file of one of the supported file formats by libcasio.
Creating and freeing a file¶
A file can be created using one of the following functions:
-
int
casio_make_picture
(casio_file_t **filep, unsigned int width, unsigned int height)¶ Create a picture file using the given dimensions.
-
int
casio_make_mcs
(casio_file_t **filep)¶ Create a main memory backup file.
-
int
casio_make_fkey
(casio_file_t **filep, casio_filefor_t filefor, int count)¶ Create a function key file for the platform given in
filefor
, withcount
slots.
-
int
casio_make_lang
(casio_file_t **filep, casio_filefor_t filefor, int count)¶ Create a language file for the platform given in
filefor
, withcount
slots.
-
int
casio_make_addin
(casio_file_t **filep, casio_filefor_t filefor, size_t size, char const *name, char const *internal, casio_version_t const *versionp, time_t const *created)¶ Create an add-in file for the platform given in
filefor
, withsize
bytes for the code,name
as the public name,internal
as the internal name (usually starting with@
),versionp
pointing to the version structure, andcreated
being the time of creation.
Once you’re done using a file, you shall use the following function:
-
void
casio_free_file
(casio_file_t *file)¶ Free the file and all of its related resources.
Decoding a file¶
A file is decoded from a generic stream, using the following function:
-
int
casio_decode
(casio_file_t **filep, char const *filename, tio_stream_t *buffer, casio_filetype_t expected_types)¶ Create a file from the stream in
buffer
, intofilep
. If you have the filename, you shall pass it infilename
(if not, just passNULL
), this function will also try to guess the file type using the detected extension or filename (which has a significance for some file formats, e.g. ancient file formats managed by CaS).If you don’t know what format you expect, pass zero to
expected_types
. Otherwise, use the types as flags, e.g.casio_filetype_picture | casio_filetype_mcs | casio_filetype_storage
if you expect to find some pictures (main memory can contain pictures).