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
64
65
66
67
68
69
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt
package org.litesoft.util;

import java.io.*;

import org.litesoft.commonfoundation.typeutils.*;

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
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 Diff Diff GeorgeS picture GeorgeS Wed 27 Oct, 2010 00:24:59 +0000
73 Diff Diff GeorgeS picture GeorgeS Mon 25 Oct, 2010 20:47:48 +0000
72 Diff Diff GeorgeS picture GeorgeS Mon 25 Oct, 2010 19:13:46 +0000
71 Diff Diff GeorgeS picture GeorgeS Mon 25 Oct, 2010 18:30:09 +0000
49 GeorgeS picture GeorgeS Mon 12 Apr, 2010 02:59:10 +0000

License Text