IFileList.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #pragma once
  5. #include "IReferenceCounted.h"
  6. #include "path.h"
  7. namespace irr
  8. {
  9. namespace io
  10. {
  11. //! Provides a list of files and folders.
  12. /** File lists usually contain a list of all files in a given folder,
  13. but can also contain a complete directory structure. */
  14. class IFileList : public virtual IReferenceCounted
  15. {
  16. public:
  17. //! Get the number of files in the filelist.
  18. /** \return Amount of files and directories in the file list. */
  19. virtual u32 getFileCount() const = 0;
  20. //! Gets the name of a file in the list, based on an index.
  21. /** The path is not included in this name. Use getFullFileName for this.
  22. \param index is the zero based index of the file which name should
  23. be returned. The index must be less than the amount getFileCount() returns.
  24. \return File name of the file. Returns 0, if an error occurred. */
  25. virtual const io::path &getFileName(u32 index) const = 0;
  26. //! Gets the full name of a file in the list including the path, based on an index.
  27. /** \param index is the zero based index of the file which name should
  28. be returned. The index must be less than the amount getFileCount() returns.
  29. \return File name of the file. Returns 0 if an error occurred. */
  30. virtual const io::path &getFullFileName(u32 index) const = 0;
  31. //! Returns the size of a file in the file list, based on an index.
  32. /** \param index is the zero based index of the file which should be returned.
  33. The index must be less than the amount getFileCount() returns.
  34. \return The size of the file in bytes. */
  35. virtual u32 getFileSize(u32 index) const = 0;
  36. //! Returns the file offset of a file in the file list, based on an index.
  37. /** \param index is the zero based index of the file which should be returned.
  38. The index must be less than the amount getFileCount() returns.
  39. \return The offset of the file in bytes. */
  40. virtual u32 getFileOffset(u32 index) const = 0;
  41. //! Returns the ID of a file in the file list, based on an index.
  42. /** This optional ID can be used to link the file list entry to information held
  43. elsewhere. For example this could be an index in an IFileArchive, linking the entry
  44. to its data offset, uncompressed size and CRC.
  45. \param index is the zero based index of the file which should be returned.
  46. The index must be less than the amount getFileCount() returns.
  47. \return The ID of the file. */
  48. virtual u32 getID(u32 index) const = 0;
  49. //! Check if the file is a directory
  50. /** \param index The zero based index which will be checked. The index
  51. must be less than the amount getFileCount() returns.
  52. \return True if the file is a directory, else false. */
  53. virtual bool isDirectory(u32 index) const = 0;
  54. //! Searches for a file or folder in the list
  55. /** Searches for a file by name
  56. \param filename The name of the file to search for.
  57. \param isFolder True if you are searching for a directory path, false if you are searching for a file
  58. \return Returns the index of the file in the file list, or -1 if
  59. no matching name name was found. */
  60. virtual s32 findFile(const io::path &filename, bool isFolder = false) const = 0;
  61. //! Returns the base path of the file list
  62. virtual const io::path &getPath() const = 0;
  63. //! Add as a file or folder to the list
  64. /** \param fullPath The file name including path, from the root of the file list.
  65. \param isDirectory True if this is a directory rather than a file.
  66. \param offset The file offset inside an archive
  67. \param size The size of the file in bytes.
  68. \param id The ID of the file in the archive which owns it */
  69. virtual u32 addItem(const io::path &fullPath, u32 offset, u32 size, bool isDirectory, u32 id = 0) = 0;
  70. //! Sorts the file list. You should call this after adding any items to the file list
  71. virtual void sort() = 0;
  72. };
  73. } // end namespace irr
  74. } // end namespace io