FileInterfaceDefault.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "../../Include/RmlUi/Core/FileInterface.h"
  3. #ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT
  4. namespace Rml {
  5. /**
  6. Implementation of the RmlUi file interface using the Standard C file functions.
  7. */
  8. class FileInterfaceDefault : public FileInterface {
  9. public:
  10. virtual ~FileInterfaceDefault();
  11. /// Opens a file.
  12. /// @param path The path of the file to open.
  13. /// @return A valid file handle, or nullptr on failure
  14. FileHandle Open(const String& path) override;
  15. /// Closes a previously opened file.
  16. /// @param file The file handle previously opened through Open().
  17. void Close(FileHandle file) override;
  18. /// Reads data from a previously opened file.
  19. /// @param buffer The buffer to be read into.
  20. /// @param size The number of bytes to read into the buffer.
  21. /// @param file The handle of the file.
  22. /// @return The total number of bytes read into the buffer.
  23. size_t Read(void* buffer, size_t size, FileHandle file) override;
  24. /// Seeks to a point in a previously opened file.
  25. /// @param file The handle of the file to seek.
  26. /// @param offset The number of bytes to seek.
  27. /// @param origin One of either SEEK_SET (seek from the beginning of the file), SEEK_END (seek from the end of the file) or SEEK_CUR (seek from
  28. /// the current file position).
  29. /// @return True if the operation completed successfully, false otherwise.
  30. bool Seek(FileHandle file, long offset, int origin) override;
  31. /// Returns the current position of the file pointer.
  32. /// @param file The handle of the file to be queried.
  33. /// @return The number of bytes from the origin of the file.
  34. size_t Tell(FileHandle file) override;
  35. };
  36. } // namespace Rml
  37. #endif /*RMLUI_NO_FILE_INTERFACE_DEFAULT*/