NeroFileSystemContent.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / NeroAPI
  10. |*
  11. |* PROGRAM: NeroFileSystemContent.h
  12. |*
  13. |* PURPOSE:
  14. |* This is the third NeroAPI interface for preparing data CDs/DVDs. Unlike NeroIsoTrack.h,
  15. |* it is not much "callback based",thus most of the process will be driven by the
  16. |* application, making it easier to write. This interface is closely connected to the
  17. |* internal engine of NeroAPI, this improves the cooperation of NeroAPI and the application.
  18. |*
  19. |* This set of classes describe the content of the file system of a disc.
  20. |* The application will build a file structure using the IFileSystemContent object.
  21. |* During the burn process, NeroAPI will request the content of files using the
  22. |* IFileContent interface.
  23. |*
  24. |* Use the NeroCreateFileSystemContainer function of NeroAPI.h to get an instance of an
  25. |* IFileSystemDescContainer object. Then, use the NERO_WRITE_FILE_SYSTEM_CONTAINER structure
  26. |* to burn the file structure created.
  27. ******************************************************************************/
  28. #ifndef __NEROFILESYSTEMCONTENT_H
  29. #define __NEROFILESYSTEMCONTENT_H
  30. #if defined(__BORLANDC__)
  31. // NEROAPI expects structs to be 8byte aligned
  32. #pragma pack(push, 8)
  33. // tell Borland C++ Builder to treat enums as int
  34. #pragma option push -b
  35. #endif
  36. // To make sure we do not interfere with other classes
  37. namespace FileSystemContent
  38. {
  39. class InterfaceBase
  40. {
  41. public:
  42. // Get another interface for the same object. This will be used to extend the DLL interface without
  43. // loosing binary compatibility. Returns NULL if no interface with this ID was found
  44. // This is inspired from the COM QueryInterface function
  45. virtual void *GetOtherInterface(int interfaceId) const // Using an ID number
  46. {
  47. return 0; // Not other interface available by default
  48. }
  49. virtual void *GetOtherInterface(const char *interfaceName) const // Using a string
  50. {
  51. return 0; // Not other interface available by default
  52. }
  53. protected:
  54. virtual ~InterfaceBase() {}
  55. };
  56. ////////////////////////////////////////////////////////////////////////////////////////
  57. // This first set of interfaces will be used by the burn engine to read the content of
  58. // the file system
  59. ////////////////////////////////////////////////////////////////////////////////////////
  60. class IFileContent : public InterfaceBase
  61. {
  62. public:
  63. virtual unsigned Read(void *pBuffer,unsigned length) =0;
  64. virtual bool EndOfFile() =0;
  65. virtual bool Error() =0;
  66. // Called by the application when the object is not needed anymore
  67. virtual void Release() = 0;
  68. };
  69. class IDirectory;
  70. class IDirectoryEntry : public InterfaceBase
  71. {
  72. public:
  73. enum ENTRY_ERROR
  74. {
  75. ENTRY_NO_ERROR,
  76. SEQUENCING_ERROR, // The content for this file may not be requested at this moment
  77. ERROR_NOT_A_FILE, // This entry is not a file
  78. NOT_AVAILABLE, // The content of this file cannot be requested at all
  79. INTERFACE_ERROR, // The overriden function has tried to get an other interface for one object and has failed
  80. FEATURE_NOT_AVAILABLE // This feature is not available for this file system type
  81. };
  82. enum {
  83. MODE2_FORM2 =1<<0,
  84. FIXED_INSIDE_VOLUME_SPACE =1<<1,
  85. FIXED_OUTSIDE_VOLUME_SPACE =1<<2,
  86. NO_OWN_CONTENT =1<<3
  87. };
  88. virtual const char *GetName() const =0; // File or directory name
  89. virtual const IDirectory *GetSubDirectory() const =0;
  90. virtual ENTRY_ERROR GetContent(IFileContent **) const =0;
  91. virtual const char *GetSourceFilePath() const =0; // Return the source file path, NULL if the file is generated
  92. virtual __int64 GetSize() const =0;
  93. virtual int GetFilePriority() const =0;
  94. virtual int GetDirOrder() const =0;
  95. virtual int GetId() const =0; // Id number that can be used to find the file again later
  96. virtual unsigned GetDataStartSec() const =0;
  97. };
  98. class IDirectory : public InterfaceBase
  99. {
  100. public:
  101. virtual int GetNumEntries() const =0;
  102. virtual const IDirectoryEntry *GetDirectoryEntry(int i) const =0;
  103. };
  104. class IFileSystemContent : public InterfaceBase
  105. {
  106. public:
  107. virtual const char *GetName() const =0; // Volume name
  108. virtual const IDirectory *GetRoot() const =0;
  109. };
  110. ////////////////////////////////////////////////////////////////////////////////////////
  111. // This second set of interfaces will be used by the application to produce the content of
  112. // the file system
  113. ////////////////////////////////////////////////////////////////////////////////////////
  114. // Allows the file producer to return the data
  115. class IDataInputStream : public InterfaceBase
  116. {
  117. public:
  118. virtual void Write(const void *buffer,int size) = 0;
  119. };
  120. // Produce the content of a file. This interface must be derived and its implementation must
  121. // create the content of the file in the ProduceFile function
  122. class IFileProducer : public InterfaceBase
  123. {
  124. public:
  125. // Calling this method will automatically update the file size to the amount of data
  126. // delivered by the producer
  127. virtual IDirectoryEntry::ENTRY_ERROR ProduceFile(IDataInputStream *str) const = 0;
  128. // Called by NeroAPI when the object is not needed anymore
  129. virtual void Release() const = 0;
  130. };
  131. class IDirectoryContainer;
  132. // Description of a file
  133. class IDirectoryEntryContainer : public IDirectoryEntry
  134. {
  135. public:
  136. // This object can be accessed in several ways
  137. enum
  138. {
  139. IID_IDirectoryEntryContainer,
  140. IID_IFileProducer, // If the file entry was created using an IFileProducer
  141. // object, this one can be retrieved using GetOtherInterface
  142. IID_IDirectoryEntryContainer2, // Reserved
  143. IID_IDirectoryEntry2 // Reserved
  144. };
  145. // Using this function, the file size can be changed after having added the entry to the directory
  146. virtual void SetSize(__int64 size) =0;
  147. // The two functions below can be used to readjust the directory priority
  148. // Priority numbers will be used in upward order: the file with smaller values first
  149. virtual void SetPriority(int priority) =0;
  150. virtual void SetDirOrder(int directoryPriority) =0;
  151. // Set the sector number that will be saved into the directory structure
  152. virtual void SetDataStartSec(unsigned) =0;
  153. // Set the physical position of the file in the filesystem
  154. virtual void SetFixedDataStartSec(unsigned) =0;
  155. virtual void SetFileNumber(int) =0;
  156. virtual void SetId(int) =0;
  157. virtual void SetFlags(bool enable,unsigned f) =0; // Enable/disable the given flag
  158. };
  159. // Extension of the IDirectoryEntryContainer interface
  160. class IDirectoryEntryContainer2 : public IDirectoryEntryContainer
  161. {
  162. public:
  163. // If the file entry was created using an IFileProducer, returns a pointer on it
  164. virtual const IFileProducer *GetFileProducer() const =0;
  165. // Update the size attribute of this file by producing its content without writing
  166. // it anywhere
  167. virtual ENTRY_ERROR MeasureSize() =0;
  168. // Set the size that is stored in the media directory record but do not change the
  169. // size of allocated and requested data
  170. // This is currently only available for ISO filesystems
  171. virtual ENTRY_ERROR SetDirRecordSize(__int64 size) =0;
  172. };
  173. // Represents the content of a directory
  174. class IDirectoryContainer : public IDirectory
  175. {
  176. public:
  177. // Add a directory a returns a pointer on it
  178. // directoryPriority specifies the position in the directory. See this->AddFile
  179. // for details
  180. virtual IDirectoryContainer *AddDirectory(const char *name, int directoryPriority) =0;
  181. // Add a file the directory. The fp object will be automatically deleted when the directory
  182. // container will be deleted
  183. //
  184. // the filesize passed here does *not* need to be correct, it will be used by the
  185. // filesystem generator to preallocate space so it must be the *maximum* space the final
  186. // version of the file may need (worst-case).
  187. //
  188. // Priority specifies some user-defined ordinal defining the order in which the files are
  189. // being written to the disc physically (like .ifo comes before .vob).
  190. // Priorities are valid across directories
  191. // The fileentry order in a directory is defined by the directoryPriority parameter which is the primary
  192. // sort criterium when arranging the files in a directory (Note that this is only true for
  193. // filesystems that do not require files to be sorted in the directory, e.g. UDF)
  194. // If any of the priority specifiers is -1, the producer doesn't care about the priority
  195. // and Nero will put the file where it thinks it fit
  196. // AddFile will return NULL if a file with the same name already exists
  197. virtual IDirectoryEntryContainer *AddFile(const char *name,
  198. const IFileProducer *fp,__int64 size,
  199. int priority, int directoryPriority) = 0;
  200. // Add a file which exists in the real file system
  201. virtual IDirectoryEntryContainer *AddFile(const char *name,
  202. const char *sourcePath,
  203. int priority, int directoryPriority) = 0;
  204. // Remove an entry from the directory
  205. virtual bool RemoveEntry(const char *name) =0;
  206. virtual IDirectoryEntryContainer *Entry(const char *name) =0;
  207. virtual IDirectoryEntryContainer *Entry(int i) =0;
  208. virtual IDirectoryContainer *SubDirectory(const char *name) =0;
  209. };
  210. // Supplemental method to the IDirectoryContainer interface
  211. class IDirectoryContainerSearch {
  212. public:
  213. enum {
  214. SEARCH_DEPTH_INCL, // Searches whole tree including given start object
  215. SEARCH_CHILDREN_EXCL // Searches children of start object only
  216. };
  217. // Like 'SubDirectory' of 'IDirectoryContainer' but with different search modes.
  218. // 'reserved' is intended for future use and MUST be initialized with NULL for now.
  219. virtual IDirectoryContainer *SubDirectoryEx(const char *name, unsigned mode, void *reserved) = 0;
  220. };
  221. // Represents the content of a file system
  222. struct IFileSystemDescContainer : public IFileSystemContent
  223. {
  224. virtual void SetName(const char *) =0; // Set the volume name of the file system
  225. virtual IDirectoryContainer *Root() =0; // Access the root directory for changing it
  226. // Called by the application when the object is not needed anymore
  227. virtual void Release() const = 0;
  228. };
  229. } // namespace FileSystemContent
  230. #if defined(__BORLANDC__)
  231. #pragma pack(pop)
  232. #pragma option pop
  233. #endif
  234. #endif//__NEROFILESYSTEMCONTENT_H