mirror of
https://github.com/facebook/zstd.git
synced 2025-07-29 11:21:22 +03:00
Use Existing Src File Stat in *_dstFile()
Funcs
One fewer `stat()` call to make per operation!
This commit is contained in:
@ -1631,20 +1631,16 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
|
|||||||
{
|
{
|
||||||
int closeDstFile = 0;
|
int closeDstFile = 0;
|
||||||
int result;
|
int result;
|
||||||
stat_t statbuf;
|
|
||||||
int transferMTime = 0;
|
int transferMTime = 0;
|
||||||
FILE *dstFile;
|
FILE *dstFile;
|
||||||
|
|
||||||
(void)srcFileStat;
|
|
||||||
|
|
||||||
assert(AIO_ReadPool_getFile(ress.readCtx) != NULL);
|
assert(AIO_ReadPool_getFile(ress.readCtx) != NULL);
|
||||||
if (AIO_WritePool_getFile(ress.writeCtx) == NULL) {
|
if (AIO_WritePool_getFile(ress.writeCtx) == NULL) {
|
||||||
int dstFilePermissions = DEFAULT_FILE_PERMISSIONS;
|
int dstFilePermissions = DEFAULT_FILE_PERMISSIONS;
|
||||||
if ( strcmp (srcFileName, stdinmark)
|
if ( strcmp (srcFileName, stdinmark)
|
||||||
&& strcmp (dstFileName, stdoutmark)
|
&& strcmp (dstFileName, stdoutmark)
|
||||||
&& UTIL_stat(srcFileName, &statbuf)
|
&& UTIL_isRegularFileStat(srcFileStat) ) {
|
||||||
&& UTIL_isRegularFileStat(&statbuf) ) {
|
dstFilePermissions = srcFileStat->st_mode;
|
||||||
dstFilePermissions = statbuf.st_mode;
|
|
||||||
transferMTime = 1;
|
transferMTime = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1671,7 +1667,7 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
|
|||||||
result=1;
|
result=1;
|
||||||
}
|
}
|
||||||
if (transferMTime) {
|
if (transferMTime) {
|
||||||
UTIL_utime(dstFileName, &statbuf);
|
UTIL_utime(dstFileName, srcFileStat);
|
||||||
}
|
}
|
||||||
if ( (result != 0) /* operation failure */
|
if ( (result != 0) /* operation failure */
|
||||||
&& strcmp(dstFileName, stdoutmark) /* special case : don't remove() stdout */
|
&& strcmp(dstFileName, stdoutmark) /* special case : don't remove() stdout */
|
||||||
@ -2474,7 +2470,6 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
|
|||||||
const stat_t* srcFileStat)
|
const stat_t* srcFileStat)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
stat_t statbuf;
|
|
||||||
int releaseDstFile = 0;
|
int releaseDstFile = 0;
|
||||||
int transferMTime = 0;
|
int transferMTime = 0;
|
||||||
|
|
||||||
@ -2485,9 +2480,8 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
|
|||||||
int dstFilePermissions = DEFAULT_FILE_PERMISSIONS;
|
int dstFilePermissions = DEFAULT_FILE_PERMISSIONS;
|
||||||
if ( strcmp(srcFileName, stdinmark) /* special case : don't transfer permissions from stdin */
|
if ( strcmp(srcFileName, stdinmark) /* special case : don't transfer permissions from stdin */
|
||||||
&& strcmp(dstFileName, stdoutmark)
|
&& strcmp(dstFileName, stdoutmark)
|
||||||
&& UTIL_stat(srcFileName, &statbuf)
|
&& UTIL_isRegularFileStat(srcFileStat) ) {
|
||||||
&& UTIL_isRegularFileStat(&statbuf) ) {
|
dstFilePermissions = srcFileStat->st_mode;
|
||||||
dstFilePermissions = statbuf.st_mode;
|
|
||||||
transferMTime = 1;
|
transferMTime = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2514,7 +2508,7 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (transferMTime) {
|
if (transferMTime) {
|
||||||
UTIL_utime(dstFileName, &statbuf);
|
UTIL_utime(dstFileName, srcFileStat);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (result != 0) /* operation failure */
|
if ( (result != 0) /* operation failure */
|
||||||
|
@ -12,8 +12,6 @@ Trace:FileStat: < 1
|
|||||||
Trace:FileStat: < 0
|
Trace:FileStat: < 0
|
||||||
Trace:FileStat: > UTIL_stat(file)
|
Trace:FileStat: > UTIL_stat(file)
|
||||||
Trace:FileStat: < 1
|
Trace:FileStat: < 1
|
||||||
Trace:FileStat: > UTIL_stat(file)
|
|
||||||
Trace:FileStat: < 1
|
|
||||||
Trace:FileStat: > UTIL_isSameFile(file, file.zst)
|
Trace:FileStat: > UTIL_isSameFile(file, file.zst)
|
||||||
Trace:FileStat: > UTIL_stat(file)
|
Trace:FileStat: > UTIL_stat(file)
|
||||||
Trace:FileStat: < 1
|
Trace:FileStat: < 1
|
||||||
|
@ -10,8 +10,6 @@ Trace:FileStat: < 1
|
|||||||
Trace:FileStat: < 0
|
Trace:FileStat: < 0
|
||||||
Trace:FileStat: > UTIL_stat(file.zst)
|
Trace:FileStat: > UTIL_stat(file.zst)
|
||||||
Trace:FileStat: < 1
|
Trace:FileStat: < 1
|
||||||
Trace:FileStat: > UTIL_stat(file.zst)
|
|
||||||
Trace:FileStat: < 1
|
|
||||||
Trace:FileStat: > UTIL_isSameFile(file.zst, file)
|
Trace:FileStat: > UTIL_isSameFile(file.zst, file)
|
||||||
Trace:FileStat: > UTIL_stat(file.zst)
|
Trace:FileStat: > UTIL_stat(file.zst)
|
||||||
Trace:FileStat: < 1
|
Trace:FileStat: < 1
|
||||||
|
Reference in New Issue
Block a user