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

Side by Side Diff: base/base_paths_android.cc

Issue 7184032: Upstream android file related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the comments Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/base_paths.h"
6
7 #include <unistd.h>
8
9 #include "base/logging.h"
10 #include "base/android_os.h"
darin (slow to review) 2011/06/20 18:44:01 this CL does not have this android_os.h file, and
michaelbai 2011/06/20 22:50:36 I will provide it in next CL.
11
12 namespace base {
13
14 const char kSelfExe[] = "/proc/self/exe";
15
16 bool PathProviderAndroid(int key, FilePath* result) {
17 switch (key) {
18 case base::FILE_EXE: {
19 char bin_dir[PATH_MAX + 1];
20 int bin_dir_size = readlink(kSelfExe, bin_dir, PATH_MAX);
21 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) {
22 NOTREACHED() << "Unable to resolve " << kSelfExe << ".";
23 return false;
24 }
25 bin_dir[bin_dir_size] = 0;
26 *result = FilePath(bin_dir);
27 return true;
28 }
29 case base::FILE_MODULE:
30 NOTIMPLEMENTED();
31 return false;
32 case base::DIR_MODULE: {
darin (slow to review) 2011/06/20 18:44:01 this is supposed to be directory of the currently
michaelbai 2011/06/20 22:50:36 As we discussed, implemented FILE_MODULE and used
33 AndroidOS* aos = AndroidOS::GetSharedInstance();
34 DCHECK(aos);
35 *result = aos->GetLibDirectory();
36 return true;
37 }
38 case base::DIR_SOURCE_ROOT:
39 // This const is only used for tests. Files in this directory are pushed
40 // to the device via android_run_test.sh.
darin (slow to review) 2011/06/20 18:44:01 android_run_test.sh is also not part of this CL.
michaelbai 2011/06/20 22:50:36 Done.
41 *result = FilePath(FILE_PATH_LITERAL("/data/local/tmp/"));
42 return true;
43 case base::DIR_CACHE: {
44 AndroidOS* aos = AndroidOS::GetSharedInstance();
45 DCHECK(aos);
46 *result = aos->GetCacheDirectory();
47 return true;
48 }
49 default:
50 // Note: the path system expects this function to override the default
51 // behavior. So no need to log an error if we don't support a given
52 // path. The system will just use the default.
53 return false;
54 }
55 }
56
57 } // namespace base
OLDNEW
« no previous file with comments | « base/DEPS ('k') | base/file_util_android.h » ('j') | base/file_util_android.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698