Here's the init code, the callback function isn't yet referenced.
Code:
LONG m_TreeNodes;
LARGE_INTEGER m_LastWrittenPercent;
unsigned char m_FileSystemHead[UDF_HEAD_SIZE_IN_LOGICAL_BLOCKS * UDF_LOGICAL_BLOCK_SIZE_IN_UCHARS];
unsigned char m_FileSystemTail[UDF_TAIL_SIZE_IN_LOGICAL_BLOCKS * UDF_LOGICAL_BLOCK_SIZE_IN_UCHARS];
unsigned char m_FileSystemStructures[1024 * UDF_LOGICAL_BLOCK_SIZE_IN_UCHARS];
//unsigned char m_IsIfoPatch = 0x00; // 0x01; // Assume IFO patch present by default
unsigned char m_Buffer[UDF_LOGICAL_BLOCK_SIZE_IN_UCHARS];
LARGE_INTEGER m_FileSizeInUCHARs;
CString video_ts = "D:\\...\\VIDEO_TS\\";
HRESULT hr = S_OK;
CString filename;
bool bTestBurn = false;
void *CdvdBurnerGrabber = NULL;
ULONG Status = ERROR_GEN_FAILURE;
char ExceptionText[1024];
EXCEPTION_NUMBER exceptionNo = EN_SUCCESS; // Assume success by default
CDB_FAILURE_INFORMATION CDBFailureInfo;
TRACK_INFORMATION l__TRACK_INFORMATION;
DISC_INFORMATION l__DISC_INFORMATION;
BOOLEAN IsBUPEnabled;
BOOLEAN IsBUPSupported;
ULONG CurrentReadSpeed;
ULONG MaximumReadSpeed;
ULONG CurrentWriteSpeed;
ULONG MaximumWriteSpeed;
BOOLEAN IsSendOPCSuccessful = FALSE;
DISC_TYPE l__DISC_TYPE = DISC_TYPE_UNKNOWN;
BOOLEAN IsTrackAtOnce = FALSE;
BOOLEAN IsSessionAtOnce = FALSE;
BOOLEAN IsDiscAtOncePQ = FALSE;
BOOLEAN IsDiscAtOnceRawPW = FALSE;
UDF_TREE_ITEM l__UDF_TREE_ITEM__Directory[20]; // Directory[ 0 ] is not used
UDF_TREE_ITEM UDF_File;
CArray<UDF_TREE_ITEM> UDF_Files;
ULONG GUID = 0; // Start assigning GUIDs with zero
UDF_CONTROL_BLOCK l__UDF_CONTROL_BLOCK;
// Prepare memory buffers
memset(m_FileSystemHead, 0, sizeof(m_FileSystemHead));
memset(m_FileSystemTail, 0, sizeof(m_FileSystemTail));
memset(m_FileSystemStructures, 0, sizeof(m_FileSystemStructures));
memset(l__UDF_TREE_ITEM__Directory, 0, sizeof(l__UDF_TREE_ITEM__Directory));
memset(&UDF_File, 0, sizeof(UDF_File));
memset(&l__UDF_CONTROL_BLOCK, 0, sizeof(UDF_CONTROL_BLOCK));
// Prepare the buffer for exception text
memset(ExceptionText, 0, sizeof(ExceptionText));
//
// Start processing cleanup
//
try
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): Formatting directories...\n" );
//
// Format Directory[ 1 ] as root
//
StarBurn_UDF_FormatTreeItemAsDirectory(
&l__UDF_TREE_ITEM__Directory[ 1 ],
( ++GUID ),
"",
NULL
);
//
// Format VIDEO_TS directory
//
StarBurn_UDF_FormatTreeItemAsDirectory(
&l__UDF_TREE_ITEM__Directory[ 2 ],
( ++GUID ),
"VIDEO_TS",
&l__UDF_TREE_ITEM__Directory[ 1 ]
);
//
// Format AUDIO_TS directory
//
StarBurn_UDF_FormatTreeItemAsDirectory(
&l__UDF_TREE_ITEM__Directory[ 3 ],
( ++GUID ),
"AUDIO_TS",
&l__UDF_TREE_ITEM__Directory[ 1 ]
);
TRACE("DVDVideoTrackAtOnceFromTree:main(): Formatting files...\n" );
//
// Format files (begin)
//
/*
Files must be aligned like this:
/VIDEO_TS/VIDEO_TS.IFO
/VIDEO_TS/VIDEO_TS.VOB
/VIDEO_TS/VIDEO_TS.BUP
/VIDEO_TS/VTS_01_0.IFO
/VIDEO_TS/VTS_01_0.VOB
: :
/VIDEO_TS/VTS_01_9.VOB
/VIDEO_TS/VTS_01_0.BUP
: :
/VIDEO_TS/VTS_99_0.BUP
*/
filename = video_ts + "video_ts.ifo";
Status =
StarBurn_UDF_FormatTreeItemAsFile(
&UDF_File,
( ++GUID ),
"video_ts.ifo",
(char *)(const char *)filename,
&l__UDF_TREE_ITEM__Directory[ 2 ]
);
//
// Check for success
//
if (Status != 0)
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): EXITing with failure, StarBurn_UDF_FormatTreeItemAsFile( %p, %ld, '%s', '%s', %p ) failed, status %ld ( 0x%X )\n",
&UDF_File,
GUID,
"video_ts.ifo",
(char *)(const char *)filename,
&l__UDF_TREE_ITEM__Directory[ 2 ],
Status,
Status
);
//
// Get out of here
//
throw Status;
}
UDF_Files.Add(UDF_File);
filename = video_ts + "video_ts.bup";
Status =
StarBurn_UDF_FormatTreeItemAsFile(
&UDF_File,
( ++GUID ),
"video_ts.bup",
(char *)(const char *)filename,
&l__UDF_TREE_ITEM__Directory[ 2 ]
);
//
// Check for success
//
if ( Status != 0 )
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): EXITing with failure, StarBurn_UDF_FormatTreeItemAsFile( %p, %ld, '%s', '%s', %p ) failed, status %ld ( 0x%X )\n",
&UDF_File,
GUID,
"video_ts.bup",
(char *)(const char *)filename,
&l__UDF_TREE_ITEM__Directory[ 2 ],
Status,
Status
);
//
// Get out of here
//
throw Status;
}
UDF_Files.Add(UDF_File);
// Ok, now we loop to add all the files we can
CString localFilename;
CString udfFilename;
int index = 1;
int part = 0;
while (Status == 0) {
// Starting from part 0
part = 0;
udfFilename.Format("vts_%02i_%i.ifo", index, part);
localFilename = video_ts + udfFilename;
// No more files?
if (!PathFileExists(localFilename))
break;
Status = StarBurn_UDF_FormatTreeItemAsFile(
&UDF_File,
( ++GUID ),
(char *)(LPCSTR)udfFilename,
(char *)(LPCSTR)localFilename,
&l__UDF_TREE_ITEM__Directory[ 2 ]
);
//
// Check for success
//
if ( Status != 0 )
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): EXITing with failure, StarBurn_UDF_FormatTreeItemAsFile( %p, %ld, '%s', '%s', %p ) failed, status %ld ( 0x%X )\n",
&UDF_File,
GUID,
(LPCSTR)udfFilename,
(LPCSTR)localFilename,
&l__UDF_TREE_ITEM__Directory[ 2 ],
Status,
Status
);
//
// Get out of here
//
break;
}
UDF_Files.Add(UDF_File);
udfFilename.Format("vts_%02i_%i.buf", index, part);
localFilename = video_ts + udfFilename;
if (PathFileExists(localFilename)) {
Status = StarBurn_UDF_FormatTreeItemAsFile(
&UDF_File,
( ++GUID ),
(char *)(LPCSTR)udfFilename,
(char *)(LPCSTR)localFilename,
&l__UDF_TREE_ITEM__Directory[ 2 ]
);
// Check for success
if ( Status != 0 )
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): EXITing with failure, StarBurn_UDF_FormatTreeItemAsFile( %p, %ld, '%s', '%s', %p ) failed, status %ld ( 0x%X )\n",
&UDF_File,
GUID,
udfFilename,
localFilename,
&l__UDF_TREE_ITEM__Directory[ 2 ],
Status,
Status
);
//
// Get out of here
//
continue;
}
UDF_Files.Add(UDF_File);
}
while (part < 10) {
udfFilename.Format("vts_%02i_%i.vob", index, part);
localFilename = video_ts + udfFilename;
if (!PathFileExists(localFilename))
break;
Status = StarBurn_UDF_FormatTreeItemAsFile(
&UDF_File,
( ++GUID ),
(char *)(LPCSTR)udfFilename,
(char *)(LPCSTR)localFilename,
&l__UDF_TREE_ITEM__Directory[ 2 ]
);
//
// Check for success
//
if ( Status != 0 )
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): EXITing with failure, StarBurn_UDF_FormatTreeItemAsFile( %p, %ld, '%s', '%s', %p ) failed, status %ld ( 0x%X )\n",
&UDF_File,
GUID,
"vts_01_1.vob",
"e:\\VOB\\vts_01_1.vob",
&l__UDF_TREE_ITEM__Directory[ 2 ],
Status,
Status
);
//
// Get out of here
//
throw Status;
}
UDF_Files.Add(UDF_File);
// We'll get the next part of the next pass
part++;
}
// Next ifo/vob index
index++;
}
//
// Format files (end)
//
//
// Try to create UDF
//
exceptionNo =
StarBurn_UDF_Create(m_FileSystemHead, sizeof(m_FileSystemHead),
m_FileSystemTail, sizeof(m_FileSystemTail),
m_FileSystemStructures,
&l__UDF_TREE_ITEM__Directory[ 1 ], // This is ROOT
&l__UDF_TREE_ITEM__Directory[ 2 ], // This is VIDEO_TS and not ROOT, for VIDEO_TS listing
&l__UDF_TREE_ITEM__Directory[ 3 ], // This is AUDIO_TS and not ROOT, for AUDIO_TS listing
&l__UDF_CONTROL_BLOCK,
ExceptionText, sizeof(ExceptionText),
&Status,
"VolumeLabel");
//
// Check for success
//
if ( exceptionNo != EN_SUCCESS )
{
TRACE("DVDVideoTrackAtOnceFromTree:main(): StarBurn_UDF_Create() failed, exception %ld, status %ld, text '%s'\n",
exceptionNo,
Status,
ExceptionText
);
//
// Get out of here
//
throw Status;
}
} catch (...) {
}