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

Unified Diff: base/file_util_posix.cc

Issue 1701005: bsd: refactor XDG bits of linux_util into a shared file. (Closed)
Patch Set: Created 10 years, 8 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 8947d6aacf79d11275f6df32ed86c92013690b4e..2d80053a1068659f7ae3d6eb59eb28e04afa1892 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -21,6 +21,8 @@
#if defined(OS_MACOSX)
#include <AvailabilityMacros.h>
+#else
+#include <glib.h>
willchan no longer on Chromium 2010/04/22 23:01:18 What's this for?
#endif
#include <fstream>
@@ -728,6 +730,23 @@ bool GetShmemTempDir(FilePath* path) {
return true;
}
+FilePath GetHomeDir() {
+ const char* home_dir = getenv("HOME");
willchan no longer on Chromium 2010/04/22 23:01:18 I think you need <stdlib.h> for getenv.
+ if (home_dir && home_dir[0])
+ return FilePath(home_dir);
+
+ home_dir = g_get_home_dir();
+ if (home_dir && home_dir[0])
+ return FilePath(home_dir);
+
+ FilePath rv;
+ if (file_util::GetTempDir(&rv))
+ return rv;
+
+ // Last resort.
+ return FilePath("/tmp");
+}
+
bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
int infile = open(from_path.value().c_str(), O_RDONLY);
if (infile < 0)

Powered by Google App Engine
This is Rietveld 408576698