Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// This Source Code is in the Public Domain per: http://unlicense.org
package org.litesoft.util;

import org.litesoft.commonfoundation.typeutils.*;
import org.litesoft.server.file.*;

import java.io.*;

public class FileReplacer extends AbstractFileAR {
    public static final String VERSION = "1.5";

    public static final int MAX_FILE_SIZE = 32 * 1024 * 1024;

    public static void main( String[] args )
            throws Exception {
        new FileReplacer().process( "FileReplacer", VERSION, args );
    }

    /**
     * Move Dir - Assume same volume!
     */
    @Override
    protected boolean moveDir( File pSource, File pDestination ) {
        Directories.deleteIfExists( pDestination );
        Directories.moveFile( pSource, pDestination );
        return true;
    }

    /**
     * Move File - Assume same volume!
     */
    @Override
    protected boolean moveFile( File pSource, File pDestination ) {
        FileUtils.deleteIfExists( pDestination );
        Directories.moveFile( pSource, pDestination );
        return true;
    }

    /**
     * Update the existing pDestination from the pSource - Assume NOT the same volume!
     */
    @Override
    protected boolean updateFile( File pSource, File pDestination ) {
        byte[] srcBytes = FileUtils.load( pSource, MAX_FILE_SIZE );
        byte[] dstBytes = FileUtils.load( pDestination, MAX_FILE_SIZE );
        if ( !Bytes.areArraysEqual( srcBytes, dstBytes ) ) {
            FileUtils.deleteIfExists( pDestination );
            FileUtils.store( pDestination, srcBytes );
            return true;
        }
        return false;
    }

    /**
     * Copy the pSource to the pDestination - Assume NOT the same volume!
     */
    @Override
    protected boolean copyAddFile( File pSource, File pDestination ) {
        byte[] zBytes = FileUtils.load( pSource, MAX_FILE_SIZE );
        FileUtils.store( pDestination, zBytes );
        return true;
    }
}

Commits for litesoft/trunk/Java/core/Server/src/org/litesoft/util/FileReplacer.java

Diff revisions: vs.
Revision Author Commited Message
958 Diff Diff GeorgeS picture GeorgeS Mon 14 Jul, 2014 15:29:35 +0000

Embrace OSS code bases.
Drop NAS-Video.

950 Diff Diff GeorgeS picture GeorgeS Thu 19 Jun, 2014 17:57:04 +0000

New Lines

948 Diff Diff GeorgeS picture GeorgeS Sat 07 Jun, 2014 23:42:39 +0000

Jusefuls Formatter Updated to New Code Format

947 Diff Diff GeorgeS picture GeorgeS Fri 06 Jun, 2014 23:36:56 +0000

Correct Spelling of package!

939 Diff Diff GeorgeS picture GeorgeS Mon 02 Jun, 2014 21:30:31 +0000

Extracting commonfoundation

823 Diff Diff GeorgeS picture GeorgeS Sun 19 Aug, 2012 16:10:13 +0000
812 Diff Diff GeorgeS picture GeorgeS Sat 18 Aug, 2012 17:45:40 +0000
809 Diff Diff GeorgeS picture GeorgeS Thu 16 Aug, 2012 04:10:46 +0000
80 Diff Diff GeorgeS picture GeorgeS Fri 29 Oct, 2010 17:23:26 +0000
76 GeorgeS picture GeorgeS Wed 27 Oct, 2010 00:24:59 +0000