in func writeToFile: change write to fc_safe_write
parent
a57b87b556
commit
74bcd17360
2
HISTORY
2
HISTORY
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
Version 1.44 2020-02-24
|
Version 1.44 2020-02-25
|
||||||
* add test file src/tests/test_pthread_lock.c
|
* add test file src/tests/test_pthread_lock.c
|
||||||
* add uniq_skiplist.[hc]
|
* add uniq_skiplist.[hc]
|
||||||
* add function split_string_ex
|
* add function split_string_ex
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
@ -1079,16 +1080,12 @@ bool isFile(const char *filename)
|
||||||
void chopPath(char *filePath)
|
void chopPath(char *filePath)
|
||||||
{
|
{
|
||||||
int lastIndex;
|
int lastIndex;
|
||||||
if (*filePath == '\0')
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastIndex = strlen(filePath) - 1;
|
lastIndex = strlen(filePath) - 1;
|
||||||
if (filePath[lastIndex] == '/')
|
while (lastIndex >= 0 && filePath[lastIndex] == '/')
|
||||||
{
|
{
|
||||||
filePath[lastIndex] = '\0';
|
filePath[lastIndex--] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getFileContent(const char *filename, char **buff, int64_t *file_size)
|
int getFileContent(const char *filename, char **buff, int64_t *file_size)
|
||||||
|
|
@ -1260,7 +1257,7 @@ int writeToFile(const char *filename, const char *buff, const int file_size)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write(fd, buff, file_size) != file_size)
|
if (fc_safe_write(fd, buff, file_size) != file_size)
|
||||||
{
|
{
|
||||||
result = errno != 0 ? errno : EIO;
|
result = errno != 0 ? errno : EIO;
|
||||||
logError("file: "__FILE__", line: %d, " \
|
logError("file: "__FILE__", line: %d, " \
|
||||||
|
|
@ -1291,7 +1288,7 @@ int writeToFile(const char *filename, const char *buff, const int file_size)
|
||||||
int safeWriteToFile(const char *filename, const char *buff, \
|
int safeWriteToFile(const char *filename, const char *buff, \
|
||||||
const int file_size)
|
const int file_size)
|
||||||
{
|
{
|
||||||
char tmpFilename[MAX_PATH_SIZE];
|
char tmpFilename[PATH_MAX];
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
snprintf(tmpFilename, sizeof(tmpFilename), "%s.tmp", filename);
|
snprintf(tmpFilename, sizeof(tmpFilename), "%s.tmp", filename);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue