home | |||
links |
|
||
developer's mag main page article part 1 part 2 part 3 part 4 part 5 part 6 part 7 |
2 - A File Pick DialogTo start, we can look at a bit of code for file management. This column's sample program (along with source code) contains a dialog that simply lists all the programs (.FXE files) in the system, and allows a selection. Although it's ready for reuse, it also lends itself well to tinkering, and can be a starting point for your own file dialog. Calling it is a matter of including the dlg_file.cpp file in your project, and calling one function:bool OpenDialog(ebo_enumerator_t *info,const char *ext); You pass a pointer to an ebo_enumerator_t structure and an extension string (case insensitive) and get back a filled structure and true, or false if no selection made. This dialog scans the MMC and main RAM, or just main RAM if there is no MMC, making this a good general-purpose dialog for file selection. To understand the results returned, we need to delve into the ebm code internals a little, starting with the ebo_enumerator_t structure: struct ebo_enumerator_t { int index; // file system index ebo_name_t name; // file name struct EBO_U32 publisher_revision; // publisher info EBO_U32 size; // file size EBO_U32 flags; // various flags EBO_U32 minimum_os; // OS requirement EBO_U32 mod_cnt; // modification count EBO_U32 modh_cnt; // mod. count (header) EBO_U32 vdev; // file device }; Some interesting fields in this structure: 'index', which indicates where in the file system this entry exists; 'size', which is the file size (not necessarily rounded to a page size); and 'vdev', which tells us the location of the file (zero if in RAM, non-zero otherwise). For our dialog, this entry makes for a handy way to test if a file resides in RAM or on the MMC. Finally, another important field, 'name' is actually the ebo_name_t structure, which provides a great deal of file information, and which we've seen before: struct ebo_name_t { char secure_type[EBO_LEN_STYPE]; char publisher[EBO_LEN_PUB]; char name[EBO_LEN_NAME]; char extension[EBO_LEN_EXT]; }; Previous Section Next Section |
||
Copyright © 2001-2006 ebmDevMag.com - Legal Notice |