Minor fixes

parent b360a285
......@@ -32,7 +32,7 @@ alias vpath = getVitisPath;
* Main function of the module
*/
void mainFn(string[] args) {
string err = "Wrong using of command 'assign'."._s;
auto err = "Wrong using of command 'assign'."._s;
if (2 == args.length && args[1].among("--help", "-h")) {
moduleHelp.mainFn("assign");
return;
......@@ -62,7 +62,7 @@ void mainFn(string[] args) {
return;
}
bool confOptionSave = (VitisConf.getAutosave == "yes") ? true : false;
const bool confOptionSave = (VitisConf.getAutosave == "yes");
string destFileSpace;
bool cliOptionSave = false;
getopt(args, config.passThrough, "save", &cliOptionSave,
......@@ -75,9 +75,9 @@ void mainFn(string[] args) {
//vitis assign [[-c] <category>] -f <file list>
string[] files = args.extractOptionRange("-f");
if (!files.empty && newName.empty) {
bool autocategorization = VitisConf.getAutocategorization != "none";
bool positiveCondition1 = categories.empty && autocategorization;
bool positiveCondition2 = !categories.empty;
const autocategorization = VitisConf.getAutocategorization != "none";
const positiveCondition1 = categories.empty && autocategorization;
const positiveCondition2 = !categories.empty;
checkCondition!err(positiveCondition1 || positiveCondition2);
foreach(f; files) {
if (f.exists) checkCondition!err(!f.isDir);
......@@ -133,7 +133,7 @@ void mainFn(string[] args) {
string vitisFile = args.extractOptionValue("-v");
if (!vitisFile.empty)
checkCondition!err(!directoryOfFilePath(vitisFile).empty);
auto strNumber = args.extractOptionValue("--number");
const strNumber = args.extractOptionValue("--number");
size_t number;
try {
number = strNumber.empty ? 0 : strNumber.to!size_t;
......@@ -185,8 +185,6 @@ void mainFn(string[] args) {
checkCondition!err(!newName.canFind('/'));
if (!vitisFile.empty) {
string category = directoryOfFilePath(vitisFile);
string linkName = fileNameFromFilePath(vitisFile);
checkCondition!err(args.length == 1);
assignNewNameToFileFromVitis(vitisFile, newName, number);
return;
......@@ -267,13 +265,14 @@ void assignAliases(string category,
}
}
/**
*/
void combineCategories(string mainCategory, string oldCategory) {
string pathToOldCategory = getCatDirPath(oldCategory);
string[] catDirList = amalthea.fs.getDirListRecurse(pathToOldCategory);
catDirList = pathToOldCategory ~ catDirList;
foreach(d; catDirList) {
string currSubcategory = d[pathToOldCategory.length .. $];
const currSubcategory = d[pathToOldCategory.length .. $];
string oldSubcategory = oldCategory ~ "/" ~ currSubcategory;
string newSubcategory = mainCategory ~ "/" ~ currSubcategory;
createNonExistentCategory(newSubcategory, true, false);
......@@ -662,7 +661,7 @@ private void createNewSymlinks(string[] categories,
}
//checking unnecessary links is not for autocategories
if (i > categories.length-1 || categories.empty) continue;
if (i+1 > categories.length || categories.empty) continue;
import module_service : checkUnnecessaryLinks;
auto category = categories[i];
......@@ -686,6 +685,9 @@ private string[] getCategoriesPaths(string[] categories) {
return categoriesPaths;
}
/**
*/
bool desktopFileIsLink(string filepath) {
bool result;
try {
......@@ -817,8 +819,8 @@ private string addFileInFileSpace(string f,
} else {
cp(f, newLocation);
}
} else if (f.isFile && !newLocation.isFile
|| f.isDir && !newLocation.isDir) {
} else if ((f.isFile && !newLocation.isFile)
|| (f.isDir && !newLocation.isDir)) {
"warning".tprintln(
newLocation, ": ",
s_("Something is preventing the file from being added" ~
......@@ -857,7 +859,7 @@ private string writeDuplicate(string file,
if (newFileName.empty) {
newFileName = baseName(file);
}
string repeatedBaseDir = dir.stripRight('/') ~ "/__repeated_names/";
const repeatedBaseDir = dir.stripRight('/') ~ "/__repeated_names/";
string fileLocation;
for(size_t i = 2; ; i++) {
string repDir = repeatedBaseDir ~ i.to!string ~ "/";
......@@ -912,8 +914,7 @@ private bool createNonExistentCategory(string category,
);
return false;
}
string categoryPath = getCatDirPath(category);
if (categoryPath != "") {
if (getCatDirPath(category) != "") {
return true;
}
if (userConfirmation) {
......@@ -950,7 +951,7 @@ private string[] createNonExistentCategories(string[] categories,
private string saveLinkEntry(string url) {
bool HTML = amalthea.net.urlIsHTML(url);
const bool HTML = amalthea.net.isLinkToHTML(url);
string linkEntriesDir = HTML ? getHTMLLinkEntriesPath()
: getNonHTMLLinkEntriesPath();
string tempEntryPath; // path to desktop-file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment