mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
redundant of getting abs path starting with '/'
This commit is contained in:
parent
f0448b3cec
commit
0309eba3c6
@ -645,42 +645,39 @@ int deleteFile(char *mess, char *fname, char *errorPrefix) {
|
|||||||
char fullname[fileNameSize];
|
char fullname[fileNameSize];
|
||||||
strcpy(fullname, fname);
|
strcpy(fullname, fname);
|
||||||
|
|
||||||
if (fname[0] != '/') {
|
if (getAbsPath(fullname, fileNameSize, fname) == FAIL) {
|
||||||
if (getAbsPath(fullname, fileNameSize, fname) == FAIL) {
|
sprintf(mess,
|
||||||
sprintf(mess,
|
"Could not %s. Could not get abs path of current "
|
||||||
"Could not %s. Could not get abs path of current "
|
"process\n",
|
||||||
"process\n",
|
errorPrefix);
|
||||||
errorPrefix);
|
LOG(logERROR, (mess));
|
||||||
LOG(logERROR, (mess));
|
return FAIL;
|
||||||
return FAIL;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (access(fullname, F_OK) == 0) {
|
||||||
|
char cmd[MAX_STR_LENGTH] = {0};
|
||||||
|
char retvals[MAX_STR_LENGTH] = {0};
|
||||||
|
|
||||||
|
if (snprintf(cmd, MAX_STR_LENGTH, "rm %s", fullname) >= MAX_STR_LENGTH) {
|
||||||
|
sprintf(mess, "Could not %s. Command to delete is too long\n",
|
||||||
|
errorPrefix);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (access(fullname, F_OK) == 0) {
|
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
||||||
char cmd[MAX_STR_LENGTH] = {0};
|
snprintf(mess, MAX_STR_LENGTH, "Could not %s. (deleting file %s). %s\n",
|
||||||
char retvals[MAX_STR_LENGTH] = {0};
|
errorPrefix, fullname, retvals);
|
||||||
|
LOG(logERROR, (mess));
|
||||||
if (snprintf(cmd, MAX_STR_LENGTH, "rm %s", fullname) >=
|
return FAIL;
|
||||||
MAX_STR_LENGTH) {
|
|
||||||
sprintf(mess, "Could not %s. Command to delete is too long\n",
|
|
||||||
errorPrefix);
|
|
||||||
LOG(logERROR, (mess));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) {
|
|
||||||
snprintf(mess, MAX_STR_LENGTH,
|
|
||||||
"Could not %s. (deleting file %s). %s\n", errorPrefix,
|
|
||||||
fullname, retvals);
|
|
||||||
LOG(logERROR, (mess));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
LOG(logINFO, ("\tDeleted file: %s (%s)\n", fullname, errorPrefix));
|
|
||||||
} else {
|
|
||||||
LOG(logINFO,
|
|
||||||
("\tFile does not exist anyway: %s (%s)\n", fullname, errorPrefix));
|
|
||||||
}
|
}
|
||||||
return OK;
|
LOG(logINFO, ("\tDeleted file: %s (%s)\n", fullname, errorPrefix));
|
||||||
|
} else {
|
||||||
|
LOG(logINFO,
|
||||||
|
("\tFile does not exist anyway: %s (%s)\n", fullname, errorPrefix));
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
|
int deleteOldServers(char *mess, char *newServerPath, char *errorPrefix) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user