correctDir function
Helper method to correct a directory
Implementation
Directory correctDir(Directory directory) {
if (directory.path.endsWith('\\.') || directory.path.endsWith('/.')) {
directory =
Directory(directory.path.substring(0, directory.path.length - 2));
} else if (directory.path.endsWith('\\') || directory.path.endsWith('/')) {
directory =
Directory(directory.path.substring(0, directory.path.length - 1));
}
return directory;
}