core: add BFile_FindFirst, Next and Close syscalls

The return code -1 noted in the BFile_FindFirst or BFile_FindNext is
from test,  which mean it could be possibles that they are negative
error code from functions failing and not meaning that no file have been
found, to be sure, the value IML_FILEERR_ENUMERATEEND from filebios.h in
the fxlib need to be checked (and maybe defined in gint with a more
meaningful name for user interactivity)
This commit is contained in:
Alice 2020-01-13 23:09:18 +01:00
parent 07e2de981a
commit 32aef78600
2 changed files with 52 additions and 0 deletions

View File

@ -84,4 +84,41 @@ int BFile_Write(int fd, void const *data, int even_size);
Returns a BFile error code. */
int BFile_Read(int handle, void *data, int size, int whence);
/* BFile_FindFirst(): Search a directory for file with matching name.
Doesn't work on Main memory.
Only four search handle can be opened, you need to close them to be able to reuse them.
Search is NOT case sensitive and * can be used to match any string.
@search FONTCHARACTER file path to match
@shandle Search handle to pass to BFile_FindNext or BFile_FindClose
@founfile FONTCHARACTER found file path
@fileinfo Structure containing a lot of information on the found file
Return 0 on success, -1 if no file found, or negative value on error. */
typedef struct tag_FILE_INFO
{
unsigned short id; //file index
unsigned short type; //file type
unsigned long fsize; //file size
unsigned long dsize; //date size (file - header)
unsigned int property; //if 0 file complete
unsigned long adress; //top adress of data (direct access is unadvised)
} FILE_INFO;
int BFile_FindFirst(uint16_t const *search, int *shandle, uint16_t *foundfile, FILE_INFO *fileinfo);
/* BFile_FindNext(): Continue a search a directory for file with matching name.
Only four search handle can be opened, u need to close them to be able to reuse them.
@shandle Search handle from BFile_FindFirst
@founfile FONTCHARACTER found file path
@fileinfo Structure containing a lot of information on the found file
Return 0 on success, -1 if no file found, or negative value on error. */
int BFile_FindNext(int shandle, uint16_t *foundfile, FILE_INFO *fileinfo);
/* BFile_FindClose(): Close the specified search handle
Only four search handle can be opened, u need to close them to be able to reuse them.
@shandle Search handle from BFile_FindFirst
Return 0 on success or negative value on error. */
int BFile_FindClose(int shandle);
#endif /* GINT_BFILE */

View File

@ -26,6 +26,9 @@
.global _BFile_Size
.global _BFile_Write
.global _BFile_Read
.global _BFile_FindFirst
.global _BFile_FindNext
.global _BFile_FindClose
.section ".pretext"
@ -84,6 +87,18 @@ _BFile_Write:
_BFile_Read:
syscall(0x0432)
# int BFile_FindFirst(uint16_t const *search, int *shandle, uint16_t *foundfile, FILE_INFO *fileinfo)
_BFile_FindFirst:
syscall(0x043b)
# int BFile_FindNext(int shandle, uint16_t *foundfile, FILE_INFO *fileinfo)
_BFile_FindNext:
syscall(0x043c)
# int BFile_FindClose(int shandle)
_BFile_FindClose:
syscall(0x043d)
syscall_table:
.long 0x80010070