campo-sirio/al/examples/ex03con.c

81 lines
2.3 KiB
C
Raw Normal View History

/*
* EX03CON.C
*
* C/DOS Example program for ArchiveLib 2.0
*
* Copyright (c) Greenleaf Software, Inc. 1994 - 1996
* All Rights Reserved
*
* MEMBERS/FUNCTIONS DEMONSTRATED
*
* ALArchiveDelete()
* ALEntryGetNextEntry()
* ALEntrySetMark()
* ALEntryListClearMarks()
* ALEntryListGetFirstEntry()
*
* DESCRIPTION
*
* This example program takes the existing dos00.gal archive (create it
* with EX01CON if you don't have it) and deletes every other entry.
* Note that when we call Delete(), we specify an Archive with an empty
* name, which causes ALArchiveBase::Delete() to rename the input to a
* backup, and rename the output to the original input name. Clear?
*
* REVISION HISTORY
*
* February 1, 1996 2.0A : Second release
*
*/
#include <stdio.h>
#include <conio.h>
#include "arclib.h"
#include "pkarc.h"
#include "glarc.h"
int main()
{
hALArchive archive;
hALArchive temp;
hALEntryList list;
hALEntry entry;
long total = 0;
printf( "Archive Library 2.0\nEX03CON.C\n\n" );
printf( "This example program takes the existing dos00.gal archive (create it\n" );
printf( "with EX00CON if you don't have it) and deletes every other entry.\n" );
printf( "Note that when we call Delete(), we specify an Archive with an empty\n" );
printf( "name, which causes ALArchiveBase::Delete() to rename the input to a\n" );
printf( "backup, and rename the output to the original input name.\n" );
getch();
printf( "\nDeleting every other object from "
#if defined( ZIP )
"dos00.zip\n" );
archive = newALPkArchive( "dos00.zip" );
temp = newALPkArchive( "" );
list = newALListPkTools( 0, 6, 13, 6 );
#else
"dos00.gal\n" );
archive = newALGlArchive( "dos00.gal" );
temp = newALGlArchive( "" );
list = newALListGlTools( 0, AL_GREENLEAF_LEVEL_4 );
#endif
ALArchiveReadDirectory( archive, list );
ALEntryListClearMarks( list, 0 ); /* Clear every mark */
entry = ALEntryListGetFirstEntry( list );
while ( entry ) {
total++;
if (total % 2) {
ALEntrySetMark( entry );
printf( "Deleting: %s\n",
ALStorageGetName( ALEntryGetStorage( entry ) ) );
}
entry = ALEntryGetNextEntry( entry );
}
return ALArchiveDelete( archive, list, temp );
}