IFileList.h 4.0 KB

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