listDeleted = new ArrayList<>();
+
+
+ Tools tools = new Tools();
+
+ /**
+ * Create a SyncDirectory from realPath.
+ *
+ * @param realPath
+ * @see SyncEntity
+ */
+ public SyncDirectory(String realPath) {
+ this.realPath = realPath;
+ stateFileBasePath = "/tmp/find" + this.realPath.replace("/", "-");
+ stateFileOldPath = stateFileBasePath + "-old";
+ stateFileNewPath = stateFileBasePath + "-new";
+ stateFileOld = getStateFileOld();
+ stateFileNew = getStateFileNew();
+ poolOld = getPoolOld();
+ poolNew = getPoolNew();
+
+ }
+
+ /**
+ * IF NOT EXISTS the StateFileOld for this SyncDirectory,
+ * - THEN create the File on Disk.
+ *
+ * @return the StateFileOld.
+ */
+ public File getStateFileOld() {
+ stateFileOld = new File(stateFileOldPath);
+ if (!stateFileOld.exists()) {
+ stateFileOld = tools.generateStateFile(realPath, stateFileOldPath);
+ }
+ return stateFileOld;
+ }
+
+ /**
+ * READ directory contents.
+ * WRITE a new StateFileNew to Disk. This is IMPORTANT in order to make sure that StateFileOld is NEVER newer than StateFileNew.
+ * WRITE a new StateFileOld to Disk.
+ */
+ public void updateStateFileBoth() {
+ //
+ tools.generateStateFile(realPath, stateFileNewPath);
+ tools.generateStateFile(realPath, stateFileOldPath);
+ }
+
+ public File getStateFileNew() {
+ stateFileNew = new File(stateFileNewPath);
+ if (!stateFileNew.exists()) {
+ stateFileNew = tools.generateStateFile(realPath, stateFileNewPath);
+ }
+ return stateFileNew;
+ }
+
+ /**
+ * READ directory contents.
+ * WRITE a new StateFileNew Disk.
+ */
+ public void updateStateFileNew() {
+ //
+ tools.generateStateFile(realPath, stateFileNewPath);
+ }
+
+
+ public Map getPoolOld() {
+ if (poolOld.isEmpty()) {
+ updatePoolBoth();
+ }
+ return poolOld;
+ }
+
+ /**
+ * UPDATE PoolOld FROM contents of StateFileOld.
+ */
+ public void updatePoolBoth() {
+ poolNew = tools.fileToPool(getStateFileNew(), "all");
+ poolOld = tools.fileToPool(getStateFileOld(), "all");
+
+ }
+
+
+ public Map getPoolNew() {
+ if (poolNew.isEmpty()) {
+ updatePoolNew();
+ }
+ return poolNew;
+ }
+
+ /**
+ * UPDATE PoolNew FROM contents of StateFileNew.
+ */
+ public void updatePoolNew() {
+ poolNew = tools.fileToPool(getStateFileNew(), "all");
+
+ }
+
+ public List getListCreated() {
+
+ listCreated = tools.mapMinus(getPoolNew(), getPoolOld());
+
+ return listCreated;
+ }
+
+ public List getListDeleted() {
+
+ listDeleted = tools.mapMinus(getPoolOld(), getPoolNew());
+
+ return listDeleted;
+ }
+
+}
diff --git a/src/com/olexyn/ensync/artifacts/SyncEntity.java b/src/com/olexyn/ensync/artifacts/SyncEntity.java
new file mode 100644
index 0000000..16f2c6b
--- /dev/null
+++ b/src/com/olexyn/ensync/artifacts/SyncEntity.java
@@ -0,0 +1,86 @@
+package com.olexyn.ensync.artifacts;
+
+
+import com.olexyn.ensync.Tools;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A SyncEntity is a collection of SyncDirectories,
+ * that are supposed to be kept in sync.
+ */
+public class SyncEntity {
+
+ public String name;
+ public int syncInterval = 3600;
+ public Map syncDirectories = new HashMap<>();
+ private Map mapCreated = new HashMap<>();
+ private Map mapDeleted = new HashMap<>();
+ Tools tools = new Tools();
+
+ /**
+ * @see SyncEntity
+ */
+ public SyncEntity(String name) {
+ this.name = name;
+
+ }
+
+ /**
+ * Creates a new Syncdirectory.
+ *
+ * Adds the created SyncDirectory to this SyncEntity.
+ *
+ * @param realPath the path from which the Syncdirectory is created.
+ * @see SyncDirectory
+ */
+ public void addDirectory(String realPath) {
+ if (new File(realPath).isDirectory()) {
+ syncDirectories.put(realPath, new SyncDirectory(realPath));
+ }
+ }
+
+ public Map getMapCreated() {
+ for (Map.Entry entry : syncDirectories.entrySet()) {
+ SyncDirectory syncDirectory = entry.getValue();
+ for (File file : syncDirectory.getListCreated()) {
+ mapCreated.put(file.getPath(), file);
+ }
+
+ }
+
+
+ return mapCreated;
+ }
+
+ public Map getMapDeleted() {
+
+ for (Map.Entry entry : syncDirectories.entrySet()) {
+ SyncDirectory syncDirectory = entry.getValue();
+ for (File file : syncDirectory.getListDeleted()) {
+ mapDeleted.put(file.getPath(), file);
+ }
+
+ }
+
+
+ return mapDeleted;
+ }
+
+ public void addToMapCreated(List listCreated) {
+ for (File file : listCreated) {
+ mapCreated.put(file.getPath(), file);
+ }
+ }
+
+
+ public void addToMapDeleted(List listDeleted) {
+ for (File file : listDeleted) {
+ mapDeleted.put(file.getPath(), file);
+ }
+ }
+
+}
diff --git a/src/com/olexyn/ensync/file-ops-covered-vs-missing.png b/src/com/olexyn/ensync/file-ops-covered-vs-missing.png
new file mode 100644
index 0000000..c6ed079
Binary files /dev/null and b/src/com/olexyn/ensync/file-ops-covered-vs-missing.png differ
diff --git a/src/com/olexyn/ensync/file-ops-covered-vs-missing.uxf b/src/com/olexyn/ensync/file-ops-covered-vs-missing.uxf
new file mode 100644
index 0000000..29b776f
--- /dev/null
+++ b/src/com/olexyn/ensync/file-ops-covered-vs-missing.uxf
@@ -0,0 +1,458 @@
+
+
+ 10
+
+ UMLObject
+
+ 290
+ 420
+ 110
+ 40
+
+ Directory B
+
+
+
+ UMLObject
+
+ 290
+ 380
+ 110
+ 40
+
+ Directory A
+
+
+
+ UMLObject
+
+ 290
+ 230
+ 110
+ 40
+
+ Delete
+bg=red
+group=1
+
+
+
+ UMLObject
+
+ 290
+ 270
+ 110
+ 40
+
+ Create
+bg=green
+group=1
+
+
+
+ UMLObject
+
+ 290
+ 310
+ 110
+ 40
+
+ Modify
+bg=yellow
+group=1
+
+
+
+ UMLState
+
+ 440
+ 530
+ 70
+ 40
+
+ YES
+bg=green
+
+
+
+ UMLState
+
+ 440
+ 420
+ 70
+ 40
+
+ File
+
+
+
+ UMLState
+
+ 530
+ 420
+ 70
+ 40
+
+ File
+bg=red
+
+
+
+ UMLState
+
+ 890
+ 530
+ 70
+ 40
+
+ NO
+bg=red
+
+
+
+ UMLObject
+
+ 290
+ 190
+ 110
+ 40
+
+ Unchanged
+bg=white
+group=1
+
+
+
+ UMLState
+
+ 440
+ 380
+ 70
+ 40
+
+ File
+
+
+
+ UMLState
+
+ 530
+ 380
+ 70
+ 40
+
+ File
+
+
+
+ UMLState
+
+ 620
+ 420
+ 70
+ 40
+
+ File
+bg=red
+
+
+
+ UMLState
+
+ 620
+ 380
+ 70
+ 40
+
+ File
+bg=red
+
+
+
+ UMLState
+
+ 710
+ 420
+ 70
+ 40
+
+ File
+bg=green
+
+
+
+ UMLState
+
+ 710
+ 380
+ 70
+ 40
+
+ File
+
+
+
+ UMLState
+
+ 800
+ 420
+ 70
+ 40
+
+ File
+bg=green
+
+
+
+ UMLState
+
+ 800
+ 380
+ 70
+ 40
+
+ File
+bg=green
+
+
+
+ UMLState
+
+ 890
+ 420
+ 70
+ 40
+
+ File
+bg=yellow
+
+
+
+ UMLState
+
+ 890
+ 380
+ 70
+ 40
+
+ File
+
+
+
+ UMLState
+
+ 980
+ 420
+ 70
+ 40
+
+ File
+bg=yellow
+
+
+
+ UMLState
+
+ 980
+ 380
+ 70
+ 40
+
+ File
+bg=yellow
+
+
+
+ UMLState
+
+ 1070
+ 380
+ 70
+ 40
+
+ File
+bg=red
+
+
+
+ UMLState
+
+ 1070
+ 420
+ 70
+ 40
+
+ File
+bg=green
+
+
+
+ UMLState
+
+ 1160
+ 380
+ 70
+ 40
+
+ File
+bg=red
+
+
+
+ UMLState
+
+ 1160
+ 420
+ 70
+ 40
+
+ File
+bg=yellow
+
+
+
+ UMLState
+
+ 1250
+ 380
+ 70
+ 40
+
+ File
+bg=green
+
+
+
+ UMLState
+
+ 1250
+ 420
+ 70
+ 40
+
+ File
+bg=yellow
+
+
+
+ UMLNote
+
+ 420
+ 190
+ 150
+ 80
+
+ 2^4 = 16
+however only 10
+because 6 are symmetrical.
+bg=white
+
+
+
+ UMLObject
+
+ 290
+ 530
+ 110
+ 40
+
+ Covered?
+
+
+
+ UMLState
+
+ 620
+ 530
+ 70
+ 40
+
+ MAYBE
+bg=yellow
+
+
+
+ UMLState
+
+ 530
+ 530
+ 70
+ 40
+
+ YES
+bg=green
+
+
+
+ UMLState
+
+ 710
+ 530
+ 70
+ 40
+
+ YES
+bg=green
+
+
+
+ UMLState
+
+ 980
+ 530
+ 70
+ 40
+
+ NO
+bg=red
+
+
+
+ UMLState
+
+ 1160
+ 530
+ 70
+ 40
+
+ NO
+bg=red
+
+
+
+ UMLState
+
+ 1250
+ 530
+ 70
+ 40
+
+ NO
+bg=red
+
+
+
+ UMLState
+
+ 800
+ 530
+ 70
+ 40
+
+ NO
+bg=red
+
+
+
+ UMLState
+
+ 1070
+ 530
+ 70
+ 40
+
+ NO
+bg=red
+
+
+
diff --git a/src/com/olexyn/ensync/handle-deletes.png b/src/com/olexyn/ensync/handle-deletes.png
new file mode 100644
index 0000000..4bc2151
Binary files /dev/null and b/src/com/olexyn/ensync/handle-deletes.png differ
diff --git a/src/com/olexyn/ensync/handle-deletes.uxf b/src/com/olexyn/ensync/handle-deletes.uxf
new file mode 100644
index 0000000..1382bbd
--- /dev/null
+++ b/src/com/olexyn/ensync/handle-deletes.uxf
@@ -0,0 +1,588 @@
+
+
+ 10
+
+ UMLClass
+
+ 250
+ 120
+ 140
+ 40
+
+ File System
+halign=left
+
+
+
+ Relation
+
+ 310
+ 150
+ 160
+ 280
+
+ lt=<-
+ 140.0;260.0;10.0;10.0
+
+
+ UMLClass
+
+ 100
+ 580
+ 120
+ 60
+
+ Collection of
+Accepted
+State Files
+halign=left
+
+
+
+ UMLState
+
+ 370
+ 410
+ 170
+ 40
+
+ User initiates a
+File System update.
+halign=left
+
+
+
+ Relation
+
+ 210
+ 590
+ 180
+ 30
+
+ lt=.
+ 10.0;10.0;160.0;10.0
+
+
+ UMLState
+
+ 370
+ 570
+ 150
+ 60
+
+ Check if a newer
+State File
+is available
+halign=left
+
+
+
+ UMLState
+
+ 80
+ 240
+ 170
+ 40
+
+ Update State File
+from File System
+halign=left
+
+
+
+ UMLClass
+
+ 100
+ 500
+ 130
+ 40
+
+ Last Accepted
+State File
+bg=green
+halign=left
+
+
+
+ UMLClass
+
+ 100
+ 320
+ 130
+ 40
+
+ Current
+State File
+bg=yellow
+halign=left
+
+
+
+ UMLState
+
+ 80
+ 410
+ 160
+ 40
+
+ Accept State File
+
+
+
+ Relation
+
+ 430
+ 440
+ 40
+ 150
+
+ lt=<-
+ 10.0;130.0;20.0;10.0
+
+
+ Relation
+
+ 150
+ 350
+ 30
+ 80
+
+ lt=<-
+ 10.0;60.0;10.0;10.0
+
+
+ Relation
+
+ 310
+ 620
+ 150
+ 120
+
+ lt=<-
+[YES]
+ 10.0;100.0;130.0;10.0
+
+
+ UMLState
+
+ 240
+ 720
+ 170
+ 60
+
+ Update File System
+according to newest
+State File
+
+
+
+ Relation
+
+ 150
+ 440
+ 30
+ 80
+
+ lt=<-
+ 10.0;60.0;10.0;10.0
+
+
+ Relation
+
+ 150
+ 150
+ 190
+ 110
+
+ lt=<-
+ 10.0;90.0;170.0;10.0
+
+
+ Relation
+
+ 150
+ 270
+ 30
+ 70
+
+ lt=<-
+ 10.0;50.0;10.0;10.0
+
+
+ Relation
+
+ 150
+ 530
+ 30
+ 70
+
+ lt=.
+ 10.0;10.0;10.0;50.0
+
+
+ UMLClass
+
+ 860
+ 0
+ 340
+ 50
+
+ SyncEntity
+--
+Map<SyncDirectory> directories
+halign=left
+
+
+
+ UMLClass
+
+ 1300
+ 90
+ 230
+ 200
+
+ SyncDirectory
+
+--
+String realPath
+String stateFileBasePath
+File stateFileOld
+File stateFileNew
+Map<String,File> poolOld
+Map<String,File> poolNew
+List<String> listCreated
+List<String> listDeleted
+halign=left
+
+
+
+ Relation
+
+ 1190
+ 30
+ 130
+ 90
+
+ lt=<-
+ 110.0;70.0;10.0;10.0
+
+
+ UMLClass
+
+ 1620
+ 740
+ 130
+ 60
+
+ StateFileOld
+bg=yellow
+halign=left
+
+
+
+ UMLClass
+
+ 1750
+ 740
+ 130
+ 30
+
+ StateFileNew
+bg=green
+halign=left
+
+
+
+ UMLClass
+
+ 1750
+ 770
+ 130
+ 30
+
+ ListDeleted
+halign=left
+
+
+
+ UMLClass
+
+ 1620
+ 820
+ 130
+ 30
+
+ StateFileOld
+bg=yellow
+halign=left
+
+
+
+ UMLClass
+
+ 1750
+ 820
+ 130
+ 60
+
+ StateFileNew
+bg=green
+halign=left
+
+
+
+ UMLClass
+
+ 1620
+ 850
+ 130
+ 30
+
+ ListCreated
+halign=left
+
+
+
+ UMLState
+
+ 1220
+ 650
+ 170
+ 60
+
+ update
+StateFileNew
+
+
+
+ UMLState
+
+ 1190
+ 770
+ 120
+ 40
+
+ get
+ListCreated
+
+
+
+ UMLState
+
+ 1310
+ 770
+ 120
+ 40
+
+ get
+ListDeleted
+
+
+
+ Relation
+
+ 1230
+ 700
+ 90
+ 90
+
+ lt=<-
+ 10.0;70.0;70.0;10.0
+
+
+ Relation
+
+ 1310
+ 700
+ 80
+ 90
+
+ lt=<-
+ 60.0;70.0;10.0;10.0
+
+
+ UMLState
+
+ 1190
+ 850
+ 120
+ 40
+
+ add to
+MapCreated
+
+
+
+ UMLState
+
+ 1310
+ 850
+ 120
+ 40
+
+ add to
+MapDeleted
+
+
+
+ Relation
+
+ 1360
+ 800
+ 30
+ 70
+
+ lt=<-
+ 10.0;50.0;10.0;10.0
+
+
+ Relation
+
+ 1240
+ 800
+ 30
+ 70
+
+ lt=<-
+ 10.0;50.0;10.0;10.0
+
+
+ UMLState
+
+ 1230
+ 970
+ 170
+ 60
+
+ Perform
+File Operations
+for Sycronization
+
+
+
+ Relation
+
+ 1310
+ 880
+ 80
+ 110
+
+ lt=<-
+ 10.0;90.0;60.0;10.0
+
+
+ Relation
+
+ 1240
+ 880
+ 100
+ 110
+
+ lt=<-
+ 80.0;90.0;10.0;10.0
+
+
+ UMLClass
+
+ 1020
+ 610
+ 440
+ 320
+
+ For Each SyncDirectory
+halign=left
+layer=-1
+
+
+
+ UMLClass
+
+ 1600
+ 720
+ 300
+ 180
+
+
+halign=left
+layer=-1
+
+
+
+ Relation
+
+ 1420
+ 780
+ 200
+ 50
+
+ lt=.
+ 180.0;30.0;10.0;10.0
+
+
+ Relation
+
+ 1280
+ 580
+ 40
+ 90
+
+ lt=<-
+ 10.0;70.0;20.0;10.0
+
+
+ UMLSpecialState
+
+ 1290
+ 570
+ 20
+ 20
+
+ type=initial
+
+
+
+ UMLSpecialState
+
+ 1300
+ 1200
+ 20
+ 20
+
+ type=final
+
+
+
+ Relation
+
+ 1300
+ 1020
+ 30
+ 80
+
+ lt=<-
+ 10.0;60.0;10.0;10.0
+
+
+ Relation
+
+ 1290
+ 1130
+ 40
+ 90
+
+ lt=<-
+ 20.0;70.0;10.0;10.0
+
+
+ UMLState
+
+ 1220
+ 1080
+ 170
+ 60
+
+ update
+StateFileBoth
+
+
+
diff --git a/src/com/olexyn/ensync/shell/pipe.sh b/src/com/olexyn/ensync/shell/pipe.sh
new file mode 100755
index 0000000..dc6f96c
--- /dev/null
+++ b/src/com/olexyn/ensync/shell/pipe.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+a=$1
+b=$2
+$a | $b
+
+# this is a pipe
\ No newline at end of file
diff --git a/src/com/olexyn/ensync/shell/pipe2.sh b/src/com/olexyn/ensync/shell/pipe2.sh
new file mode 100755
index 0000000..826e21f
--- /dev/null
+++ b/src/com/olexyn/ensync/shell/pipe2.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+a=$1
+b=$2
+c=$3
+$a | $b | $c
+
+# this is a double pipe
\ No newline at end of file
diff --git a/src/com/olexyn/ensync/shell/toFile.sh b/src/com/olexyn/ensync/shell/toFile.sh
new file mode 100755
index 0000000..8585b3d
--- /dev/null
+++ b/src/com/olexyn/ensync/shell/toFile.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+a=$1
+b=$2
+c=$3
+
+$a $b > $c
\ No newline at end of file
diff --git a/src/com/olexyn/ensync/sync.conf b/src/com/olexyn/ensync/sync.conf
deleted file mode 100644
index b2aca4c..0000000
--- a/src/com/olexyn/ensync/sync.conf
+++ /dev/null
@@ -1,13 +0,0 @@
-# -u update
-# -r recursive
-# -v verbose
-# -t keep modification times
-# -W whole file (faster if network bandwith is faster then disk bandwith)
-#
-# examples:
-# ./dirA -- urvtW -> ./dirB
-# ./dirA <- urvtW ---- urvtW -> ./dirB
-/home/user/ws/idea/env-sync/src/com/olexyn/ensync/tmp/in/ <- urvtW ---- urvtW -> /home/user/ws/idea/env-sync/src/com/olexyn/ensync/tmp/out/
-# backup
-# /home/user/ws/ -- urvtW -> /media/time/backup/auto/ws
-/home/user/wiki/ -- urvtW -> /media/time/backup/auto/wiki
\ No newline at end of file