summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2020-11-30 13:15:15 +0800
committerkeuin <[email protected]>2020-11-30 13:15:15 +0800
commit61ade9adad4668494dfc32da7751e1b86251dc97 (patch)
treec220fe41d0691d7ad6ed08e51d351537fa220a4f /src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java
parente59bdf4ac0b66ce683be1bbc36852bfce6f70a63 (diff)
Implementing incremental backup
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java b/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java
new file mode 100644
index 0000000..7f74725
--- /dev/null
+++ b/src/main/java/com/keuin/kbackupfabric/util/FilesystemUtil.java
@@ -0,0 +1,33 @@
+package com.keuin.kbackupfabric.util;
+
+import java.io.File;
+
+public class FilesystemUtil {
+
+ /**
+ * Get file sizes in bytes.
+ * @param parentDirectory path to specific file.
+ * @param fileName file name.
+ * @return bytes. If failed, return -1.
+ */
+ public static long getFileSizeBytes(String parentDirectory, String fileName) {
+ long fileSize = -1;
+ try{
+ File backupZipFile = new File(parentDirectory, fileName);
+ fileSize = backupZipFile.length();
+ } catch (SecurityException ignored){
+ }
+ return fileSize;
+ }
+
+ public static long getFileSizeBytes(String filePath) {
+ long fileSize = -1;
+ try{
+ File backupZipFile = new File(filePath);
+ fileSize = backupZipFile.length();
+ } catch (SecurityException ignored){
+ }
+ return fileSize;
+ }
+
+}