I am having problems trying to append files to a CDRW disk.
The first time through, using a blank disk, the following code executes without error, but the disk is not readable.
When I run it a second time StarBurn_ISO9660JolietFileTree_ImportTrack() fails with a SCSI CDB Error.
Any ideas what I am doing wrong?
Thanks
Quote:
/*=================================================================================*/
BMRC DevOptical::AddFileToDisk( char* filename )
{
BMRC rc = Success;
ULONG l__ULONG__Status = ERROR_GEN_FAILURE;
CHAR l__CHAR__VendorID[ 1024 ] = {0};
CHAR l__CHAR__ProductID[ 1024 ] = {0};
CHAR l__CHAR__ProductRevisionLevel[ 1024 ] = {0};
ULONG l__ULONG__BufferSizeInUCHARs = 0;
BOOLEAN l__BOOLEAN__IsSendOPCSuccessful = FALSE;
EXCEPTION_NUMBER l__EXCEPTION_NUMBER = EN_SUCCESS; // Assume success by default
CHAR l__CHAR__ExceptionText[ 1024 ];
CDB_FAILURE_INFORMATION l__CDB_FAILURE_INFORMATION;
TRACK_INFORMATION l__TRACK_INFORMATION;
// DISC_INFORMATION l__DISC_INFORMATION;
DISC_TYPE l__DISC_TYPE = DISC_TYPE_UNKNOWN;
BOOLEAN l__BOOLEAN__IsTrackAtOnce = FALSE;
BOOLEAN l__BOOLEAN__IsSessionAtOnce = FALSE;
BOOLEAN l__BOOLEAN__IsDiscAtOncePQ = FALSE;
BOOLEAN l__BOOLEAN__IsDiscAtOnceRawPW = FALSE;
LONG l__LONG__FailedLBA = 0;
BOOLEAN l__BOOLEAN__IsAudioFileSupported = FALSE; // Assume data stream by default
BOOLEAN l__BOOLEAN__IsMediaPresent = FALSE;
BOOLEAN l__BOOLEAN__IsDoorOrTrayOpened = FALSE;
BOOLEAN bMustFormat = FALSE;
PVOID l__PVOID__ISO9660JolietFileTree = NULL;
PVOID l__PVOID__Root = NULL;
LONG l__LONG__TreeLevel = 5;
UCHAR l__UCHAR__LastTrack = 0;
char* StarBurnAPIFunctionName = NULL;
/*
StarBurn_CdvdBurnerGrabber_GetTrackInformation the invisible track
StarBurn_ISO9660JolietFileTree_Create
StarBurn_ISO9660JolietFileTree_ImportTrack track 1
StarBurn_ISO9660JolietFileTree_GetRoot
StarBurn_ISO9660JolietFileTree_Add the file
StarBurn_ISO9660JolietFileTree_GetLevel
StarBurn_ISO9660JolietFileTree_BuildImage passing the level and the next writable address from the track info
and StarBurn_CdvdBurnerGrabber_TrackAtOnceFromTree
*/
if( m_CdvdBurnerGrabber )
{
StarBurn_Destroy( &m_CdvdBurnerGrabber );
m_CdvdBurnerGrabber = NULL;
}
prepareForWriteOperation();
StarBurnAPIFunctionName = "StarBurn_CdvdBurnerGrabber_GetTrackInformation";
l__EXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_GetTrackInformation(
m_CdvdBurnerGrabber,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
&l__CDB_FAILURE_INFORMATION,
TRACK_NUMBER_INVISIBLE,
( PTRACK_INFORMATION )( &l__TRACK_INFORMATION )
);
if( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
l__EXCEPTION_NUMBER = StarBurn_ISO9660JolietFileTree_Create(
&l__PVOID__ISO9660JolietFileTree,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
( PCALLBACK )( BurnCallback ),
( PVOID )( this ),
TRUE,
FALSE, // No locked files - do not keep all the handles opened all the time
TRUE, // Use Level2 for ISO9660 names generation
FILE_TREE_JOLIET );
}
if( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_GetLastTrack(
m_CdvdBurnerGrabber,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
&l__CDB_FAILURE_INFORMATION,
&l__UCHAR__LastTrack
);
}
if( l__UCHAR__LastTrack )
{
if( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
UCHAR UCHAR__TrackNumber = 1;
l__EXCEPTION_NUMBER = StarBurn_ISO9660JolietFileTree_ImportTrack(
m_CdvdBurnerGrabber,
&l__PVOID__ISO9660JolietFileTree,
UCHAR__TrackNumber,
true, // BOOLEAN__ImportJolietStructures,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status );
}
if( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
// Try to get root here
l__PVOID__Root = StarBurn_ISO9660JolietFileTree_GetRoot( l__PVOID__ISO9660JolietFileTree );
// Check for correct reply
if ( l__PVOID__Root == NULL )
{
// Handle error here, keep in mind that root CAN be NULL if nothing was added to tree before...
}
}
}
// Find next node to add new file to
PVOID ParentNode = l__PVOID__Root;
PVOID ChildNode = l__PVOID__Root;
PVOID NextChildNode = l__PVOID__Root;
PVOID NewNode = l__PVOID__Root;
{
StarBurn_ISO9660JolietFileTree_GetFirstKid( l__PVOID__ISO9660JolietFileTree, &ChildNode );
while( ChildNode )
{
StarBurn_ISO9660JolietFileTree_GetFirstKid( ChildNode, &NextChildNode );
if( NextChildNode )
{
ChildNode = NextChildNode;
}
}
}
if( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
l__EXCEPTION_NUMBER = StarBurn_ISO9660JolietFileTree_Add(
l__PVOID__ISO9660JolietFileTree,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
filename, // Pointer to directory or file name name to build the ISO9660 or Joliet image from
"ROOT", // Pointer to directory or file name to be stored in the ISO9660 or Joliet image as root name, NULL to include default name from the previous parameter
FILE_TIME_LAST_WRITE, // File time that will be included in file system image (See FILE_TIME).
&ChildNode, // Pointer to pointer to the file tree node we'll use as parent. This is the result of either tree walking with StarBurn_ISO9660JolietFileTree_GetFirst(Next)Kid().
&NewNode ); // Pointer to pointer to the new created file tree node.
// Check for correct reply
}
if( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
// Get tree level here
l__LONG__TreeLevel = StarBurn_ISO9660JolietFileTree_GetLevel( l__PVOID__ISO9660JolietFileTree );
}
if ( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
l__EXCEPTION_NUMBER =
StarBurn_ISO9660JolietFileTree_BuildImage(
l__PVOID__ISO9660JolietFileTree,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
l__TRACK_INFORMATION.m__LONG__NextWritableAddress, // Starting LBA to build the image from (it should be the next writable address of the track on the CD/DVD media, 0 for empty disc).
l__LONG__TreeLevel, //ISO9660_TREE_LEVEL
FALSE, // TRUE, // s CDROM XA or CDROM data (do we need CDROM XA marker to be included to the the image).
"Backup_Disk", // Pointer to the volume set.name
"CompanyName", // Pointer to the publisher and preparer name.
"Program.exe" ); // Pointer to the application name.
}
if ( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
// Try to record the ISO9660 or Joliet file system image in Track-At-Once mode
l__EXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_TrackAtOnceFromTree(
m_CdvdBurnerGrabber,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
&l__CDB_FAILURE_INFORMATION,
l__PVOID__ISO9660JolietFileTree, // Pointer to ISO9660 or Joliet file system image located in a file tree.
TRUE, // BOOLEAN set to TRUE if this is CDROM XA, FALSE if this is a just ordinary CDROM/CDDA
FALSE, // BOOLEAN set to TRUE if this is test write, FALSE if this is a real write.
TRUE, // FALSE, // BOOLEAN set to TRUE is next session is allowed on this media, FALSE if next session will not be allowed on this media.
WRITE_REPORT_DELAY_IN_SECONDS,
BUFFER_STATUS_REPORT_DELAY_IN_SECONDS
);
/*
if ( l__EXCEPTION_NUMBER == EN_SUCCESS )
{
// Try to close the session
//
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_CloseSession(
m_CdvdBurnerGrabber,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
&l__CDB_FAILURE_INFORMATION
);
}
*/
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_Eject(
m_CdvdBurnerGrabber,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__Status,
&l__CDB_FAILURE_INFORMATION
);
}
return rc;
}