mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Rename.
This commit is contained in:
parent
3da2b70558
commit
a5fbae6c65
1 changed files with 4 additions and 4 deletions
|
@ -19,17 +19,17 @@ public class Md5 {
|
|||
// }
|
||||
|
||||
/**
|
||||
* Calculate a checksum for all the files under the passed directories. The conversion from File to
|
||||
* Calculate a checksum for all the files/directories. The conversion from File to
|
||||
* bytes can be customized by the @param{toBytes} parameter. The default implementation calculates
|
||||
* a checksum of the last modified timestamp.
|
||||
*/
|
||||
fun toMd5Directories(directories: List<File>,
|
||||
fun toMd5Directories(filesOrDirectories: List<File>,
|
||||
toBytes: (File) -> ByteArray = { it.lastModified().toString().toByteArray() } ): String? {
|
||||
val ds = directories.filter { it.exists() }
|
||||
val ds = filesOrDirectories.filter { it.exists() }
|
||||
if (ds.size > 0) {
|
||||
MessageDigest.getInstance("MD5").let { md5 ->
|
||||
var fileCount = 0
|
||||
directories.filter { it.exists() }.forEach { file ->
|
||||
filesOrDirectories.filter { it.exists() }.forEach { file ->
|
||||
if (file.isFile) {
|
||||
val bytes = file.readBytes()
|
||||
md5.update(bytes, 0, bytes.size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue