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

Side by Side Diff: base/files/file_util_posix.cc

Issue 1339573003: Remove g_get_home_dir() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/file_util.h" 5 #include "base/files/file_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <libgen.h> 10 #include <libgen.h>
11 #include <limits.h> 11 #include <limits.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <stdlib.h> 13 #include <stdlib.h>
14 #include <string.h> 14 #include <string.h>
15 #include <sys/errno.h> 15 #include <sys/errno.h>
16 #include <sys/mman.h> 16 #include <sys/mman.h>
17 #include <sys/param.h> 17 #include <sys/param.h>
18 #include <sys/stat.h> 18 #include <sys/stat.h>
19 #include <sys/time.h> 19 #include <sys/time.h>
20 #include <sys/types.h> 20 #include <sys/types.h>
21 #include <time.h> 21 #include <time.h>
22 #include <unistd.h> 22 #include <unistd.h>
23 23
24 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
25 #include <AvailabilityMacros.h> 25 #include <AvailabilityMacros.h>
26 #include "base/mac/foundation_util.h" 26 #include "base/mac/foundation_util.h"
27 #elif !defined(OS_CHROMEOS) && defined(USE_GLIB)
28 #include <glib.h> // for g_get_home_dir()
29 #endif 27 #endif
30 28
31 #include "base/basictypes.h" 29 #include "base/basictypes.h"
32 #include "base/files/file_enumerator.h" 30 #include "base/files/file_enumerator.h"
33 #include "base/files/file_path.h" 31 #include "base/files/file_path.h"
34 #include "base/files/scoped_file.h" 32 #include "base/files/scoped_file.h"
35 #include "base/logging.h" 33 #include "base/logging.h"
36 #include "base/memory/scoped_ptr.h" 34 #include "base/memory/scoped_ptr.h"
37 #include "base/memory/singleton.h" 35 #include "base/memory/singleton.h"
38 #include "base/path_service.h" 36 #include "base/path_service.h"
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 return FilePath("/"); 469 return FilePath("/");
472 } 470 }
473 #endif 471 #endif
474 472
475 const char* home_dir = getenv("HOME"); 473 const char* home_dir = getenv("HOME");
476 if (home_dir && home_dir[0]) 474 if (home_dir && home_dir[0])
477 return FilePath(home_dir); 475 return FilePath(home_dir);
478 476
479 #if defined(OS_ANDROID) 477 #if defined(OS_ANDROID)
480 DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; 478 DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented.";
481 #elif defined(USE_GLIB) && !defined(OS_CHROMEOS)
482 // g_get_home_dir calls getpwent, which can fall through to LDAP calls so
483 // this may do I/O. However, it should be rare that $HOME is not defined and
484 // this is typically called from the path service which has no threading
485 // restrictions. The path service will cache the result which limits the
486 // badness of blocking on I/O. As a result, we don't have a thread
487 // restriction here.
488 home_dir = g_get_home_dir();
489 if (home_dir && home_dir[0])
490 return FilePath(home_dir);
491 #endif 479 #endif
492 480
493 FilePath rv; 481 FilePath rv;
494 if (GetTempDir(&rv)) 482 if (GetTempDir(&rv))
495 return rv; 483 return rv;
496 484
497 // Last resort. 485 // Last resort.
498 return FilePath("/tmp"); 486 return FilePath("/tmp");
499 } 487 }
500 #endif // !defined(OS_MACOSX) 488 #endif // !defined(OS_MACOSX)
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return false; 914 return false;
927 915
928 DeleteFile(from_path, true); 916 DeleteFile(from_path, true);
929 return true; 917 return true;
930 } 918 }
931 919
932 } // namespace internal 920 } // namespace internal
933 921
934 #endif // !defined(OS_NACL_NONSFI) 922 #endif // !defined(OS_NACL_NONSFI)
935 } // namespace base 923 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698