Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Unified Diff: base/file_util_posix.cc

Issue 6660001: Getting service process on Mac to handle having things moved/changed underneath it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up phajdan's comments, got things working properly Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 8df0d27f2dfbde297b8bc9025f3ce13800d4a531..23218e83a255587b3bb1a2dec702a08c686e207a 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -524,13 +524,25 @@ bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
return true;
}
-bool GetInode(const FilePath& path, ino_t* inode) {
+bool AreReferringToSameObject(const FilePath& a, const FilePath& b) {
+ ino_t inode_a, inode_b;
+ dev_t dev_a, dev_b;
+ if (GetInodeAndDevice(a, &inode_a, &dev_a)) {
+ if (GetInodeAndDevice(b, &inode_b, &dev_b)) {
+ return (inode_a == inode_b) && (dev_a == dev_b);
+ }
+ }
+ return false;
+}
+
+bool GetInodeAndDevice(const FilePath& path, ino_t* inode, dev_t* dev) {
Mark Mentovai 2011/03/11 20:13:52 Nobody was using this function?
Mark Mentovai 2011/03/11 20:13:52 GetDeviceAndInode would make more sense to me.
base::ThreadRestrictions::AssertIOAllowed(); // For call to stat().
struct stat buffer;
int result = stat(path.value().c_str(), &buffer);
if (result < 0)
return false;
+ *dev = buffer.st_dev;
*inode = buffer.st_ino;
return true;
}

Powered by Google App Engine
This is Rietveld 408576698