NeroFileSystemContent.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. CPR_MAI_ADPTY =1<<4
  88. };
  89. virtual const char *GetName() const =0; // File or directory name
  90. virtual const IDirectory *GetSubDirectory() const =0;
  91. virtual ENTRY_ERROR GetContent(IFileContent **) const =0;
  92. virtual const char *GetSourceFilePath() const =0; // Return the source file path, NULL if the file is generated
  93. virtual __int64 GetSize() const =0;
  94. virtual int GetFilePriority() const =0;
  95. virtual int GetDirOrder() const =0;
  96. virtual int GetId() const =0; // Id number that can be used to find the file again later
  97. virtual unsigned GetDataStartSec() const =0;
  98. };
  99. class IDirectory : public InterfaceBase
  100. {
  101. public:
  102. virtual int GetNumEntries() const =0;
  103. virtual const IDirectoryEntry *GetDirectoryEntry(int i) const =0;
  104. };
  105. class IFileSystemContent : public InterfaceBase
  106. {
  107. public:
  108. virtual const char *GetName() const =0; // Volume name
  109. virtual const IDirectory *GetRoot() const =0;
  110. };
  111. ////////////////////////////////////////////////////////////////////////////////////////
  112. // This second set of interfaces will be used by the application to produce the content of
  113. // the file system
  114. ////////////////////////////////////////////////////////////////////////////////////////
  115. // Allows the file producer to return the data
  116. class IDataInputStream : public InterfaceBase
  117. {
  118. public:
  119. virtual void Write(const void *buffer,int size) = 0;
  120. };
  121. // Produce the content of a file. This interface must be derived and its implementation must
  122. // create the content of the file in the ProduceFile function
  123. class IFileProducer : public InterfaceBase
  124. {
  125. public:
  126. // Calling this method will automatically update the file size to the amount of data
  127. // delivered by the producer
  128. virtual IDirectoryEntry::ENTRY_ERROR ProduceFile(IDataInputStream *str) const = 0;
  129. // Called by NeroAPI when the object is not needed anymore
  130. virtual void Release() const = 0;
  131. };
  132. class IDirectoryContainer;
  133. // Description of a file
  134. class IDirectoryEntryContainer : public IDirectoryEntry
  135. {
  136. public:
  137. // This object can be accessed in several ways
  138. enum
  139. {
  140. IID_IDirectoryEntryContainer,
  141. IID_IFileProducer, // If the file entry was created using an IFileProducer
  142. // object, this one can be retrieved using GetOtherInterface
  143. IID_IDirectoryEntryContainer2, // Reserved
  144. IID_IDirectoryEntry2 // Reserved
  145. };
  146. // Using this function, the file size can be changed after having added the entry to the directory
  147. virtual void SetSize(__int64 size) =0;
  148. // The two functions below can be used to readjust the directory priority
  149. // Priority numbers will be used in upward order: the file with smaller values first
  150. virtual void SetPriority(int priority) =0;
  151. virtual void SetDirOrder(int directoryPriority) =0;
  152. // Set the sector number that will be saved into the directory structure
  153. virtual void SetDataStartSec(unsigned) =0;
  154. // Set the physical position of the file in the filesystem
  155. virtual void SetFixedDataStartSec(unsigned) =0;
  156. virtual void SetFileNumber(int) =0;
  157. virtual void SetId(int) =0;
  158. virtual void SetFlags(bool enable,unsigned f) =0; // Enable/disable the given flag
  159. };
  160. // Extension of the IDirectoryEntryContainer interface
  161. class IDirectoryEntryContainer2 : public IDirectoryEntryContainer
  162. {
  163. public:
  164. // If the file entry was created using an IFileProducer, returns a pointer on it
  165. virtual const IFileProducer *GetFileProducer() const =0;
  166. // Update the size attribute of this file by producing its content without writing
  167. // it anywhere
  168. virtual ENTRY_ERROR MeasureSize() =0;
  169. // Set the size that is stored in the media directory record but do not change the
  170. // size of allocated and requested data
  171. // This is currently only available for ISO filesystems
  172. virtual ENTRY_ERROR SetDirRecordSize(__int64 size) =0;
  173. };
  174. // Represents the content of a directory
  175. class IDirectoryContainer : public IDirectory
  176. {
  177. public:
  178. // Add a directory a returns a pointer on it
  179. // directoryPriority specifies the position in the directory. See this->AddFile
  180. // for details
  181. virtual IDirectoryContainer *AddDirectory(const char *name, int directoryPriority) =0;
  182. // Add a file the directory. The fp object will be automatically deleted when the directory
  183. // container will be deleted
  184. //
  185. // the filesize passed here does *not* need to be correct, it will be used by the
  186. // filesystem generator to preallocate space so it must be the *maximum* space the final
  187. // version of the file may need (worst-case).
  188. //
  189. // Priority specifies some user-defined ordinal defining the order in which the files are
  190. // being written to the disc physically (like .ifo comes before .vob).
  191. // Priorities are valid across directories
  192. // The fileentry order in a directory is defined by the directoryPriority parameter which is the primary
  193. // sort criterium when arranging the files in a directory (Note that this is only true for
  194. // filesystems that do not require files to be sorted in the directory, e.g. UDF)
  195. // If any of the priority specifiers is -1, the producer doesn't care about the priority
  196. // and Nero will put the file where it thinks it fit
  197. // AddFile will return NULL if a file with the same name already exists
  198. virtual IDirectoryEntryContainer *AddFile(const char *name,
  199. const IFileProducer *fp,__int64 size,
  200. int priority, int directoryPriority) = 0;
  201. // Add a file which exists in the real file system
  202. virtual IDirectoryEntryContainer *AddFile(const char *name,
  203. const char *sourcePath,
  204. int priority, int directoryPriority) = 0;
  205. // Remove an entry from the directory
  206. virtual bool RemoveEntry(const char *name) =0;
  207. virtual IDirectoryEntryContainer *Entry(const char *name) =0;
  208. virtual IDirectoryEntryContainer *Entry(int i) =0;
  209. virtual IDirectoryContainer *SubDirectory(const char *name) =0;
  210. };
  211. // Supplemental method to the IDirectoryContainer interface
  212. class IDirectoryContainerSearch {
  213. public:
  214. enum {
  215. SEARCH_DEPTH_INCL, // Searches whole tree including given start object
  216. SEARCH_CHILDREN_EXCL // Searches children of start object only
  217. };
  218. // Like 'SubDirectory' of 'IDirectoryContainer' but with different search modes.
  219. // 'reserved' is intended for future use and MUST be initialized with NULL for now.
  220. virtual IDirectoryContainer *SubDirectoryEx(const char *name, unsigned mode, void *reserved) = 0;
  221. };
  222. // Represents the content of a file system
  223. struct IFileSystemDescContainer : public IFileSystemContent
  224. {
  225. virtual void SetName(const char *) =0; // Set the volume name of the file system
  226. virtual IDirectoryContainer *Root() =0; // Access the root directory for changing it
  227. // Called by the application when the object is not needed anymore
  228. virtual void Release() const = 0;
  229. };
  230. // Extension of IFileSystemDescContainer to set extended volume names.
  231. // If you use these methods, don't use SetName of IFileSystemDescContainer
  232. struct IFileSystemDescContainerVolume : public InterfaceBase
  233. {
  234. virtual void SetISOName(const char *) = 0;
  235. virtual void SetJolietName(const WCHAR *) = 0;
  236. virtual void SetUDFName(const WCHAR *) = 0;
  237. // Non-const get functions will return a volume label even if it was
  238. // not set by calling above methods. These methods will provide a volume label
  239. // that will be really burn on the disc by converting illegal characters.
  240. virtual const char* GetISOName() = 0;
  241. virtual const WCHAR* GetJolietName() = 0;
  242. virtual const WCHAR* GetUDFName() = 0;
  243. };
  244. } // namespace FileSystemContent
  245. #if defined(__BORLANDC__)
  246. #pragma pack(pop)
  247. #pragma option pop
  248. #endif
  249. #endif//__NEROFILESYSTEMCONTENT_H