Remove UTIL_statFile() and UTIL_statDir(); Decompose Former Call-Sites
This commit is contained in:
parent
93dda988c8
commit
51ac0207af
@ -1486,7 +1486,8 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
|
||||
addHandler(dstFileName);
|
||||
|
||||
if ( strcmp (srcFileName, stdinmark)
|
||||
&& UTIL_statFile(srcFileName, &statbuf))
|
||||
&& UTIL_stat(srcFileName, &statbuf)
|
||||
&& UTIL_isRegularFileStat(&statbuf) )
|
||||
transfer_permissions = 1;
|
||||
}
|
||||
|
||||
@ -2352,7 +2353,8 @@ static int FIO_decompressDstFile(FIO_prefs_t* const prefs,
|
||||
addHandler(dstFileName);
|
||||
|
||||
if ( strcmp(srcFileName, stdinmark) /* special case : don't transfer permissions from stdin */
|
||||
&& UTIL_statFile(srcFileName, &statbuf) )
|
||||
&& UTIL_stat(srcFileName, &statbuf)
|
||||
&& UTIL_isRegularFileStat(&statbuf) )
|
||||
transfer_permissions = 1;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ int UTIL_stat(const char* filename, stat_t* statbuf)
|
||||
int UTIL_isRegularFile(const char* infilename)
|
||||
{
|
||||
stat_t statbuf;
|
||||
return UTIL_statFile(infilename, &statbuf); /* Only need to know whether it is a regular file */
|
||||
return UTIL_stat(infilename, &statbuf) && UTIL_isRegularFileStat(&statbuf);
|
||||
}
|
||||
|
||||
int UTIL_isRegularFileStat(const stat_t* statbuf)
|
||||
@ -125,16 +125,6 @@ int UTIL_isRegularFileStat(const stat_t* statbuf)
|
||||
#endif
|
||||
}
|
||||
|
||||
int UTIL_statFile(const char* infilename, stat_t *statbuf)
|
||||
{
|
||||
return UTIL_stat(infilename, statbuf) && UTIL_isRegularFileStat(statbuf);
|
||||
}
|
||||
|
||||
int UTIL_statDir(const char* infilename, stat_t *statbuf)
|
||||
{
|
||||
return UTIL_stat(infilename, statbuf) && UTIL_isDirectoryStat(statbuf);
|
||||
}
|
||||
|
||||
/* like chmod, but avoid changing permission of /dev/null */
|
||||
int UTIL_chmod(char const* filename, const stat_t* statbuf, mode_t permissions)
|
||||
{
|
||||
@ -189,7 +179,7 @@ int UTIL_setFileStat(const char *filename, const stat_t *statbuf)
|
||||
int UTIL_isDirectory(const char* infilename)
|
||||
{
|
||||
stat_t statbuf;
|
||||
return UTIL_statDir(infilename, &statbuf);
|
||||
return UTIL_stat(infilename, &statbuf) && UTIL_isDirectoryStat(&statbuf);
|
||||
}
|
||||
|
||||
int UTIL_isDirectoryStat(const stat_t* statbuf)
|
||||
@ -671,11 +661,14 @@ static int isFileNameValidForMirroredOutput(const char *filename)
|
||||
static mode_t getDirMode(const char *dirName)
|
||||
{
|
||||
stat_t st;
|
||||
int ret = UTIL_statDir(dirName, &st);
|
||||
if (!ret) {
|
||||
if (!UTIL_stat(dirName, &st)) {
|
||||
UTIL_DISPLAY("zstd: failed to get DIR stats %s: %s\n", dirName, strerror(errno));
|
||||
return DIR_DEFAULT_MODE;
|
||||
}
|
||||
if (!UTIL_isDirectoryStat(&st)) {
|
||||
UTIL_DISPLAY("zstd: expected directory: %s\n", dirName);
|
||||
return DIR_DEFAULT_MODE;
|
||||
}
|
||||
return st.st_mode;
|
||||
}
|
||||
|
||||
|
@ -120,10 +120,6 @@ extern int g_utilDisplayLevel;
|
||||
* Returns success (1) or failure (0).
|
||||
*/
|
||||
int UTIL_stat(const char* filename, stat_t* statbuf);
|
||||
/** Also checks that the target is a regular file. */
|
||||
int UTIL_statFile(const char* infilename, stat_t* statbuf);
|
||||
/** Also checks that the target is a directory. */
|
||||
int UTIL_statDir(const char* infilename, stat_t* statbuf);
|
||||
|
||||
/**
|
||||
* Instead of getting a file's stats, this updates them with the info in the
|
||||
|
Loading…
Reference in New Issue
Block a user