1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-09-28 18:10:47 +00:00
falk-werner_webfuse-provider/test/webfuse/utils/file_utils.cc
2020-02-20 17:15:13 +01:00

38 lines
758 B
C++

#include "webfuse/utils/file_utils.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
namespace webfuse_test
{
bool is_dir(std::string const & path)
{
struct stat info;
int rc = stat(path.c_str(), &info);
return (0 == rc) && (S_ISDIR(info.st_mode));
}
bool is_symlink(std::string const & path)
{
struct stat info;
int rc = lstat(path.c_str(), &info);
return (0 == rc) && (S_ISLNK(info.st_mode));
}
bool is_same_path(std::string const & path, std::string const & other)
{
struct stat info;
int rc = stat(path.c_str(), &info);
struct stat info_other;
int rc_other = stat(other.c_str(), &info_other);
return (0 == rc) && (0 == rc_other) && (info.st_ino == info_other.st_ino);
}
}