Prime modifiche per compatibilita' UNIX

git-svn-id: svn://10.65.10.50/trunk@33 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-08-18 10:40:18 +00:00
parent 80624b0d87
commit ea150a8931
4 changed files with 955 additions and 952 deletions

View File

@ -59,6 +59,7 @@
//
#include "arclib.h"
#include <utility.h>
#pragma hdrstop
//
@ -193,7 +194,7 @@ void AL_DLL_FAR * AL_PROTO ALEntryList::operator new( size_t size )
AL_PROTO ALEntry::ALEntry( ALEntryList &list,
ALStorage *object,
ALCompressionEngine *engine )
: mrList( list ) // Initialize our own pointer to the list we will
: mrList( list ) // Initialize our own pointer to the list we will
// be a member of.
{
mpNextItem = this;
@ -204,19 +205,19 @@ AL_PROTO ALEntry::ALEntry( ALEntryList &list,
mlCompressedObjectPosition = -1;
miMark = 1; //Always construct with the mark turned on
mszComment = 0;
//
// I check for the object member to be non-zero because of a clunky design
// choice I made a while back. Each ALEntryList has an ALEntry member that
// points to the first and last members of the list. I could have (and
// probably should have) made the root of the list just be a pair of pointers,
// instead of a dummy ALEntry. Anyway, I can tell that dummy entry apart
// from the valid entries by virtue of the fact that it has a null
// pointer in its object pointer.
//
// So anyway, when I create this dummy object, I don't want to try to add
// it to the list, because by definition it is already in the list. So
// I do a check before adding any ALEntry to the list.
//
//
// I check for the object member to be non-zero because of a clunky design
// choice I made a while back. Each ALEntryList has an ALEntry member that
// points to the first and last members of the list. I could have (and
// probably should have) made the root of the list just be a pair of pointers,
// instead of a dummy ALEntry. Anyway, I can tell that dummy entry apart
// from the valid entries by virtue of the fact that it has a null
// pointer in its object pointer.
//
// So anyway, when I create this dummy object, I don't want to try to add
// it to the list, because by definition it is already in the list. So
// I do a check before adding any ALEntry to the list.
//
if ( object )
InsertBefore( *list.mpListHead );
}
@ -270,12 +271,12 @@ AL_PROTO ALEntry::~ALEntry()
next_job->mpPreviousItem = previous_job;
previous_job->mpNextItem = next_job;
}
//
// Note that I check the object twice, one at the start of the dtor, and
// once again at the end. With all the linked list and dynamic deletion
// being done here, it seems like it would be really easy to hose things
// up if any mistakes were made.
//
//
// Note that I check the object twice, one at the start of the dtor, and
// once again at the end. With all the linked list and dynamic deletion
// being done here, it seems like it would be really easy to hose things
// up if any mistakes were made.
//
AL_ASSERT( GoodTag(), "~ALEntry: Attempting to delete invalid object" );
}
@ -481,7 +482,7 @@ int AL_PROTO ALEntry::CompressionRatio()
ALMonitor ALDefaultMonitor( AL_MONITOR_OBJECTS );
AL_PROTO ALEntryList::ALEntryList( ALMonitor AL_DLL_FAR * monitor /* = 0 */ )
: mrMonitor( monitor ? *monitor : ALDefaultMonitor )
: mrMonitor( monitor ? *monitor : ALDefaultMonitor )
{
mpListHead = new ALEntry( *this, 0, 0 );
}
@ -640,10 +641,10 @@ int AL_PROTO ALEntryList::ToggleMarks()
ALEntry AL_DLL_FAR * AL_PROTO ALEntry::GetNextEntry()
{
ALEntry *next_entry = this->mpNextItem;
//
// The list head has the special case where both the compression engine
// and storage object pointers are 0, and that makes the end of the list.
//
//
// The list head has the special case where both the compression engine
// and storage object pointers are 0, and that makes the end of the list.
//
if ( mpNextItem->mpStorageObject == 0 )
return 0;
else
@ -908,6 +909,6 @@ int AL_PROTO ALEntryList::SetMarksFromListBox( HWND hDlg, int list_box /* = -1 *
}
delete[] items;
return count;
}
}
#endif

View File

@ -110,7 +110,7 @@ void AL_DLL_FAR * AL_PROTO ALArchive::operator new( size_t size )
//
AL_PROTO ALArchive::ALArchive( const char AL_DLL_FAR *file_name )
: ALArchiveBase( new ALFile( file_name ), 1 )
: ALArchiveBase( new ALFile( file_name ), 1 )
{
}
@ -143,7 +143,7 @@ AL_PROTO ALArchive::ALArchive( const char AL_DLL_FAR *file_name )
//
AL_PROTO ALArchive::ALArchive( ALStorage AL_DLL_FAR &so )
: ALArchiveBase( &so, 0 )
: ALArchiveBase( &so, 0 )
{
}
@ -333,9 +333,9 @@ ALArchive::AddWildCardFiles( ALEntryList AL_DLL_FAR & list,
ALWildCardExpander files( wild_spec, traverse_flag );
int count = 0;
char *new_name;
char *new_name; ALEntry* dummy;
while ( ( new_name = files.GetNextFile() ) != 0 ) {
new ALEntry( list,
dummy = new ALEntry( list,
new ALFile( new_name ),
new ALGreenleafEngine( compression_level ) );
count++;
@ -428,6 +428,6 @@ MakeEntriesFromListBox( ALEntryList AL_DLL_FAR &list,
}
delete items;
return count;
}
}
#endif //#ifdef AL_WINDOWS_GUI

View File

@ -130,7 +130,7 @@ void AL_DLL_FAR * AL_PROTO ALArchiveBase::operator new( size_t size )
AL_PROTO ALArchiveBase::ALArchiveBase( ALStorage AL_DLL_FAR *storage_object,
short int delete_in_dtor )
: miDeleteStorageObject( delete_in_dtor )
: miDeleteStorageObject( delete_in_dtor )
{
mpArchiveStorageObject = storage_object;
mszComment = 0;
@ -353,38 +353,38 @@ void AL_PROTO ALArchiveBase::ScanStatus( ALEntryList AL_DLL_FAR &list )
int AL_PROTO ALArchiveBase::Extract( ALEntryList AL_DLL_FAR &list )
{
//
// Open the input storage object, if not already open. Let the monitor
// know about it.
//
//
// Open the input storage object, if not already open. Let the monitor
// know about it.
//
ALOpenInputFile archive( *mpArchiveStorageObject );
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_OPEN, this, 0 );
//
// Get rid of any duplicate entries, and set up the monitor sizes.
//
//
// Get rid of any duplicate entries, and set up the monitor sizes.
//
list.UnmarkDuplicates( list, "Duplicate entry in list passed to Extract()" );
list.mrMonitor.mlJobSoFar = 0L;
if ( list.mrMonitor.miMonitorType == AL_MONITOR_JOB )
list.mrMonitor.mlJobSize = CalculateCompressedJobSize( list );
//
// This loop iterates through the entire ALEntryList. We only care about
// ALEntry objects that have their mark set.
//
//
// This loop iterates through the entire ALEntryList. We only care about
// ALEntry objects that have their mark set.
//
ALEntry *job = list.GetFirstEntry();
while ( job ) {
if ( job->miMark ) {
//
// Go to the correct input position in this, and set up the monitor for
// this particular object.
//
//
// Go to the correct input position in this, and set up the monitor for
// this particular object.
//
list.mrMonitor.ArchiveOperation( AL_EXTRACTION_OPEN, this, job );
mpArchiveStorageObject->Seek( job->mlCompressedObjectPosition );
list.mrMonitor.mlObjectStart = job->mlCompressedObjectPosition;
list.mrMonitor.mlObjectSize = job->mlCompressedSize;
mpArchiveStorageObject->mpMonitor = &list.mrMonitor;
//
// Extract it, then check the CRC.
//
//
// Extract it, then check the CRC.
//
job->mpCompressionEngine->Decompress( *mpArchiveStorageObject,
*job->mpStorageObject,
job->mlCompressedSize );
@ -394,11 +394,11 @@ int AL_PROTO ALArchiveBase::Extract( ALEntryList AL_DLL_FAR &list )
"CRC32 was supposed to be %08lx, was %08lx",
job->GetCrc32(),
job->mpStorageObject->GetCrc32() );
//
// Update the monitor data, and yield some time. Note that I turn off
// the monitor at this point so it doesn't jump around while I seek to the
// next position in the archive.
//
//
// Update the monitor data, and yield some time. Note that I turn off
// the monitor at this point so it doesn't jump around while I seek to the
// next position in the archive.
//
list.mrMonitor.mlJobSoFar += job->mlCompressedSize;
mpArchiveStorageObject->YieldTime();
mpArchiveStorageObject->mpMonitor = 0;
@ -407,9 +407,9 @@ int AL_PROTO ALArchiveBase::Extract( ALEntryList AL_DLL_FAR &list )
}
job = job->GetNextEntry();
}
//
// Update the monitor, then scan the list for status errors.
//
//
// Update the monitor, then scan the list for status errors.
//
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
ScanStatus( list );
return mStatus;
@ -460,22 +460,22 @@ int AL_PROTO ALArchiveBase::AddJobs( ALEntryList AL_DLL_FAR &list )
ALEntry *job = list.GetFirstEntry();
while ( job ) {
if ( job->miMark ) {
//
// We need to keep track of the position in the archive where the compressed
// data is going to go.
//
//
// We need to keep track of the position in the archive where the compressed
// data is going to go.
//
job->mlCompressedObjectPosition = mpArchiveStorageObject->Tell();
//
// Attach the monitor to the storage object that is going to be inserted
// in the archive.
//
//
// Attach the monitor to the storage object that is going to be inserted
// in the archive.
//
list.mrMonitor.ArchiveOperation( AL_INSERTION_OPEN, this, job );
list.mrMonitor.mlObjectSize = -1L; // This means we ask for it in ALMonitor, after the object is opened
job->mpStorageObject->mpMonitor = &list.mrMonitor;
//
// Compress the object into the archive. Then store the resulting CRC
// the compressed size in the ALEntry object.
//
//
// Compress the object into the archive. Then store the resulting CRC
// the compressed size in the ALEntry object.
//
job->mpCompressionEngine->Compress( *job->mpStorageObject,
*mpArchiveStorageObject );
job->mlCrc32 = job->mpStorageObject->GetCrc32();
@ -484,9 +484,9 @@ int AL_PROTO ALArchiveBase::AddJobs( ALEntryList AL_DLL_FAR &list )
return mStatus = job->mpCompressionEngine->mStatus;
job->mlCompressedSize = mpArchiveStorageObject->Tell() -
job->mlCompressedObjectPosition;
//
// Update the monitor
//
//
// Update the monitor
//
list.mrMonitor.mlJobSoFar += job->mpStorageObject->GetSize();
list.mrMonitor.ArchiveOperation( AL_INSERTION_CLOSE, this, job );
}
@ -499,7 +499,7 @@ int AL_PROTO ALArchiveBase::AddJobs( ALEntryList AL_DLL_FAR &list )
// PRIVATE MEMBER FUNCTION
//
// int ALArchiveBase::AddDirectoryEntries( ALEntryList &list )
// int ALArchiveBase::AddDirectoryEntries( ALEntryList &list )
//
// ARGUMENTS:
//
@ -561,11 +561,11 @@ int AL_PROTO ALArchiveBase::AddDirectoryEntries( ALEntryList AL_DLL_FAR &list )
}
job = job->GetNextEntry();
}
//
// I write out the end of directory string here. But then I back up the
// file pointer so new entries can be appended without causing any trouble
// The end of the directory is denoted by an entry with an empty name.
//
//
// I write out the end of directory string here. But then I back up the
// file pointer so new entries can be appended without causing any trouble
// The end of the directory is denoted by an entry with an empty name.
//
mpArchiveStorageObject->WriteString( "" );
mpArchiveStorageObject->Seek( mpArchiveStorageObject->Tell() - 2 );
@ -709,60 +709,60 @@ long AL_PROTO ALArchiveBase::CalculateCompressedJobSize( ALEntryList AL_DLL_FAR
int AL_PROTO ALArchiveBase::Create( ALEntryList AL_DLL_FAR &list )
{
//
// Miscellaneous: open the archive, set the archive version, initialize
// the monitor. If the storage object is broken, quite now!
//
//
// Miscellaneous: open the archive, set the archive version, initialize
// the monitor. If the storage object is broken, quite now!
//
ALOpenOutputFile archive( *mpArchiveStorageObject );
miVersion = 0x100;
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_OPEN, this, 0 );
if ( mpArchiveStorageObject->mStatus < 0 )
return mStatus = mpArchiveStorageObject->mStatus;
//
// We don't want to create an archive with duplicate entries, so we check here.
//
//
// We don't want to create an archive with duplicate entries, so we check here.
//
list.UnmarkDuplicates( list,
"Duplicate entry in list passed to Create()" );
//
// The first four bytes in the archive are a long that points to the
// first byte of the directory. I don't know where the directory is
// going to be, so I just reserve space at this time with a dummy value.
//
//
// The first four bytes in the archive are a long that points to the
// first byte of the directory. I don't know where the directory is
// going to be, so I just reserve space at this time with a dummy value.
//
mpArchiveStorageObject->WritePortableLong( 0x12345678L );
//
// Set up the monitor.
//
//
// Set up the monitor.
//
list.mrMonitor.mlJobSoFar = 0L;
if ( list.mrMonitor.miMonitorType == AL_MONITOR_JOB )
list.mrMonitor.mlJobSize = CalculateJobSize( list );
//
// AddJobs() takes care of actually adding the jobs to the archive.
//
//
// AddJobs() takes care of actually adding the jobs to the archive.
//
AddJobs( list );
//
// All the jobs are written, now I can figure out where the
// directory is in the storage object. I copy it, then write
// it out to the storage object at position 0.
//
//
// All the jobs are written, now I can figure out where the
// directory is in the storage object. I copy it, then write
// it out to the storage object at position 0.
//
mlDirectoryOffset = mpArchiveStorageObject->Tell();
mpArchiveStorageObject->Seek( 0L );
mpArchiveStorageObject->WritePortableLong( mlDirectoryOffset );
//
// Return without writing the directory if there is an error in the
// archive storage object.
//
//
// Return without writing the directory if there is an error in the
// archive storage object.
//
if ( mpArchiveStorageObject->mStatus < 0 ) {
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
return mStatus = mpArchiveStorageObject->mStatus;
}
//
// Finally, write out the directory to the storage object.
//
//
// Finally, write out the directory to the storage object.
//
list.mrMonitor.ArchiveOperation( AL_START_DIRECTORY_WRITE, this, 0 );
WriteDirectory( list );
//
// Update the monitor, check for errors, and blow.
//
//
// Update the monitor, check for errors, and blow.
//
list.mrMonitor.ArchiveOperation( AL_END_DIRECTORY_WRITE, this, 0 );
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
ScanStatus( list );
@ -815,39 +815,39 @@ int AL_PROTO ALArchiveBase::Create( ALEntryList AL_DLL_FAR &list )
int AL_PROTO ALArchiveBase::CopyJobs( ALArchiveBase AL_DLL_FAR &source_archive,
ALEntryList AL_DLL_FAR &source_list )
{
//
// Open the storage object attached to the input archive. The storage object
// attached to this is already open.
//
//
// Open the storage object attached to the input archive. The storage object
// attached to this is already open.
//
ALOpenInputFile input( *(source_archive.mpArchiveStorageObject) );
//
// Iterate through the list of entries in the list, selecting only the
// marked entries.
//
//
// Iterate through the list of entries in the list, selecting only the
// marked entries.
//
ALEntry *job = source_list.GetFirstEntry();
while ( job ) {
if ( job->miMark ) {
//
// Seek the compressed object in the source archive, then update the monitor
// to work properly during the copy operation.
//
//
// Seek the compressed object in the source archive, then update the monitor
// to work properly during the copy operation.
//
source_archive.mpArchiveStorageObject->Seek( job->mlCompressedObjectPosition );
source_list.mrMonitor.mlObjectStart = job->mlCompressedObjectPosition;
source_list.mrMonitor.mlObjectSize = job->mlCompressedSize;
source_list.mrMonitor.ArchiveOperation( AL_COPY_OPEN, this, job );
source_archive.mpArchiveStorageObject->mpMonitor = &source_list.mrMonitor;
//
// Save the new position in the destination archive, then copy the
// whole thing across.
//
//
// Save the new position in the destination archive, then copy the
// whole thing across.
//
job->mlCompressedObjectPosition = mpArchiveStorageObject->Tell();
for ( long i = 0 ; i < job->mlCompressedSize ; i++ ) {
int c = source_archive.mpArchiveStorageObject->ReadChar();
mpArchiveStorageObject->WriteChar( c );
}
//
// Update the monitor now that the copy is complete.
//
//
// Update the monitor now that the copy is complete.
//
source_list.mrMonitor.ArchiveOperation( AL_COPY_CLOSE, this, job );
source_archive.mpArchiveStorageObject->YieldTime();
source_list.mrMonitor.mlJobSoFar += job->mlCompressedSize;
@ -897,23 +897,23 @@ int AL_PROTO ALArchiveBase::CopyJobs( ALArchiveBase AL_DLL_FAR &source_archive,
int AL_PROTO ALArchiveBase::Create( ALArchiveBase AL_DLL_FAR &source_archive,
ALEntryList AL_DLL_FAR &source_list )
{
//
// Open the source archive, set the version, and blow if for some reason
// the storage object I am writing to isn't working right.
//
//
// Open the source archive, set the version, and blow if for some reason
// the storage object I am writing to isn't working right.
//
ALOpenOutputFile archive( *mpArchiveStorageObject );
miVersion = 0x100;
if ( mpArchiveStorageObject->mStatus < 0 )
return mStatus = mpArchiveStorageObject->mStatus;
//
// I don't want to create an archive with duplicates, that would be bad.
//
//
// I don't want to create an archive with duplicates, that would be bad.
//
source_list.UnmarkDuplicates( source_list, "Duplicate entry in list passed to Create()" );
//
// At this point, just for fun, I am going to calculate the total
// compressed size of the jobs I am copying. Hey, it looks like I
// could substitute a call to CalculateCompressedSize() here!
//
//
// At this point, just for fun, I am going to calculate the total
// compressed size of the jobs I am copying. Hey, it looks like I
// could substitute a call to CalculateCompressedSize() here!
//
source_list.mrMonitor.ArchiveOperation( AL_ARCHIVE_OPEN, this, 0 );
source_list.mrMonitor.mlJobSoFar = 0L;
source_list.mrMonitor.mlJobSize = 0L;
@ -923,19 +923,19 @@ int AL_PROTO ALArchiveBase::Create( ALArchiveBase AL_DLL_FAR &source_archive,
if ( job->GetMark() )
source_list.mrMonitor.mlJobSize += job->mlCompressedSize;
}
//
// Since I am creating a new archive, I write a long out as a place
// holder for the directory pointer. When I am done copying jobs,
// I'll come back here and write a pointer to the directory.
//
//
// Since I am creating a new archive, I write a long out as a place
// holder for the directory pointer. When I am done copying jobs,
// I'll come back here and write a pointer to the directory.
//
mpArchiveStorageObject->WritePortableLong( 0x12345678L );
//
// Now copy the data.
//
//
// Now copy the data.
//
CopyJobs( source_archive, source_list );
//
// Write out the directory offset, then the directory itself.
//
//
// Write out the directory offset, then the directory itself.
//
mlDirectoryOffset = mpArchiveStorageObject->Tell();
mpArchiveStorageObject->Seek( 0L );
mpArchiveStorageObject->WritePortableLong( mlDirectoryOffset );
@ -947,9 +947,9 @@ int AL_PROTO ALArchiveBase::Create( ALArchiveBase AL_DLL_FAR &source_archive,
WriteDirectory( source_list );
source_list.mrMonitor.ArchiveOperation( AL_END_DIRECTORY_WRITE, this, 0 );
source_list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
//
// Update the error status, and then we are done.
//
//
// Update the error status, and then we are done.
//
ScanStatus( source_list );
return mStatus;
}
@ -984,49 +984,49 @@ int AL_PROTO ALArchiveBase::Create( ALArchiveBase AL_DLL_FAR &source_archive,
int AL_PROTO ALArchiveBase::Append( ALEntryList AL_DLL_FAR &list )
{
ALEntryList old_list;
//
// Open the storage object for this.
//
//
// Open the storage object for this.
//
ALOpenInputFile archive( *mpArchiveStorageObject );
//
// I read in the current directory for this archive. I am going to
// write over the directory with new stuff, so I will have to write it
// back out later.
//
//
// I read in the current directory for this archive. I am going to
// write over the directory with new stuff, so I will have to write it
// back out later.
//
ReadDirectory( old_list );
if ( mStatus < 0 )
return mStatus;
//
// The list of new objects I am going to add needs to be scanned for
// duplicates. First I clear duplicate entries from the list itself.
// Then I clear any duplicates between the current list and the
// stuff already in the archive.
//
//
// The list of new objects I am going to add needs to be scanned for
// duplicates. First I clear duplicate entries from the list itself.
// Then I clear any duplicates between the current list and the
// stuff already in the archive.
//
list.UnmarkDuplicates( list, "Duplicate entry in list passed to Append()" );
list.UnmarkDuplicates( old_list, "Duplicate entry in list passed to Append()" );
//
// I get the monitor set up, for the batch of entries I am about to do.
//
//
// I get the monitor set up, for the batch of entries I am about to do.
//
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_OPEN, this, 0 );
list.mrMonitor.mlJobSoFar = 0L;
if ( list.mrMonitor.miMonitorType == AL_MONITOR_JOB )
list.mrMonitor.mlJobSize = CalculateJobSize( list );
//
// The new entries start at the position currently occupied by the
// directory. I seek to that point, then call AddJobs() to do the
// dirty work.
//
//
// The new entries start at the position currently occupied by the
// directory. I seek to that point, then call AddJobs() to do the
// dirty work.
//
mpArchiveStorageObject->Seek( mlDirectoryOffset );
AddJobs( list );
if ( mStatus < 0 ) {
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
return mStatus;
}
//
// Now that all the new stuff is in the archive, I can figure
// out where the directory belongs, and write it out to position
// 0 in the archive.
//
//
// Now that all the new stuff is in the archive, I can figure
// out where the directory belongs, and write it out to position
// 0 in the archive.
//
mlDirectoryOffset = mpArchiveStorageObject->Tell();
mpArchiveStorageObject->Seek( 0L );
mpArchiveStorageObject->WritePortableLong( mlDirectoryOffset );
@ -1034,16 +1034,16 @@ int AL_PROTO ALArchiveBase::Append( ALEntryList AL_DLL_FAR &list )
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
return mStatus = mpArchiveStorageObject->mStatus;
}
//
// Now I write the old directory out, and then add in the new
// directory entries.
//
//
// Now I write the old directory out, and then add in the new
// directory entries.
//
list.mrMonitor.ArchiveOperation( AL_START_DIRECTORY_WRITE, this, 0 );
WriteDirectory( old_list );
AddDirectoryEntries( list );
//
// Update the monitor, check for errors, then leave.
//
//
// Update the monitor, check for errors, then leave.
//
list.mrMonitor.ArchiveOperation( AL_END_DIRECTORY_WRITE, this, 0 );
list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
ScanStatus( list );
@ -1083,42 +1083,42 @@ int AL_PROTO ALArchiveBase::Append( ALArchiveBase AL_DLL_FAR &source_archive,
ALEntryList AL_DLL_FAR &source_list )
{
ALEntryList old_list;
//
// Open the storage object associated with this.
//
//
// Open the storage object associated with this.
//
ALOpenInputFile archive( *mpArchiveStorageObject );
source_list.mrMonitor.ArchiveOperation( AL_ARCHIVE_OPEN, this, 0 );
//
// I have to read the current directory into memory, because as soon as
// I start to write objects out to this, I am going to obliterate
// the directory.
//
//
// I have to read the current directory into memory, because as soon as
// I start to write objects out to this, I am going to obliterate
// the directory.
//
ReadDirectory( old_list );
if ( mStatus < 0 ) {
source_list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
return mStatus;
}
//
// We don't want to create an archive that has duplicate entries, that would
// be a bad thing. So I first comb all the duplicate entries out of the list
// of objects to append. I then compare that list for duplicates against
// the list of objects already in the library, and comb out any matches
// there as well.
//
//
// We don't want to create an archive that has duplicate entries, that would
// be a bad thing. So I first comb all the duplicate entries out of the list
// of objects to append. I then compare that list for duplicates against
// the list of objects already in the library, and comb out any matches
// there as well.
//
source_list.UnmarkDuplicates( source_list, "Duplicate entry in list passed to Append()" );
source_list.UnmarkDuplicates( old_list, "Duplicate entry in list passed to Append()" );
//
// I am going to start writing new stuff at the location where the
// the directory starts right now.
//
//
// I am going to start writing new stuff at the location where the
// the directory starts right now.
//
mpArchiveStorageObject->Seek( mlDirectoryOffset );
//
// Before starting to copy jobs, I have to set up the monitor.
// This includes calculating the total number of compressed bytes
// in all the marked jobs. I could do this a lot easier by calling
// the CalculateCompressedBytes() function, but it's too late to change now.
//
//
// Before starting to copy jobs, I have to set up the monitor.
// This includes calculating the total number of compressed bytes
// in all the marked jobs. I could do this a lot easier by calling
// the CalculateCompressedBytes() function, but it's too late to change now.
//
source_list.mrMonitor.mlJobSoFar = 0L;
source_list.mrMonitor.mlJobSize = 0L;
for ( ALEntry *job = source_list.GetFirstEntry();
@ -1127,18 +1127,18 @@ int AL_PROTO ALArchiveBase::Append( ALArchiveBase AL_DLL_FAR &source_archive,
if ( job->GetMark() )
source_list.mrMonitor.mlJobSize += job->mlCompressedSize;
}
//
// CopyJobs() does the hard work for me.
//
//
// CopyJobs() does the hard work for me.
//
CopyJobs( source_archive, source_list );
if ( mStatus < 0 ) {
source_list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
return mStatus;
}
//
// The jobs are now in, I just have to update the directory with
// the old files and the new files.
//
//
// The jobs are now in, I just have to update the directory with
// the old files and the new files.
//
mlDirectoryOffset = mpArchiveStorageObject->Tell();
mpArchiveStorageObject->Seek( 0L );
mpArchiveStorageObject->WritePortableLong( mlDirectoryOffset );
@ -1149,9 +1149,9 @@ int AL_PROTO ALArchiveBase::Append( ALArchiveBase AL_DLL_FAR &source_archive,
source_list.mrMonitor.ArchiveOperation( AL_START_DIRECTORY_WRITE, this, 0 );
WriteDirectory( old_list );
AddDirectoryEntries( source_list );
//
// Wrap it up.
//
//
// Wrap it up.
//
source_list.mrMonitor.ArchiveOperation( AL_END_DIRECTORY_WRITE, this, 0 );
source_list.mrMonitor.ArchiveOperation( AL_ARCHIVE_CLOSE, this, 0 );
ScanStatus( source_list );
@ -1188,11 +1188,11 @@ int AL_PROTO ALArchiveBase::ReadDirectory( ALEntryList AL_DLL_FAR &list )
ALOpenInputFile archive( *mpArchiveStorageObject );
if ( mpArchiveStorageObject->mStatus < 0 )
return mStatus = mpArchiveStorageObject->mStatus;
//
// First I seek to the start of the directory (offset found at 0), and
// read in the version. This function only supports the directory
// structure defined in version 0x100.
//
//
// First I seek to the start of the directory (offset found at 0), and
// read in the version. This function only supports the directory
// structure defined in version 0x100.
//
mpArchiveStorageObject->Seek( 0 );
mpArchiveStorageObject->ReadPortableLong( mlDirectoryOffset );
mpArchiveStorageObject->Seek( mlDirectoryOffset );
@ -1201,40 +1201,40 @@ int AL_PROTO ALArchiveBase::ReadDirectory( ALEntryList AL_DLL_FAR &list )
return mStatus.SetError( AL_INVALID_ARCHIVE,
"%s is not a valid archive file",
mpArchiveStorageObject->mName.GetSafeName() );
//
// Read in any customized archive data defined by a derived class.
//
//
// Read in any customized archive data defined by a derived class.
//
ReadArchiveData();
//
// Read in the comment, deleting the old one if necessary.
//
//
// Read in the comment, deleting the old one if necessary.
//
if ( mszComment )
delete[] mszComment;
mszComment = mpArchiveStorageObject->ReadString();
//
// Now, the big loop. I have to read in each entry, one at a time, and
// add it to the list. If I broke this out into a separate routine it
// would make the whole thing a lot more manageable.
//
//
// Now, the big loop. I have to read in each entry, one at a time, and
// add it to the list. If I broke this out into a separate routine it
// would make the whole thing a lot more manageable.
//
for ( ; ; ) {
if ( mpArchiveStorageObject->mStatus < 0 )
return mStatus = mpArchiveStorageObject->mStatus;
char *name = mpArchiveStorageObject->ReadString();
if ( name == 0 )
break;
//
// The directory ends with a blank name.
//
//
// The directory ends with a blank name.
//
if ( strlen( name ) == 0 ) {
delete[] name;
break;
}
//
// Derived classes are responsible for providing a version of
// CreateCompressionEngine() that will convert the engine_type
// integer into a created compression engine. The derived class is
// then also responsible for reading in the engine data from the archive.
//
//
// Derived classes are responsible for providing a version of
// CreateCompressionEngine() that will convert the engine_type
// integer into a created compression engine. The derived class is
// then also responsible for reading in the engine data from the archive.
//
int engine_type = mpArchiveStorageObject->ReadChar();
ALCompressionEngine *engine = CreateCompressionEngine( engine_type );
if ( engine )
@ -1247,13 +1247,13 @@ int AL_PROTO ALArchiveBase::ReadDirectory( ALEntryList AL_DLL_FAR &list )
"Failure creating compression engine for object %s",
name );
}
//
// Now we go through a nearly identical process to create the storage object.
// The derived class is responsible for writing a CreateStorageObject()
// function that converts an object_type integer to a created storage
// object. The derived class also has to read in the storage object
// data.
//
//
// Now we go through a nearly identical process to create the storage object.
// The derived class is responsible for writing a CreateStorageObject()
// function that converts an object_type integer to a created storage
// object. The derived class also has to read in the storage object
// data.
//
int object_type = mpArchiveStorageObject->ReadChar();
ALStorage *storage_object = CreateStorageObject( name, object_type );
delete[] name; // Don't need it any more
@ -1268,9 +1268,9 @@ int AL_PROTO ALArchiveBase::ReadDirectory( ALEntryList AL_DLL_FAR &list )
"Failure creating storage object for object %s",
name );
}
//
// The rest of the stuff in the entry is pretty straightforward.
//
//
// The rest of the stuff in the entry is pretty straightforward.
//
mpArchiveStorageObject->ReadPortableLong( storage_object->mlSize );
ALEntry *job = new ALEntry( list, storage_object, engine );
mpArchiveStorageObject->ReadPortableLong( job->mlCompressedSize );
@ -1396,7 +1396,7 @@ int AL_PROTO ALArchiveBase::Delete( ALEntryList AL_DLL_FAR &list,
list.ToggleMarks();
ALName temp = mpArchiveStorageObject->mName;
mpArchiveStorageObject->RenameToBackup();
destination.mpArchiveStorageObject->Rename( temp );
destination.mpArchiveStorageObject->Rename( (const char*)temp );
if ( destination.mStatus < 0 )
return mStatus = destination.mStatus;
return mStatus;

View File

@ -34,7 +34,9 @@
#include "arclib.h"
#pragma hdrstop
#if XVT_OS != XVT_OS_SCOUNIX
#include <dos.h>
#endif
#include "fileattr.h"