mirror of
https://github.com/farfalleflickan/cmyflix.git
synced 2024-11-24 09:45:30 +00:00
Minor improvements
Better error message on configuration error, cleaned up generated config, new "copy extras" code
This commit is contained in:
parent
908f67946c
commit
e88d8972e2
@ -216,7 +216,7 @@ progConfig *getConfig(char *srcPath) {
|
||||
mallocMacro(options->TMDBapi, tempPtrSize, "getConfig error");
|
||||
strlcpy(options->TMDBapi, confValue, tempPtrSize);
|
||||
} else {
|
||||
fatalError_exit("getConfig error", "configuration file \"%s\" contains errors!\n%sUse \"cmyflix --gen-config > %s\" to generate default.\n", srcPath, HBLU, srcPath);
|
||||
fatalError_exit("getConfig error", "configuration file \"%s\" contains errors!\nInvalid: \"%s\";\n%sUse \"cmyflix --gen-config > %s\" to generate default.\n", srcPath, confKey, HBLU, srcPath);
|
||||
}
|
||||
if (i<properties) {
|
||||
pos+=offset[i]+offset[i+1];
|
||||
|
45
src/main.c
45
src/main.c
@ -206,27 +206,33 @@ void copyExtras(progConfig *conf, progFlags runFlags, char *htmlFolder, char *de
|
||||
tempStr=dirname(conf->TVhtml);
|
||||
}
|
||||
if (tempStr!=NULL) {
|
||||
char *cmdStr=NULL;
|
||||
size_t tempStrSize=strlen("cp -r /* ")+strlen(extPath)+strlen(tempStr)+1;
|
||||
mallocMacro(cmdStr, tempStrSize, "cmyflix error");
|
||||
snprintf(cmdStr, tempStrSize, "cp -r %s/* %s", extPath, tempStr);
|
||||
resetSTDColors();
|
||||
FILE *cmdRet=popen(cmdStr, "r");
|
||||
if (cmdRet==NULL) {
|
||||
if (pclose(cmdRet)!=0) {
|
||||
printError("cmyflix", false, HRED, "%s\n", strerror(errno));
|
||||
}
|
||||
tryFree(cmdStr);
|
||||
fatalError_exit("cmyflix error", "something went wrong while trying to copy HTML resources from '%s' to '%s';\n", extPath, tempStr);
|
||||
} else {
|
||||
if (pclose(cmdRet)!=0) {
|
||||
printError("cmyflix", false, HRED, "something went wrong while trying to copy HTML resources from '%s' to '%s';\n", extPath, tempStr);
|
||||
printError("cmyflix", false, HRED, "%s\n", strerror(errno));
|
||||
char *tempStr2=appendSlash(tempStr);
|
||||
if (checkFolder(tempStr2, true)==0) {
|
||||
char *cmdStr=NULL;
|
||||
size_t tempStrSize=strlen("cp -r /* ")+strlen(extPath)+strlen(tempStr2)+1;
|
||||
mallocMacro(cmdStr, tempStrSize, "cmyflix error");
|
||||
snprintf(cmdStr, tempStrSize, "cp -r %s/* %s", extPath, tempStr2);
|
||||
resetSTDColors();
|
||||
FILE *cmdRet=popen(cmdStr, "r");
|
||||
if (cmdRet==NULL) {
|
||||
if (pclose(cmdRet)!=0) {
|
||||
printError("cmyflix", false, HRED, "%s\n", strerror(errno));
|
||||
}
|
||||
tryFree(cmdStr);
|
||||
fatalError_exit("cmyflix error", "something went wrong while trying to copy HTML resources from '%s' to '%s';\n", extPath, tempStr2);
|
||||
} else {
|
||||
printInfo("", false, "Copied HTML resources from '%s' to '%s';\n", extPath, tempStr);
|
||||
if (pclose(cmdRet)!=0) {
|
||||
printError("cmyflix", false, HRED, "something went wrong while trying to copy HTML resources from '%s' to '%s';\n", extPath, tempStr2);
|
||||
printError("cmyflix", false, HRED, "%s\n", strerror(errno));
|
||||
} else {
|
||||
printInfo("", false, "Copied HTML resources from '%s' to '%s';\n", extPath, tempStr2);
|
||||
}
|
||||
}
|
||||
}
|
||||
tryFree(cmdStr);
|
||||
tryFree(cmdStr);
|
||||
}
|
||||
if (tempStr2!=tempStr) {
|
||||
tryFree(tempStr2);
|
||||
}
|
||||
} else {
|
||||
printError("cmyflix error", false, HRED, "could not get path to copy HTML resources to.\n");
|
||||
}
|
||||
@ -403,7 +409,6 @@ int main(int argc, char * argv[]) {
|
||||
printVersion();
|
||||
exit(EXIT_SUCCESS);
|
||||
} else if (currOption=='9') { // --gen-config
|
||||
resetSTDColors();
|
||||
printf("%s\n", DEF_CONF);
|
||||
exit(EXIT_SUCCESS);
|
||||
} else if (currOption=='c') { // --clean
|
||||
|
14
src/utils.c
14
src/utils.c
@ -983,3 +983,17 @@ long double getElapsedTime() {
|
||||
gettimeofday(¤tTime, NULL);
|
||||
return (currentTime.tv_sec - timeProgStart.tv_sec)+((long double)(currentTime.tv_usec - timeProgStart.tv_usec)/1000000);
|
||||
}
|
||||
|
||||
// checks if last character in string is '/' and appends it if needed
|
||||
char *appendSlash(char *origStr) {
|
||||
char *newStr=NULL;
|
||||
size_t origLen=strlen(origStr);
|
||||
if (origStr[origLen]=='/') {
|
||||
newStr=origStr;
|
||||
} else {
|
||||
origLen+=2;
|
||||
mallocMacro(newStr, origLen, "cmyflix error");
|
||||
snprintf(newStr, origLen, "%s/", origStr);
|
||||
}
|
||||
return newStr;
|
||||
}
|
||||
|
@ -140,3 +140,4 @@ void printBitFlags(unsigned bits);
|
||||
int fixMode(progConfig *conf, progFlags flags, const char *toFix, const char *id, const char *poster, const char *newName, bool refreshMode);
|
||||
int writeCharToFile(const char *str, const char *fileStr);
|
||||
long double getElapsedTime();
|
||||
char *appendSlash(char *origStr);
|
||||
|
Loading…
Reference in New Issue
Block a user