Guest User

DasOS File API

a guest
Aug 7th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. enum FILETYPE
  2. {
  3.     ftUNKNOWN, ftFILE, dtDIRECTORY,
  4. };
  5.  
  6. // GENERIC API
  7.  
  8. /**
  9.  * Opens a file and gets a file handle.
  10.  */
  11. int fs_open(char *name);
  12.  
  13. /**
  14.  * Returns the type of the given file.
  15.  */
  16. FILETYPE fs_type(int file);
  17.  
  18. /**
  19.  * Releases a file handle.
  20.  */
  21. void fs_close(int file);
  22.  
  23. // FILE API
  24.  
  25. /**
  26.  * Reads a block of data from a file.
  27.  * @param file   The file handle.
  28.  * @param buffer The target memory
  29.  * @param offset The start position in the file
  30.  * @param length Number of bytes to read.
  31.  * @return       Number of bytes read.
  32.  */
  33. uint32_t file_read(
  34.     int file,
  35.     void *buffer,
  36.     uint32_t offset,
  37.     uint32_t length);
  38.  
  39. /**
  40.  * Returns the length of a file in bytes.
  41.  */
  42. uint32_t file_length(int file);
  43.  
  44. // DIRECTORY API
  45.  
  46. struct NODE
  47. {
  48.     char name[FILENAME_MAXLEN];
  49.     FILETYPE type;
  50. };
  51.  
  52. /**
  53.  * Returns the number of entries in a directory.
  54.  * @param file The file handle.
  55.  */
  56. uint32_t dir_length(int file);
  57.  
  58. /**
  59.  * Gets a directory entry.
  60.  * @param file  The file handle
  61.  * @param index The index of the node in the directory.
  62.  * @param node  A pointer to a node to store the information.
  63.  */
  64. bool dir_get(int file, int index, NODE *node);
Advertisement
Add Comment
Please, Sign In to add comment