FileInterfaceDefault.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019-2023 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #ifndef RMLUI_CORE_FILEINTERFACEDEFAULT_H
  29. #define RMLUI_CORE_FILEINTERFACEDEFAULT_H
  30. #include "../../Include/RmlUi/Core/FileInterface.h"
  31. #ifndef RMLUI_NO_FILE_INTERFACE_DEFAULT
  32. namespace Rml {
  33. /**
  34. Implementation of the RmlUi file interface using the Standard C file functions.
  35. @author Peter Curry
  36. */
  37. class FileInterfaceDefault : public FileInterface {
  38. public:
  39. virtual ~FileInterfaceDefault();
  40. /// Opens a file.
  41. /// @param path The path of the file to open.
  42. /// @return A valid file handle, or nullptr on failure
  43. FileHandle Open(const String& path) override;
  44. /// Closes a previously opened file.
  45. /// @param file The file handle previously opened through Open().
  46. void Close(FileHandle file) override;
  47. /// Reads data from a previously opened file.
  48. /// @param buffer The buffer to be read into.
  49. /// @param size The number of bytes to read into the buffer.
  50. /// @param file The handle of the file.
  51. /// @return The total number of bytes read into the buffer.
  52. size_t Read(void* buffer, size_t size, FileHandle file) override;
  53. /// Seeks to a point in a previously opened file.
  54. /// @param file The handle of the file to seek.
  55. /// @param offset The number of bytes to seek.
  56. /// @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
  57. /// the current file position).
  58. /// @return True if the operation completed successfully, false otherwise.
  59. bool Seek(FileHandle file, long offset, int origin) override;
  60. /// Returns the current position of the file pointer.
  61. /// @param file The handle of the file to be queried.
  62. /// @return The number of bytes from the origin of the file.
  63. size_t Tell(FileHandle file) override;
  64. };
  65. } // namespace Rml
  66. #endif /*RMLUI_NO_FILE_INTERFACE_DEFAULT*/
  67. #endif