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 "arclib.h"
#include <utility.h>
#pragma hdrstop #pragma hdrstop
// //
@ -100,7 +101,7 @@
#if defined( AL_BUILDING_DLL ) #if defined( AL_BUILDING_DLL )
void AL_DLL_FAR * AL_PROTO ALEntry::operator new( size_t size ) void AL_DLL_FAR * AL_PROTO ALEntry::operator new( size_t size )
{ {
return ::new char[ size ]; return ::new char[ size ];
} }
#endif #endif
@ -130,7 +131,7 @@ void AL_DLL_FAR * AL_PROTO ALEntry::operator new( size_t size )
#if defined( AL_BUILDING_DLL ) #if defined( AL_BUILDING_DLL )
void AL_DLL_FAR * AL_PROTO ALEntryList::operator new( size_t size ) void AL_DLL_FAR * AL_PROTO ALEntryList::operator new( size_t size )
{ {
return ::new char[ size ]; return ::new char[ size ];
} }
#endif #endif
@ -191,34 +192,34 @@ void AL_DLL_FAR * AL_PROTO ALEntryList::operator new( size_t size )
// //
AL_PROTO ALEntry::ALEntry( ALEntryList &list, AL_PROTO ALEntry::ALEntry( ALEntryList &list,
ALStorage *object, ALStorage *object,
ALCompressionEngine *engine ) 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. // be a member of.
{ {
mpNextItem = this; mpNextItem = this;
mpPreviousItem = this; mpPreviousItem = this;
mpStorageObject = object; mpStorageObject = object;
mpCompressionEngine = engine; mpCompressionEngine = engine;
mlCompressedSize = -1; mlCompressedSize = -1;
mlCompressedObjectPosition = -1; mlCompressedObjectPosition = -1;
miMark = 1; //Always construct with the mark turned on miMark = 1; //Always construct with the mark turned on
mszComment = 0; mszComment = 0;
// //
// I check for the object member to be non-zero because of a clunky design // 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 // 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 // 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, // 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 // 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 // from the valid entries by virtue of the fact that it has a null
// pointer in its object pointer. // pointer in its object pointer.
// //
// So anyway, when I create this dummy object, I don't want to try to add // 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 // 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 do a check before adding any ALEntry to the list.
// //
if ( object ) if ( object )
InsertBefore( *list.mpListHead ); InsertBefore( *list.mpListHead );
} }
// //
@ -253,30 +254,30 @@ AL_PROTO ALEntry::ALEntry( ALEntryList &list,
AL_PROTO ALEntry::~ALEntry() AL_PROTO ALEntry::~ALEntry()
{ {
AL_ASSERT( GoodTag(), "~ALEntry: Attempting to delete invalid object" ); AL_ASSERT( GoodTag(), "~ALEntry: Attempting to delete invalid object" );
if ( mszComment ) if ( mszComment )
delete[] mszComment; delete[] mszComment;
if ( mpStorageObject != 0 ) if ( mpStorageObject != 0 )
delete mpStorageObject; delete mpStorageObject;
if ( mpCompressionEngine != 0 ) if ( mpCompressionEngine != 0 )
delete mpCompressionEngine; delete mpCompressionEngine;
AL_ASSERT( mpNextItem != 0 ,"~ALEntry: next item is null" ); AL_ASSERT( mpNextItem != 0 ,"~ALEntry: next item is null" );
AL_ASSERT( mpPreviousItem != 0, "~ALEntry: previous item is null" ); AL_ASSERT( mpPreviousItem != 0, "~ALEntry: previous item is null" );
ALEntry *next_job = mpNextItem; ALEntry *next_job = mpNextItem;
ALEntry *previous_job = mpPreviousItem; ALEntry *previous_job = mpPreviousItem;
if ( next_job != this ) { if ( next_job != this ) {
next_job->mpPreviousItem = previous_job; next_job->mpPreviousItem = previous_job;
previous_job->mpNextItem = next_job; previous_job->mpNextItem = next_job;
} }
// //
// Note that I check the object twice, one at the start of the dtor, and // 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 // 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 // being done here, it seems like it would be really easy to hose things
// up if any mistakes were made. // up if any mistakes were made.
// //
AL_ASSERT( GoodTag(), "~ALEntry: Attempting to delete invalid object" ); AL_ASSERT( GoodTag(), "~ALEntry: Attempting to delete invalid object" );
} }
// //
@ -306,22 +307,22 @@ AL_PROTO ALEntry::~ALEntry()
int AL_PROTO ALEntry::Duplicate( ALEntryList &list ) int AL_PROTO ALEntry::Duplicate( ALEntryList &list )
{ {
char *name = mpStorageObject->mName; char *name = mpStorageObject->mName;
int case_sensitive = mpStorageObject->mName.mCase == AL_MIXED; int case_sensitive = mpStorageObject->mName.mCase == AL_MIXED;
ALEntry *job = list.GetFirstEntry(); ALEntry *job = list.GetFirstEntry();
while ( job ) { while ( job ) {
if ( job->GetMark() && job != this ) { if ( job->GetMark() && job != this ) {
if ( case_sensitive ) { if ( case_sensitive ) {
if ( strcmp( name, job->mpStorageObject->mName ) == 0 ) if ( strcmp( name, job->mpStorageObject->mName ) == 0 )
return 1; return 1;
} else { } else {
if ( stricmp( name, job->mpStorageObject->mName ) == 0 ) if ( stricmp( name, job->mpStorageObject->mName ) == 0 )
return 1; return 1;
} }
}
job = job->GetNextEntry();
} }
return 0; job = job->GetNextEntry();
}
return 0;
} }
// //
@ -352,10 +353,10 @@ int AL_PROTO ALEntry::Duplicate( ALEntryList &list )
void AL_PROTO ALEntry::InsertBefore( ALEntry &job ) void AL_PROTO ALEntry::InsertBefore( ALEntry &job )
{ {
mpNextItem = &job; mpNextItem = &job;
mpPreviousItem = job.mpPreviousItem; mpPreviousItem = job.mpPreviousItem;
(job.mpPreviousItem)->mpNextItem = this; (job.mpPreviousItem)->mpNextItem = this;
job.mpPreviousItem = this; job.mpPreviousItem = this;
} }
// //
@ -387,20 +388,20 @@ void AL_PROTO ALEntry::InsertBefore( ALEntry &job )
int AL_PROTO ALEntry::SetComment( const char AL_DLL_FAR *comment ) int AL_PROTO ALEntry::SetComment( const char AL_DLL_FAR *comment )
{ {
if ( mszComment )
delete[] mszComment;
if ( comment ) {
mszComment = new char[ strlen( comment ) + 1 ];
if ( mszComment ) if ( mszComment )
delete[] mszComment; strcpy( mszComment, comment );
if ( comment ) { else
mszComment = new char[ strlen( comment ) + 1 ]; return mrList.mStatus.SetError( AL_CANT_ALLOCATE_MEMORY,
if ( mszComment ) "Failed to allocate memory when "
strcpy( mszComment, comment ); "adding comment to storage object %s",
else (char *) mpStorageObject->mName );
return mrList.mStatus.SetError( AL_CANT_ALLOCATE_MEMORY, } else
"Failed to allocate memory when " mszComment = 0;
"adding comment to storage object %s", return AL_SUCCESS;
(char *) mpStorageObject->mName );
} else
mszComment = 0;
return AL_SUCCESS;
} }
// //
@ -434,13 +435,13 @@ int AL_PROTO ALEntry::SetComment( const char AL_DLL_FAR *comment )
int AL_PROTO ALEntry::CompressionRatio() int AL_PROTO ALEntry::CompressionRatio()
{ {
long uncompressed_size = mpStorageObject->GetSize(); long uncompressed_size = mpStorageObject->GetSize();
if ( uncompressed_size <= 0 ) if ( uncompressed_size <= 0 )
return -1; return -1;
if ( mlCompressedSize <= 0 ) if ( mlCompressedSize <= 0 )
return -1; return -1;
return (int) ( 100 * mlCompressedSize / uncompressed_size ); return (int) ( 100 * mlCompressedSize / uncompressed_size );
} }
@ -481,9 +482,9 @@ int AL_PROTO ALEntry::CompressionRatio()
ALMonitor ALDefaultMonitor( AL_MONITOR_OBJECTS ); ALMonitor ALDefaultMonitor( AL_MONITOR_OBJECTS );
AL_PROTO ALEntryList::ALEntryList( ALMonitor AL_DLL_FAR * monitor /* = 0 */ ) AL_PROTO ALEntryList::ALEntryList( ALMonitor AL_DLL_FAR * monitor /* = 0 */ )
: mrMonitor( monitor ? *monitor : ALDefaultMonitor ) : mrMonitor( monitor ? *monitor : ALDefaultMonitor )
{ {
mpListHead = new ALEntry( *this, 0, 0 ); mpListHead = new ALEntry( *this, 0, 0 );
} }
// //
@ -512,16 +513,16 @@ AL_PROTO ALEntryList::ALEntryList( ALMonitor AL_DLL_FAR * monitor /* = 0 */ )
AL_PROTO ALEntryList::~ALEntryList() AL_PROTO ALEntryList::~ALEntryList()
{ {
AL_ASSERT( GoodTag(), "~ALEntryList: attempting to delete invalid object" ); AL_ASSERT( GoodTag(), "~ALEntryList: attempting to delete invalid object" );
ALEntry *job = GetFirstEntry(); ALEntry *job = GetFirstEntry();
while ( job ) { while ( job ) {
ALEntry *next_job = job->GetNextEntry(); ALEntry *next_job = job->GetNextEntry();
delete job; delete job;
job = next_job; job = next_job;
} }
if ( mpListHead ) if ( mpListHead )
delete mpListHead; delete mpListHead;
AL_ASSERT( GoodTag(), "~ALEntryList: attempting to delete invalid object" ); AL_ASSERT( GoodTag(), "~ALEntryList: attempting to delete invalid object" );
} }
// PROTECTED FUNCTION // PROTECTED FUNCTION
@ -555,24 +556,24 @@ AL_PROTO ALEntryList::~ALEntryList()
// //
int AL_PROTO ALEntryList::SetMarkState( const char AL_DLL_FAR *name, int AL_PROTO ALEntryList::SetMarkState( const char AL_DLL_FAR *name,
short int new_state ) short int new_state )
{ {
int count = 0; int count = 0;
ALEntry *job = GetFirstEntry(); ALEntry *job = GetFirstEntry();
while ( job ) { while ( job ) {
if ( name ) { if ( name ) {
if ( job->mpStorageObject->mName.WildCardMatch( name ) ) { if ( job->mpStorageObject->mName.WildCardMatch( name ) ) {
job->SetMarkState( new_state ); job->SetMarkState( new_state );
count++; count++;
} }
} else { } else {
job->SetMarkState( new_state ); job->SetMarkState( new_state );
count++; count++;
}
job = job->GetNextEntry();
} }
return count; job = job->GetNextEntry();
}
return count;
} }
// //
@ -600,14 +601,14 @@ int AL_PROTO ALEntryList::SetMarkState( const char AL_DLL_FAR *name,
int AL_PROTO ALEntryList::ToggleMarks() int AL_PROTO ALEntryList::ToggleMarks()
{ {
int count = 0; int count = 0;
ALEntry *job = GetFirstEntry(); ALEntry *job = GetFirstEntry();
while ( job ) { while ( job ) {
job->SetMarkState( (short int) !job->GetMark() ); job->SetMarkState( (short int) !job->GetMark() );
job = job->GetNextEntry(); job = job->GetNextEntry();
count++; count++;
} }
return count; return count;
} }
// //
@ -639,15 +640,15 @@ int AL_PROTO ALEntryList::ToggleMarks()
ALEntry AL_DLL_FAR * AL_PROTO ALEntry::GetNextEntry() ALEntry AL_DLL_FAR * AL_PROTO ALEntry::GetNextEntry()
{ {
ALEntry *next_entry = this->mpNextItem; ALEntry *next_entry = this->mpNextItem;
// //
// The list head has the special case where both the compression engine // 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. // and storage object pointers are 0, and that makes the end of the list.
// //
if ( mpNextItem->mpStorageObject == 0 ) if ( mpNextItem->mpStorageObject == 0 )
return 0; return 0;
else else
return next_entry; return next_entry;
} }
// //
@ -677,7 +678,7 @@ ALEntry AL_DLL_FAR * AL_PROTO ALEntry::GetNextEntry()
ALEntry AL_DLL_FAR * AL_PROTO ALEntryList::GetFirstEntry() ALEntry AL_DLL_FAR * AL_PROTO ALEntryList::GetFirstEntry()
{ {
return mpListHead->GetNextEntry(); return mpListHead->GetNextEntry();
} }
// //
@ -720,21 +721,21 @@ ALEntry AL_DLL_FAR * AL_PROTO ALEntryList::GetFirstEntry()
// //
void AL_PROTO ALEntryList::UnmarkDuplicates( ALEntryList &list, void AL_PROTO ALEntryList::UnmarkDuplicates( ALEntryList &list,
const char *error_message /* = 0 */ ) const char *error_message /* = 0 */ )
{ {
ALEntry *job = GetFirstEntry(); ALEntry *job = GetFirstEntry();
while ( job ) { while ( job ) {
if ( job->GetMark() ) { if ( job->GetMark() ) {
if ( job->Duplicate( list ) ) { if ( job->Duplicate( list ) ) {
job->ClearMark(); job->ClearMark();
if ( error_message && error_message[ 0 ] != '\0' ) if ( error_message && error_message[ 0 ] != '\0' )
job->mpStorageObject->mStatus.SetError( job->mpStorageObject->mStatus.SetError(
AL_DUPLICATE_ENTRY, AL_DUPLICATE_ENTRY,
error_message ); error_message );
} }
}
job = job->GetNextEntry();
} }
job = job->GetNextEntry();
}
} }
// //
@ -762,19 +763,19 @@ void AL_PROTO ALEntryList::UnmarkDuplicates( ALEntryList &list,
int AL_PROTO ALEntryList::DeleteUnmarked() int AL_PROTO ALEntryList::DeleteUnmarked()
{ {
ALEntry *job; ALEntry *job;
int count = 0; int count = 0;
job = GetFirstEntry(); job = GetFirstEntry();
while ( job ) { while ( job ) {
ALEntry *next_job = job->GetNextEntry(); ALEntry *next_job = job->GetNextEntry();
if ( job->GetMark() == 0 ) { if ( job->GetMark() == 0 ) {
count++; count++;
delete job; delete job;
}
job = next_job;
} }
return count; job = next_job;
}
return count;
} }
// //
@ -811,31 +812,31 @@ int AL_PROTO ALEntryList::DeleteUnmarked()
#if defined( AL_WINDOWS_GUI ) #if defined( AL_WINDOWS_GUI )
int AL_PROTO ALEntryList::FillListBox( HWND hDlg, int list_box /* = -1 */ ) int AL_PROTO ALEntryList::FillListBox( HWND hDlg, int list_box /* = -1 */ )
{ {
HWND window; HWND window;
if ( list_box != -1 ) if ( list_box != -1 )
window = GetDlgItem( hDlg, (short int) list_box ); window = GetDlgItem( hDlg, (short int) list_box );
else else
window = hDlg; window = hDlg;
SendMessage( window, LB_RESETCONTENT, 0, 0 ); SendMessage( window, LB_RESETCONTENT, 0, 0 );
ALEntry *job = GetFirstEntry(); ALEntry *job = GetFirstEntry();
int count = 0; int count = 0;
while ( job ) { while ( job ) {
if ( job->GetMark() ) { if ( job->GetMark() ) {
count++; count++;
SendMessage( window, SendMessage( window,
LB_ADDSTRING, LB_ADDSTRING,
0, 0,
(LPARAM)( (LPSTR) job->mpStorageObject->mName ) ); (LPARAM)( (LPSTR) job->mpStorageObject->mName ) );
}
job = job->GetNextEntry();
} }
if ( count == 0 ) job = job->GetNextEntry();
SendMessage( window, }
LB_ADDSTRING, if ( count == 0 )
0, SendMessage( window,
(LPARAM)( (LPSTR) "<none>" ) ); LB_ADDSTRING,
return count; 0,
(LPARAM)( (LPSTR) "<none>" ) );
return count;
} }
@ -871,43 +872,43 @@ int AL_PROTO ALEntryList::FillListBox( HWND hDlg, int list_box /* = -1 */ )
int AL_PROTO ALEntryList::SetMarksFromListBox( HWND hDlg, int list_box /* = -1 */ ) int AL_PROTO ALEntryList::SetMarksFromListBox( HWND hDlg, int list_box /* = -1 */ )
{ {
HWND window; HWND window;
if ( list_box != -1 ) if ( list_box != -1 )
window = GetDlgItem( hDlg, (short int) list_box ); window = GetDlgItem( hDlg, (short int) list_box );
else else
window = hDlg; window = hDlg;
WORD count = (WORD) SendMessage( window, LB_GETSELCOUNT, 0, 0L ); WORD count = (WORD) SendMessage( window, LB_GETSELCOUNT, 0, 0L );
int *items = new int[ count ]; int *items = new int[ count ];
if ( items == 0 ) if ( items == 0 )
return mStatus.SetError( AL_CANT_ALLOCATE_MEMORY, return mStatus.SetError( AL_CANT_ALLOCATE_MEMORY,
"Memory allocation failure in SetMarksFromListBox()" ); "Memory allocation failure in SetMarksFromListBox()" );
#ifdef AL_FLAT_MODEL #ifdef AL_FLAT_MODEL
if ( count != (WORD) SendMessage( window, LB_GETSELITEMS, count, (LPARAM) ( items ) ) ) { if ( count != (WORD) SendMessage( window, LB_GETSELITEMS, count, (LPARAM) ( items ) ) ) {
#else #else
if ( count != (WORD) SendMessage( window, LB_GETSELITEMS, count, (LPARAM) ( (int _far * ) items ) ) ) { if ( count != (WORD) SendMessage( window, LB_GETSELITEMS, count, (LPARAM) ( (int _far * ) items ) ) ) {
#endif #endif
mStatus.SetError( AL_LOGIC_ERROR, mStatus.SetError( AL_LOGIC_ERROR,
"Logic error in SetMarksFromListBox()." "Logic error in SetMarksFromListBox()."
"Mismatch in select count from list box." ); "Mismatch in select count from list box." );
delete[] items; delete[] items;
return AL_LOGIC_ERROR; return AL_LOGIC_ERROR;
} }
for ( WORD i = 0 ; i < count ; i++ ) { for ( WORD i = 0 ; i < count ; i++ ) {
WORD length = (WORD) SendMessage( window, LB_GETTEXTLEN, (short int) items[ i ], 0L ); WORD length = (WORD) SendMessage( window, LB_GETTEXTLEN, (short int) items[ i ], 0L );
AL_ASSERT( length != (WORD) LB_ERR, "SetMarksFromListBox: LB_ERR returned from list box" ); AL_ASSERT( length != (WORD) LB_ERR, "SetMarksFromListBox: LB_ERR returned from list box" );
if ( length > 0 ) { if ( length > 0 ) {
char *name = new char[ length + 1 ]; char *name = new char[ length + 1 ];
if ( name ) { if ( name ) {
if ( SendMessage( window, LB_GETTEXT, (short int) items[ i ], (LPARAM)( (LPSTR) name ) ) >= 0 ) if ( SendMessage( window, LB_GETTEXT, (short int) items[ i ], (LPARAM)( (LPSTR) name ) ) >= 0 )
SetMarks( name ); SetMarks( name );
delete[] name; delete[] name;
}
} }
}
} }
delete[] items; delete[] items;
return count; return count;
} }
#endif #endif

View File

@ -78,7 +78,7 @@
#if defined( AL_BUILDING_DLL ) #if defined( AL_BUILDING_DLL )
void AL_DLL_FAR * AL_PROTO ALArchive::operator new( size_t size ) void AL_DLL_FAR * AL_PROTO ALArchive::operator new( size_t size )
{ {
return ::new char[ size ]; return ::new char[ size ];
} }
#endif #endif
@ -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 ) 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 ) AL_PROTO ALArchive::ALArchive( ALStorage AL_DLL_FAR &so )
: ALArchiveBase( &so, 0 ) : ALArchiveBase( &so, 0 )
{ {
} }
@ -173,7 +173,7 @@ AL_PROTO ALArchive::ALArchive( ALStorage AL_DLL_FAR &so )
AL_PROTO ALArchive::~ALArchive() AL_PROTO ALArchive::~ALArchive()
{ {
AL_ASSERT( GoodTag(), "~ALArchive: attempt to delete invalid object" ); AL_ASSERT( GoodTag(), "~ALArchive: attempt to delete invalid object" );
} }
// //
@ -206,18 +206,18 @@ AL_PROTO ALArchive::~ALArchive()
ALCompressionEngine AL_DLL_FAR * ALCompressionEngine AL_DLL_FAR *
AL_PROTO ALArchive::CreateCompressionEngine( int engine_type ) AL_PROTO ALArchive::CreateCompressionEngine( int engine_type )
{ {
switch ( engine_type ) { switch ( engine_type ) {
case AL_COMPRESSION_COPY : case AL_COMPRESSION_COPY :
return new ALCopyEngine(); return new ALCopyEngine();
case AL_COMPRESSION_GREENLEAF : case AL_COMPRESSION_GREENLEAF :
return new ALGreenleafEngine(); return new ALGreenleafEngine();
default : default :
mStatus.SetError( AL_UNKNOWN_COMPRESSION_TYPE, mStatus.SetError( AL_UNKNOWN_COMPRESSION_TYPE,
"Unknown compression type (%d) found in archive", "Unknown compression type (%d) found in archive",
engine_type ); engine_type );
break; //Break instead of return because of bogus warnings break; //Break instead of return because of bogus warnings
} }
return 0; return 0;
} }
// //
@ -251,22 +251,22 @@ AL_PROTO ALArchive::CreateCompressionEngine( int engine_type )
ALStorage AL_DLL_FAR * AL_PROTO ALStorage AL_DLL_FAR * AL_PROTO
ALArchive::CreateStorageObject( const char AL_DLL_FAR *name, ALArchive::CreateStorageObject( const char AL_DLL_FAR *name,
int object_type ) int object_type )
{ {
switch ( object_type ) { switch ( object_type ) {
case AL_MEMORY_OBJECT : case AL_MEMORY_OBJECT :
return new ALMemory( name ); return new ALMemory( name );
case AL_FILE_OBJECT : case AL_FILE_OBJECT :
return new ALFile( name ); return new ALFile( name );
default : default :
mStatus.SetError( AL_UNKNOWN_STORAGE_OBJECT, mStatus.SetError( AL_UNKNOWN_STORAGE_OBJECT,
"Unknown storage object type (%d) " "Unknown storage object type (%d) "
"found in archive", "found in archive",
object_type ); object_type );
break; break;
} }
return 0; return 0;
} }
// STATIC MEMBER FUNCTION // STATIC MEMBER FUNCTION
@ -325,22 +325,22 @@ ALArchive::CreateStorageObject( const char AL_DLL_FAR *name,
int AL_PROTO int AL_PROTO
ALArchive::AddWildCardFiles( ALEntryList AL_DLL_FAR & list, ALArchive::AddWildCardFiles( ALEntryList AL_DLL_FAR & list,
const char AL_DLL_FAR *wild_spec /* = "*.*" */, const char AL_DLL_FAR *wild_spec /* = "*.*" */,
int traverse_flag /* = 0 */, int traverse_flag /* = 0 */,
short int compression_level /* = AL_GREENLEAF_LEVEL_2 */ ) short int compression_level /* = AL_GREENLEAF_LEVEL_2 */ )
{ {
AL_ASSERT( wild_spec != 0, "AddWildCardFiles: null parameter for wild_spec" ); AL_ASSERT( wild_spec != 0, "AddWildCardFiles: null parameter for wild_spec" );
ALWildCardExpander files( wild_spec, traverse_flag ); ALWildCardExpander files( wild_spec, traverse_flag );
int count = 0; int count = 0;
char *new_name; char *new_name; ALEntry* dummy;
while ( ( new_name = files.GetNextFile() ) != 0 ) { while ( ( new_name = files.GetNextFile() ) != 0 ) {
new ALEntry( list, dummy = new ALEntry( list,
new ALFile( new_name ), new ALFile( new_name ),
new ALGreenleafEngine( compression_level ) ); new ALGreenleafEngine( compression_level ) );
count++; count++;
} }
return count; return count;
} }
// //
@ -385,49 +385,49 @@ ALArchive::AddWildCardFiles( ALEntryList AL_DLL_FAR & list,
int AL_PROTO ALArchive:: int AL_PROTO ALArchive::
MakeEntriesFromListBox( ALEntryList AL_DLL_FAR &list, MakeEntriesFromListBox( ALEntryList AL_DLL_FAR &list,
HWND hDlg, HWND hDlg,
int list_box /* = -1 */ ) int list_box /* = -1 */ )
{ {
HWND window; HWND window;
if ( list_box != -1 ) if ( list_box != -1 )
window = GetDlgItem( hDlg, (short int) list_box ); window = GetDlgItem( hDlg, (short int) list_box );
else else
window = hDlg; window = hDlg;
int count = (WORD) SendMessage( window, LB_GETSELCOUNT, 0, 0L ); int count = (WORD) SendMessage( window, LB_GETSELCOUNT, 0, 0L );
if ( count == LB_ERR ) if ( count == LB_ERR )
return AL_GETSEL_ERROR; return AL_GETSEL_ERROR;
int *items = new int[ count ]; int *items = new int[ count ];
if ( items == 0 ) if ( items == 0 )
return AL_CANT_ALLOCATE_MEMORY; return AL_CANT_ALLOCATE_MEMORY;
#ifdef AL_FLAT_MODEL #ifdef AL_FLAT_MODEL
if ( count != SendMessage( window, LB_GETSELITEMS, (short int) count, (LPARAM) items ) ) { if ( count != SendMessage( window, LB_GETSELITEMS, (short int) count, (LPARAM) items ) ) {
#else #else
if ( count != SendMessage( window, LB_GETSELITEMS, (short int) count, (LPARAM)(int _far *) items ) ) { if ( count != SendMessage( window, LB_GETSELITEMS, (short int) count, (LPARAM)(int _far *) items ) ) {
#endif #endif
delete items; delete items;
return AL_GETSEL_ERROR; return AL_GETSEL_ERROR;
} }
for ( WORD i = 0 ; i < (WORD) count ; i++ ) { for ( WORD i = 0 ; i < (WORD) count ; i++ ) {
WORD length = (WORD) SendMessage( window, LB_GETTEXTLEN, (short int) items[ i ], 0L ); WORD length = (WORD) SendMessage( window, LB_GETTEXTLEN, (short int) items[ i ], 0L );
if ( length > 0 ) { if ( length > 0 ) {
char *name = new char[ length + 1 ]; char *name = new char[ length + 1 ];
if ( name ) { if ( name ) {
if ( SendMessage( window, LB_GETTEXT, (short int) items[ i ], (LPARAM)( (LPSTR) name ) ) >= 0 ) { if ( SendMessage( window, LB_GETTEXT, (short int) items[ i ], (LPARAM)( (LPSTR) name ) ) >= 0 ) {
new ALEntry( list, new ALEntry( list,
new ALFile( name ), new ALFile( name ),
new ALGreenleafEngine() ); new ALGreenleafEngine() );
} }
delete name; delete name;
SendMessage( window, SendMessage( window,
LB_SETSEL, LB_SETSEL,
0, 0,
items[ i ] ); items[ i ] );
}
} }
}
} }
delete items; delete items;
return count; return count;
} }
#endif //#ifdef AL_WINDOWS_GUI #endif //#ifdef AL_WINDOWS_GUI

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,9 @@
#include "arclib.h" #include "arclib.h"
#pragma hdrstop #pragma hdrstop
#if XVT_OS != XVT_OS_SCOUNIX
#include <dos.h> #include <dos.h>
#endif
#include "fileattr.h" #include "fileattr.h"
@ -72,7 +74,7 @@
#if defined( AL_BUILDING_DLL ) #if defined( AL_BUILDING_DLL )
void AL_DLL_FAR * AL_PROTO ALFileAttributes::operator new( size_t size ) void AL_DLL_FAR * AL_PROTO ALFileAttributes::operator new( size_t size )
{ {
return ::new char[ size ]; return ::new char[ size ];
} }
#endif #endif
@ -103,10 +105,10 @@ void AL_DLL_FAR * AL_PROTO ALFileAttributes::operator new( size_t size )
AL_PROTO ALFileAttributes::ALFileAttributes() AL_PROTO ALFileAttributes::ALFileAttributes()
{ {
miReadOnly = 0; miReadOnly = 0;
miSystem = 0; miSystem = 0;
miHidden = 0; miHidden = 0;
miArchive = 0; miArchive = 0;
} }
// //
@ -164,10 +166,10 @@ AL_PROTO ALFileAttributes::~ALFileAttributes()
void AL_PROTO ALFileAttributes:: void AL_PROTO ALFileAttributes::
SetFromPackedAttributes( short int attributes ) SetFromPackedAttributes( short int attributes )
{ {
miReadOnly = ( attributes & 1 ) != 0; miReadOnly = ( attributes & 1 ) != 0;
miSystem = ( attributes & 2 ) != 0; miSystem = ( attributes & 2 ) != 0;
miHidden = ( attributes & 4 ) != 0; miHidden = ( attributes & 4 ) != 0;
miArchive = ( attributes & 8 ) != 0; miArchive = ( attributes & 8 ) != 0;
} }
// //
@ -203,10 +205,10 @@ SetFromPackedAttributes( short int attributes )
void AL_PROTO ALFileAttributes:: void AL_PROTO ALFileAttributes::
SetFromWin32Attributes( DWORD win32_attributes ) SetFromWin32Attributes( DWORD win32_attributes )
{ {
miReadOnly = ( win32_attributes & FILE_ATTRIBUTE_READONLY ) != 0; miReadOnly = ( win32_attributes & FILE_ATTRIBUTE_READONLY ) != 0;
miSystem = ( win32_attributes & FILE_ATTRIBUTE_SYSTEM ) != 0; miSystem = ( win32_attributes & FILE_ATTRIBUTE_SYSTEM ) != 0;
miHidden = ( win32_attributes & FILE_ATTRIBUTE_HIDDEN ) != 0; miHidden = ( win32_attributes & FILE_ATTRIBUTE_HIDDEN ) != 0;
miArchive = ( win32_attributes & FILE_ATTRIBUTE_ARCHIVE ) != 0; miArchive = ( win32_attributes & FILE_ATTRIBUTE_ARCHIVE ) != 0;
} }
#endif #endif
@ -243,10 +245,10 @@ SetFromWin32Attributes( DWORD win32_attributes )
void AL_PROTO ALFileAttributes::SetFromDosAttributes( unsigned dos_attributes ) void AL_PROTO ALFileAttributes::SetFromDosAttributes( unsigned dos_attributes )
{ {
miReadOnly = ( dos_attributes & _A_RDONLY ) != 0; miReadOnly = ( dos_attributes & _A_RDONLY ) != 0;
miSystem = ( dos_attributes & _A_SYSTEM ) != 0; miSystem = ( dos_attributes & _A_SYSTEM ) != 0;
miHidden = ( dos_attributes & _A_HIDDEN ) != 0; miHidden = ( dos_attributes & _A_HIDDEN ) != 0;
miArchive = ( dos_attributes & _A_ARCH ) != 0; miArchive = ( dos_attributes & _A_ARCH ) != 0;
} }
#endif #endif
@ -279,13 +281,13 @@ void AL_PROTO ALFileAttributes::SetFromDosAttributes( unsigned dos_attributes )
unsigned short int AL_PROTO ALFileAttributes::PackedAttributes() unsigned short int AL_PROTO ALFileAttributes::PackedAttributes()
{ {
int result = 0; int result = 0;
result |= miReadOnly ? 1 : 0; result |= miReadOnly ? 1 : 0;
result |= miSystem ? 2 : 0; result |= miSystem ? 2 : 0;
result |= miHidden ? 4 : 0; result |= miHidden ? 4 : 0;
result |= miArchive ? 8 : 0; result |= miArchive ? 8 : 0;
return (unsigned short int ) result; return (unsigned short int ) result;
} }
// //
@ -316,12 +318,12 @@ unsigned short int AL_PROTO ALFileAttributes::PackedAttributes()
unsigned short int AL_PROTO ALFileAttributes::GetDosAttributes() unsigned short int AL_PROTO ALFileAttributes::GetDosAttributes()
{ {
int result = 0; int result = 0;
result |= miReadOnly ? _A_RDONLY : 0; result |= miReadOnly ? _A_RDONLY : 0;
result |= miSystem ? _A_SYSTEM : 0; result |= miSystem ? _A_SYSTEM : 0;
result |= miHidden ? _A_HIDDEN : 0; result |= miHidden ? _A_HIDDEN : 0;
result |= miArchive ? _A_ARCH : 0; result |= miArchive ? _A_ARCH : 0;
return (unsigned short int) result; return (unsigned short int) result;
} }
#endif //#if !defined( AL_WIN32S ) #endif //#if !defined( AL_WIN32S )
@ -353,11 +355,11 @@ unsigned short int AL_PROTO ALFileAttributes::GetDosAttributes()
DWORD AL_PROTO ALFileAttributes::GetWin32Attributes() DWORD AL_PROTO ALFileAttributes::GetWin32Attributes()
{ {
DWORD result = 0; DWORD result = 0;
result |= miReadOnly ? FILE_ATTRIBUTE_READONLY : 0; result |= miReadOnly ? FILE_ATTRIBUTE_READONLY : 0;
result |= miSystem ? FILE_ATTRIBUTE_SYSTEM : 0; result |= miSystem ? FILE_ATTRIBUTE_SYSTEM : 0;
result |= miHidden ? FILE_ATTRIBUTE_HIDDEN : 0; result |= miHidden ? FILE_ATTRIBUTE_HIDDEN : 0;
result |= miArchive ? FILE_ATTRIBUTE_ARCHIVE : 0; result |= miArchive ? FILE_ATTRIBUTE_ARCHIVE : 0;
return result; return result;
} }
#endif //#if !defined( AL_WIN32S ) #endif //#if !defined( AL_WIN32S )