Centralize stat calls to ensure consistency of time fields on windows

This commit is contained in:
Jean-Francois Dockes
2016-01-08 11:23:10 +01:00
parent b2066f6133
commit ff15f8fb1c
9 changed files with 52 additions and 18 deletions
+3 -3
View File
@@ -195,7 +195,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
m_fn = m_tfile;
// Stat the uncompressed file, mainly to get the size
struct stat ucstat;
if (stat(m_fn.c_str(), &ucstat) != 0) {
if (path_fileprops(m_fn, &ucstat) != 0) {
LOGERR(("FileInterner: can't stat the uncompressed file"
"[%s] errno %d\n", m_fn.c_str(), errno));
return;
@@ -1042,7 +1042,7 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
{
LOGDEB(("FileInterner::isCompressed: [%s]\n", fn.c_str()));
struct stat st;
if (stat(fn.c_str(), &st) < 0) {
if (path_fileprops(fn, &st) < 0) {
LOGERR(("FileInterner::isCompressed: can't stat [%s]\n", fn.c_str()));
return false;
}
@@ -1066,7 +1066,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
{
LOGDEB(("FileInterner::maybeUncompressToTemp: [%s]\n", fn.c_str()));
struct stat st;
if (stat(fn.c_str(), &st) < 0) {
if (path_fileprops(fn.c_str(), &st) < 0) {
LOGERR(("FileInterner::maybeUncompressToTemp: can't stat [%s]\n",
fn.c_str()));
return false;
+1 -2
View File
@@ -20,7 +20,6 @@
#include <errno.h>
#include "safefcntl.h"
#include <sys/types.h>
#include "safesysstat.h"
#include "safeunistd.h"
#include <iostream>
@@ -56,7 +55,7 @@ bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
// file size for oversize check
long long fsize = path_filesize(m_fn);
if (fsize < 0) {
LOGERR(("MimeHandlerText::set_document_file: stat(%s) errno %d\n",
LOGERR(("MimeHandlerText::set_document_file: stat %s errno %d\n",
m_fn.c_str(), errno));
return false;
}