File.pkg 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. $#include "File.h"
  2. /// File open mode.
  3. enum FileMode
  4. {
  5. FILE_READ = 0,
  6. FILE_WRITE,
  7. FILE_READWRITE
  8. };
  9. /// %File opened either through the filesystem or from within a package file.
  10. class File : public Deserializer
  11. {
  12. public:
  13. /// Read bytes from the file. Return number of bytes actually read.
  14. virtual unsigned Read(void* dest, unsigned size);
  15. /// Set position from the beginning of the file.
  16. virtual unsigned Seek(unsigned position);
  17. /// Return the file name.
  18. virtual const String& GetName() const;
  19. /// Return a checksum of the file contents using the SDBM hash algorithm.
  20. virtual unsigned GetChecksum();
  21. /// Open a filesystem file. Return true if successful.
  22. bool Open(const String& fileName, FileMode mode = FILE_READ);
  23. /// Open from within a package file. Return true if successful.
  24. bool Open(PackageFile* package, const String& fileName);
  25. /// Close the file.
  26. void Close();
  27. /// Flush any buffered output to the file.
  28. void Flush();
  29. /// Change the file name. Used by the resource system.
  30. void SetName(const String& name);
  31. /// Return the open mode.
  32. FileMode GetMode() const;
  33. /// Return whether is open.
  34. bool IsOpen() const;
  35. /// Return the file handle.
  36. void* GetHandle() const;
  37. /// Return whether the file originates from a package.
  38. bool IsPackaged() const;
  39. };