use of org.fagu.fmv.utils.IniFile in project fmv by f-agu.
the class Bootstrap method recurse.
/**
* @param rootPath
* @param currentFile
* @param currentDepth
* @param maxDepth
*/
private void recurse(Path rootPath, File currentFile, int currentDepth, int maxDepth) {
if (currentFile.isFile()) {
doFile(rootPath, currentFile);
return;
}
System.out.println(currentFile);
IniFile iniFile = loadIniFile(currentFile);
File[] files = currentFile.listFiles(createFileFilter(iniFile));
if (files != null) {
Arrays.sort(files);
for (File f : files) {
recurse(rootPath, f, currentDepth + 1, maxDepth);
}
}
}
use of org.fagu.fmv.utils.IniFile in project fmv by f-agu.
the class Sync method sync.
// --------------------------------------------
/**
* @param srcItem
* @param destItemsList
* @throws IOException
*/
private void sync(Item srcItem, List<Item> destItemsList) throws IOException {
System.out.println(srcItem.toString());
synchronizer.doNothingOnFolder(srcItem);
Map<String, Item> listChildren = srcItem.listChildren();
List<Dest> dests = new ArrayList<>();
for (Item destItem : destItemsList) {
Map<String, Item> map = destItem.listChildren();
dests.add(new Dest(destItem, map, loadInitFile(map)));
}
IniFile srcInitFile = loadInitFile(listChildren);
for (Entry<String, Item> entry : listChildren.entrySet()) {
String name = entry.getKey();
Item curSrcItem = entry.getValue();
List<Item> curDestItems = new ArrayList<>();
for (Dest dest : dests) {
Item destItem = dest.item;
Map<String, Item> destItems = dest.childMap;
IniFile destInitFile = dest.iniFile;
Item curDestItem = destItems.remove(name);
if (curDestItem != null) {
curDestItems.add(curDestItem);
}
if (!accept(curSrcItem, srcInitFile)) {
synchronizer.ignore(curSrcItem.toString());
continue;
}
if (curDestItem != null && !accept(curDestItem, destInitFile)) {
synchronizer.ignore(curDestItem.toString());
continue;
}
if (curDestItem == null) {
if (curSrcItem.isDirectory()) {
Item ditem = synchronizer.mkdir(destItem, curSrcItem.getName());
if (ditem != null) {
sync(curSrcItem, Collections.singletonList(ditem));
}
} else if (curSrcItem.isFile()) {
curDestItem = synchronizer.createFile(destItem, curSrcItem.getName());
if (curDestItem != null) {
final Item finalCurDestItem = curDestItem;
progressBar(progress -> synchronizer.copyForNew(curSrcItem, finalCurDestItem, progress), curSrcItem);
}
} else {
synchronizer.unknown(srcItem.toString());
}
} else if (curDestItem.isFile() != curSrcItem.isFile() || curDestItem.isDirectory() != curSrcItem.isDirectory()) {
synchronizer.conflict(curDestItem.toString());
// conflict type
} else if (curDestItem.isDirectory()) {
// sync(curSrcItem, Collections.singletonList(curDestItem));
} else if (curDestItem.size() != curSrcItem.size()) {
// to update
final Item finalCurDestItem = curDestItem;
progressBar(progress -> synchronizer.copyForUpdate(curSrcItem, finalCurDestItem, progress), curSrcItem);
}
if (curSrcItem.isFile()) {
synchronizer.doNothingOnFile(curDestItem);
}
}
if (curSrcItem.isDirectory()) {
sync(curSrcItem, curDestItems);
}
}
for (Dest dest : dests) {
for (Entry<String, Item> entry : dest.childMap.entrySet()) {
Item value = entry.getValue();
// to delete ?
if (!accept(value, dest.iniFile)) {
synchronizer.ignore(value.toString());
continue;
}
synchronizer.delete(value);
}
}
}
Aggregations