diff --git a/HISTORY b/HISTORY index 622be89..2f7e9f8 100644 --- a/HISTORY +++ b/HISTORY @@ -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 diff --git a/src/shared_func.c b/src/shared_func.c index 763a572..add2ca7 100644 --- a/src/shared_func.c +++ b/src/shared_func.c @@ -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);