mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-19 16:16:48 +00:00
63 lines
1.5 KiB
C++
63 lines
1.5 KiB
C++
/*
|
|
ISC License
|
|
|
|
Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "to_neg_errno.hpp"
|
|
|
|
#include <string>
|
|
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
namespace fs
|
|
{
|
|
static
|
|
inline
|
|
int
|
|
is_same_file(const char *a_,
|
|
const char *b_)
|
|
{
|
|
int rv_a;
|
|
int rv_b;
|
|
struct stat st_a;
|
|
struct stat st_b;
|
|
|
|
rv_a = ::lstat(a_,&st_a);
|
|
rv_b = ::lstat(b_,&st_b);
|
|
|
|
if(rv_a < 0 || rv_b < 0)
|
|
return -errno;
|
|
if(st_a.st_dev != st_b.st_dev || st_a.st_ino != st_b.st_ino)
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
static
|
|
inline
|
|
int
|
|
is_same_file(const std::string &a_,
|
|
const std::string &b_)
|
|
{
|
|
return fs::is_same_file(a_.c_str(),
|
|
b_.c_str());
|
|
}
|
|
}
|