Commit 1d691ca1 authored by Josh Coalson's avatar Josh Coalson
Browse files

add grabbag__file_are_same()

parent 369a6da0
......@@ -45,6 +45,9 @@ const char *grabbag__file_get_basename(const char *srcpath);
*/
FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only);
/* returns true iff stat() succeeds for both files and they have the same inode */
FLAC__bool grabbag__file_are_same(const char *f1, const char *f2);
/* attempts to make writable before unlinking */
FLAC__bool grabbag__file_remove_file(const char *filename);
......
......@@ -108,6 +108,12 @@ FLAC__bool grabbag__file_change_stats(const char *filename, FLAC__bool read_only
return true;
}
FLAC__bool grabbag__file_are_same(const char *f1, const char *f2)
{
struct stat s1, s2;
return f1 && f2 && stat(f1, &s1) == 0 && stat(f2, &s2) == 0 && s1.st_ino == s2.st_ino;
}
FLAC__bool grabbag__file_remove_file(const char *filename)
{
return grabbag__file_change_stats(filename, /*read_only=*/false) && 0 == unlink(filename);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment