Alternative library and kernel for add-in development on fx-9860G and fx-CG50 under Linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.6KB

  1. //---
  2. // gint:bfile - BFile interface
  3. //
  4. // The system's file system is a nightmare and the risk of corrupting it
  5. // or the flash by driving it manually is too great to risk. This module
  6. // interfaces with the BFile syscalls for file management.
  7. //---
  8. #ifndef GINT_BFILE
  9. #define GINT_BFILE
  10. #include <stdint.h>
  11. /* BFile_Remove(): Remove a file
  12. Also works if the file does not exist.
  13. @file FONTCHARACTER file path
  14. Returns a BFile error code. */
  15. int BFile_Remove(uint16_t const *file);
  16. /* BFile_Create(): Create a new entry
  17. The file or directory must not exist. For a file the size pointer must point
  18. to the desired file size (which is fixed), for a folder it is ignored.
  19. @file FONTCHARACTER file path
  20. @type Entry type
  21. @size Pointer to file size if [type = BFile_File], ignored otherwise
  22. Returns a BFile error code. */
  23. enum BFile_EntryType
  24. {
  25. BFile_File = 1,
  26. BFile_Folder = 5,
  27. };
  28. int BFile_Create(uint16_t const *file, enum BFile_EntryType type, int *size);
  29. /* BFile_Open(): Open an existing file
  30. The file must exist.
  31. @file FONTCHARACTER file path
  32. @mode Desired access mode
  33. Returns a file descriptor on success, or a negative BFile error code. */
  34. enum BFile_OpenMode
  35. {
  36. BFile_ReadOnly = 0x01,
  37. BFile_WriteOnly = 0x02,
  38. BFile_ReadWrite = BFile_ReadOnly | BFile_WriteOnly,
  39. };
  40. int BFile_Open(uint16_t const *file, enum BFile_OpenMode mode);
  41. /* BFile_Close(): Close a file descriptor
  42. @fd Open file descriptor
  43. Returns a BFile error code. */
  44. int BFile_Close(int fd);
  45. /* BFile_Write(): Write data to an open file
  46. Second and third argument specify the data and length to write.
  47. WARNING: The file systems has shown to become inconsistent if an odd number
  48. of bytes is written with BFile_Write(). Keep it even!
  49. @fd File descriptor open for writing
  50. @data Data to write
  51. @even_size Size to write (must be even, yes)
  52. Returns a BFile error code. */
  53. int BFile_Write(int fd, void const *data, int even_size);
  54. /* BFile_Read(): Read data from an open file
  55. The second and third argument specify where to store and how much to read.
  56. The location from where the data is read depends on [whence]:
  57. * If [whence >= 0], it is taken as an absolute location within the file;
  58. * If [whence == -1], BFile_Read() reads from the current position.
  59. @fd File descriptor open for reading
  60. @data Buffer of at least [size] bytes to store data to
  61. @size Number of bytes to read
  62. @whence Starting position of the data to read in the file
  63. Returns a BFile error code. */
  64. int BFile_Read(int handle, void *data, int size, int whence);
  65. #endif /* GINT_BFILE */