Exemplo n.º 1
0
void WriteNewLib( void )
{
    char tmp[ _MAX_PATH + 1 ];
    char *bak,*lib,*out;

    lib = Options.input_name;
    if( Options.output_name != NULL && !SameFile( lib, Options.output_name ) ) {
        out = Options.output_name;
    } else {
        out = MakeTmpName( tmp );
    }
    if( Options.export_list_file ) {
        ExportListFile = LibOpen( Options.export_list_file, LIBOPEN_BINARY_WRITE | O_CREAT);
    } else {
        ExportListFile = NULL;
    }
    NewLibrary = LibOpen( out, LIBOPEN_BINARY_WRITE );
    if( NewLibrary == NULL ) {
        if( out == tmp ) {
            FatalError( ERR_CANT_OPEN, out, "Cannot create temporary file" );
        } else {
            FatalError( ERR_CANT_OPEN, out, strerror( errno ) );
        }
    }
    WriteFileTable();
    LibClose( NewLibrary );
    if( ExportListFile != NULL ) {
        LibClose( ExportListFile );
    }
    ResetInputLibs();//closes all input libs
    if( out == tmp ) {
        bak = MakeBakName();
        if( access( bak, F_OK ) == 0 && remove( bak ) != 0 ) {
            FatalError( ERR_CANT_REMOVE, bak );
        }
        if( access( lib, F_OK ) == 0 && rename( lib, bak ) != 0 ) {
            FatalError( ERR_CANT_REPLACE, lib, strerror( errno ) );
        }
        if( rename( tmp, lib ) != 0 ) {
            rename( bak, lib );
            FatalError( ERR_CANT_REPLACE, lib, strerror( errno ) );
        }
        if( Options.no_backup ) {
            remove( bak );
        }
    }
}
Exemplo n.º 2
0
int WlibMainLine( char *argv[] )
{
    int     retcode;

    InitCmdLine();          // JBS 99/07/09 reset options for each use
    if( !setjmp( Env ) ) {
        ProcessCmdLine( argv );
        ProcessCommands();
        retcode = EXIT_SUCCESS;
    } else {
        retcode = EXIT_FAILURE;
    }
    if( !setjmp( Env ) ) {
        ResetInputLibs();
        ResetFileTab();
        ResetCmdLine();
        ResetLibIo();
        ResetMem();
    } else {
        retcode = EXIT_FAILURE;
    }
    return( retcode );
}