Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
bd41e2d2f5 | |||
c59a700cf9 | |||
641a562563 | |||
e49bd4e9c9 |
@ -3,16 +3,17 @@ apply plugin: "application"
|
||||
apply plugin: "maven"
|
||||
|
||||
group = "com.jdblabs"
|
||||
version = "1.4.2"
|
||||
version = "1.4.4"
|
||||
mainClassName = "com.jdblabs.file.treediff.TreeDiff"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral() }
|
||||
mavenCentral()
|
||||
maven { url "http://mvn.jdb-labs.com/repo" } }
|
||||
|
||||
dependencies {
|
||||
compile 'org.codehaus.groovy:groovy-all:2.4.3'
|
||||
compile 'com.jdbernard:jdb-util:3.8'
|
||||
compile localGroovy()
|
||||
compile 'com.jdbernard:jdb-util:4.+'
|
||||
compile 'commons-codec:commons-codec:1.10'
|
||||
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.apache.commons.codec.digest.DigestUtils
|
||||
|
||||
public class TreeDiff {
|
||||
|
||||
public static final String VERSION = "1.4.2"
|
||||
public static final String VERSION = "1.4.3"
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper()
|
||||
private PrintStream stdout
|
||||
|
@ -1,36 +1,32 @@
|
||||
import md5
|
||||
import md5, streams
|
||||
import os
|
||||
|
||||
proc fileToMD5*(filename: string) : string =
|
||||
|
||||
const blockSize: int = 8192
|
||||
const blockSize: int = 8192 # read files in 8KB chunnks
|
||||
var
|
||||
c: MD5Context
|
||||
d: MD5Digest
|
||||
f: File
|
||||
bytesRead: int = 0
|
||||
buffer: array[blockSize, char]
|
||||
byteTotal: int = 0
|
||||
fs: FileStream
|
||||
buffer: string
|
||||
|
||||
#read chunk of file, calling update until all bytes have been read
|
||||
try:
|
||||
f = open(filename)
|
||||
fs = filename.open.newFileStream
|
||||
|
||||
md5Init(c)
|
||||
bytesRead = f.readBuffer(buffer.addr, blockSize)
|
||||
buffer = fs.readStr(blockSize)
|
||||
|
||||
while bytesRead > 0:
|
||||
byteTotal += bytesRead
|
||||
md5Update(c, buffer, bytesRead)
|
||||
bytesRead = f.readBuffer(buffer.addr, blockSize)
|
||||
while buffer.len > 0:
|
||||
md5Update(c, buffer, buffer.len)
|
||||
buffer = fs.readStr(blockSize)
|
||||
|
||||
md5Final(c, d)
|
||||
|
||||
except IOError:
|
||||
echo("File not found.")
|
||||
except IOError: echo("File not found.")
|
||||
finally:
|
||||
if f != nil:
|
||||
close(f)
|
||||
if fs != nil:
|
||||
close(fs)
|
||||
|
||||
result = $d
|
||||
|
||||
|
@ -24,12 +24,13 @@ proc newProgressWrapper*(outFile = stdout, verbosity = normal): ProgressWrapper
|
||||
else: result = (impl: nil, verbosity: verbosity)
|
||||
|
||||
proc init(p: ProgressWrapper, root: string, fileCount: int): void =
|
||||
if p.verbosity == normal: echo "-- ", root.expandFilename
|
||||
if p.verbosity == normal:
|
||||
echo "-- ", root.expandFilename, "\L ", fileCount, " files"
|
||||
if p.verbosity > very_quiet: p.impl.setMax(fileCount)
|
||||
|
||||
proc update(p: ProgressWrapper, count: int, file: string): void =
|
||||
if p.verbosity > very_quiet:
|
||||
p.impl.updateProgress(count, file[(file.high - 15)..file.high])
|
||||
p.impl.updateProgress(count, file[max(file.high - 15, 0)..file.high])
|
||||
|
||||
proc finish(p: ProgressWrapper): void =
|
||||
if p.verbosity > very_quiet:
|
||||
@ -231,7 +232,7 @@ Options:
|
||||
|
||||
"""
|
||||
|
||||
let args = docopt(doc, version = "treediff v1.4.2")
|
||||
let args = docopt(doc, version = "treediff v1.4.5")
|
||||
|
||||
var verbosity = normal
|
||||
if args["--quiet"]: verbosity = quiet
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Package
|
||||
version = "1.4.2"
|
||||
version = "1.4.5"
|
||||
author = "Jonathan Bernard (jdb@jdb-labs.com)"
|
||||
description = "Utility to generate diffs of full directory trees."
|
||||
license = "BSD"
|
||||
@ -7,4 +7,4 @@ bin = @["treediff"]
|
||||
srcDir = "src/main/nim"
|
||||
|
||||
# Dependencies
|
||||
requires: @["nim >= 0.13.0", "docopt >= 0.1.0", "console_progress >= 1.2.1"]
|
||||
requires: @["nim >= 1.0.4", "docopt >= 0.6.8", "console_progress >= 1.2.1"]
|
||||
|
Reference in New Issue
Block a user