Example #1
0
static rc_t copy2_main( Args * args )
{
    const char * source_path;
    rc_t rc = ArgsParamValue( args, 0, &source_path );
    if ( rc != 0 )
        LOGERR( klogInt, rc, "ArgsParamValue( 0 ) failed" );
    else
    {
        const char * dest_path;
        rc = ArgsParamValue( args, 1, &dest_path );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "ArgsParamValue( 1 ) failed" );
        else
        {
            KDirectory *dir, *dest_dir;
            const KDirectory *source_dir;
            rc = KDirectoryNativeDir ( &dir );
            if ( rc != 0 )
                LOGERR( klogInt, rc, "KDirectoryNativeDir() failed" );
            else
            {
                rc = KDirectoryOpenDirRead( dir, &source_dir, false,
                                            source_path );
                if ( rc != 0 )
                    LOGERR( klogInt, rc, "KDirectoryOpenDirRead() failed" );
                else
                {
                    rc = KDirectoryOpenDirUpdate( dir, &dest_dir, false,
                                            dest_path );
                    if ( rc != 0 )
                        LOGERR( klogInt, rc,
                                "KDirectoryOpenDirUpdate() failed" );
                    else
                    {
                        rc = KDirectoryCopy( source_dir, dest_dir, true,
                                             source_path, dest_path );
                        if ( rc != 0 )
                            LOGERR( klogInt, rc, "copy_dirs() failed" );
                        else
                            OUTMSG(( "copy successful!\n" ));
                        KDirectoryRelease ( dest_dir );
                    }
                    KDirectoryRelease ( source_dir );
                }
                KDirectoryRelease ( dir );
            }
        }
    }
    return rc;
}
Example #2
0
static rc_t copy_library( const KDirectory * src_dir, KDirectory * dst_dir,
                          const char * in_path, const char * out_path )
{
    rc_t rc;
    size_t l = string_size( out_path ) + string_size( lib_dst ) + 2;
    char * dst = malloc( l );
    if ( dst == NULL )
        rc = RC( rcExe, rcFile, rcCopying, rcMemory, rcExhausted );
    else
    {
        size_t written;
        rc = string_printf( dst, l, &written, "%s/%s", out_path, lib_dst );
        if ( rc == 0 )
            rc = KDirectoryCopy( src_dir, dst_dir, true, in_path, dst );
        free( dst );
    }
    return rc;
}