Rename UTIL_getFileStat() -> UTIL_statFile() and UTIL_getDirectoryStat() -> UTIL_statDir()
I want to introduce versions of many of these functions that take pre- populated `stat_t` objects and use those rather than doing their own redundant `stat()` internally. These functions will have `...Stat()` suffixes. So this commit renames these existing functions into the active voice, to avoid confusion.
This commit is contained in:
parent
1a1003f996
commit
b6e24bc4dc
@ -1478,7 +1478,7 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
|
|||||||
addHandler(dstFileName);
|
addHandler(dstFileName);
|
||||||
|
|
||||||
if ( strcmp (srcFileName, stdinmark)
|
if ( strcmp (srcFileName, stdinmark)
|
||||||
&& UTIL_getFileStat(srcFileName, &statbuf))
|
&& UTIL_statFile(srcFileName, &statbuf))
|
||||||
transfer_permissions = 1;
|
transfer_permissions = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2344,7 +2344,7 @@ static int FIO_decompressDstFile(FIO_prefs_t* const prefs,
|
|||||||
addHandler(dstFileName);
|
addHandler(dstFileName);
|
||||||
|
|
||||||
if ( strcmp(srcFileName, stdinmark) /* special case : don't transfer permissions from stdin */
|
if ( strcmp(srcFileName, stdinmark) /* special case : don't transfer permissions from stdin */
|
||||||
&& UTIL_getFileStat(srcFileName, &statbuf) )
|
&& UTIL_statFile(srcFileName, &statbuf) )
|
||||||
transfer_permissions = 1;
|
transfer_permissions = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,10 +119,10 @@ int UTIL_fileExist(const char* filename)
|
|||||||
int UTIL_isRegularFile(const char* infilename)
|
int UTIL_isRegularFile(const char* infilename)
|
||||||
{
|
{
|
||||||
stat_t statbuf;
|
stat_t statbuf;
|
||||||
return UTIL_getFileStat(infilename, &statbuf); /* Only need to know whether it is a regular file */
|
return UTIL_statFile(infilename, &statbuf); /* Only need to know whether it is a regular file */
|
||||||
}
|
}
|
||||||
|
|
||||||
int UTIL_getFileStat(const char* infilename, stat_t *statbuf)
|
int UTIL_statFile(const char* infilename, stat_t *statbuf)
|
||||||
{
|
{
|
||||||
const int r = UTIL_stat(infilename, statbuf);
|
const int r = UTIL_stat(infilename, statbuf);
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
@ -132,7 +132,7 @@ int UTIL_getFileStat(const char* infilename, stat_t *statbuf)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int UTIL_getDirectoryStat(const char* infilename, stat_t *statbuf)
|
int UTIL_statDir(const char* infilename, stat_t *statbuf)
|
||||||
{
|
{
|
||||||
const int r = UTIL_stat(infilename, statbuf);
|
const int r = UTIL_stat(infilename, statbuf);
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
@ -190,7 +190,7 @@ int UTIL_setFileStat(const char *filename, const stat_t *statbuf)
|
|||||||
int UTIL_isDirectory(const char* infilename)
|
int UTIL_isDirectory(const char* infilename)
|
||||||
{
|
{
|
||||||
stat_t statbuf;
|
stat_t statbuf;
|
||||||
return UTIL_getDirectoryStat(infilename, &statbuf);
|
return UTIL_statDir(infilename, &statbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int UTIL_compareStr(const void *p1, const void *p2) {
|
int UTIL_compareStr(const void *p1, const void *p2) {
|
||||||
@ -647,7 +647,7 @@ static int isFileNameValidForMirroredOutput(const char *filename)
|
|||||||
static mode_t getDirMode(const char *dirName)
|
static mode_t getDirMode(const char *dirName)
|
||||||
{
|
{
|
||||||
stat_t st;
|
stat_t st;
|
||||||
int ret = UTIL_getDirectoryStat(dirName, &st);
|
int ret = UTIL_statDir(dirName, &st);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
UTIL_DISPLAY("zstd: failed to get DIR stats %s: %s\n", dirName, strerror(errno));
|
UTIL_DISPLAY("zstd: failed to get DIR stats %s: %s\n", dirName, strerror(errno));
|
||||||
return DIR_DEFAULT_MODE;
|
return DIR_DEFAULT_MODE;
|
||||||
|
@ -120,6 +120,8 @@ extern int g_utilDisplayLevel;
|
|||||||
* Returns success (1) or failure (0).
|
* Returns success (1) or failure (0).
|
||||||
*/
|
*/
|
||||||
int UTIL_stat(const char* filename, stat_t* statbuf);
|
int UTIL_stat(const char* filename, stat_t* statbuf);
|
||||||
|
int UTIL_statFile(const char* infilename, stat_t* statbuf); /* also check it's a file */
|
||||||
|
int UTIL_statDir(const char* infilename, stat_t* statbuf); /* also check it's a directory */
|
||||||
int UTIL_fileExist(const char* filename);
|
int UTIL_fileExist(const char* filename);
|
||||||
int UTIL_isRegularFile(const char* infilename);
|
int UTIL_isRegularFile(const char* infilename);
|
||||||
int UTIL_isDirectory(const char* infilename);
|
int UTIL_isDirectory(const char* infilename);
|
||||||
@ -131,9 +133,7 @@ int UTIL_isFIFO(const char* infilename);
|
|||||||
#define UTIL_FILESIZE_UNKNOWN ((U64)(-1))
|
#define UTIL_FILESIZE_UNKNOWN ((U64)(-1))
|
||||||
U64 UTIL_getFileSize(const char* infilename);
|
U64 UTIL_getFileSize(const char* infilename);
|
||||||
U64 UTIL_getTotalFileSize(const char* const * fileNamesTable, unsigned nbFiles);
|
U64 UTIL_getTotalFileSize(const char* const * fileNamesTable, unsigned nbFiles);
|
||||||
int UTIL_getFileStat(const char* infilename, stat_t* statbuf);
|
|
||||||
int UTIL_setFileStat(const char* filename, const stat_t* statbuf);
|
int UTIL_setFileStat(const char* filename, const stat_t* statbuf);
|
||||||
int UTIL_getDirectoryStat(const char* infilename, stat_t* statbuf);
|
|
||||||
int UTIL_chmod(char const* filename, mode_t permissions); /*< like chmod, but avoid changing permission of /dev/null */
|
int UTIL_chmod(char const* filename, mode_t permissions); /*< like chmod, but avoid changing permission of /dev/null */
|
||||||
int UTIL_compareStr(const void *p1, const void *p2);
|
int UTIL_compareStr(const void *p1, const void *p2);
|
||||||
const char* UTIL_getFileExtension(const char* infilename);
|
const char* UTIL_getFileExtension(const char* infilename);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user