refine getFileContent log info

pull/12/head
yuqing 2016-12-22 15:09:39 +08:00
parent 182ad4b72a
commit e4871c205f
2 changed files with 24 additions and 4 deletions

View File

@ -1,6 +1,7 @@
Version 1.33 2016-12-13
Version 1.33 2016-12-22
* add function hash_get_prime_capacity
* refine getFileContent log info
Version 1.32 2016-12-01
* downgrade log level from warning to debug

View File

@ -960,13 +960,32 @@ int getFileContent(const char *filename, char **buff, int64_t *file_size)
{
int fd;
errno = 0;
if (!isFile(filename))
{
*buff = NULL;
*file_size = 0;
logError("file: "__FILE__", line: %d, "
"%s is not a regular file", __LINE__, filename);
return EINVAL;
if (errno != 0)
{
if (errno == ENOENT)
{
logError("file: "__FILE__", line: %d, "
"file %s not exist", __LINE__, filename);
}
else
{
logError("file: "__FILE__", line: %d, "
"stat %s fail, errno: %d, error info: %s",
__LINE__, filename, errno, STRERROR(errno));
}
return errno != 0 ? errno : ENOENT;
}
else
{
logError("file: "__FILE__", line: %d, "
"%s is not a regular file", __LINE__, filename);
return EINVAL;
}
}
fd = open(filename, O_RDONLY);