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

Side by Side Diff: base/os_compat_android.cc

Issue 12767006: [Cleanup] Remove StringPrintf from global namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, once more Created 7 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 unified diff | Download patch | Annotate | Revision Log
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/os_compat_android.h" 5 #include "base/os_compat_android.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <math.h> 8 #include <math.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <time64.h> 10 #include <time64.h>
11 11
12 #include "base/rand_util.h" 12 #include "base/rand_util.h"
13 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 15
16 // There is no futimes() avaiable in Bionic, so we provide our own 16 // There is no futimes() avaiable in Bionic, so we provide our own
17 // implementation until it is there. 17 // implementation until it is there.
18 extern "C" { 18 extern "C" {
19 19
20 int futimes(int fd, const struct timeval tv[2]) { 20 int futimes(int fd, const struct timeval tv[2]) {
21 const std::string fd_path = StringPrintf("/proc/self/fd/%d", fd); 21 const std::string fd_path = base::StringPrintf("/proc/self/fd/%d", fd);
22 return utimes(fd_path.c_str(), tv); 22 return utimes(fd_path.c_str(), tv);
23 } 23 }
24 24
25 // Android has only timegm64() and no timegm(). 25 // Android has only timegm64() and no timegm().
26 // We replicate the behaviour of timegm() when the result overflows time_t. 26 // We replicate the behaviour of timegm() when the result overflows time_t.
27 time_t timegm(struct tm* const t) { 27 time_t timegm(struct tm* const t) {
28 // time_t is signed on Android. 28 // time_t is signed on Android.
29 static const time_t kTimeMax = ~(1 << (sizeof(time_t) * CHAR_BIT - 1)); 29 static const time_t kTimeMax = ~(1 << (sizeof(time_t) * CHAR_BIT - 1));
30 static const time_t kTimeMin = (1 << (sizeof(time_t) * CHAR_BIT - 1)); 30 static const time_t kTimeMin = (1 << (sizeof(time_t) * CHAR_BIT - 1));
31 time64_t result = timegm64(t); 31 time64_t result = timegm64(t);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // The directory doesn't exist, but an error occured 146 // The directory doesn't exist, but an error occured
147 return NULL; 147 return NULL;
148 } 148 }
149 } 149 }
150 150
151 // We reached the max number of tries. 151 // We reached the max number of tries.
152 return NULL; 152 return NULL;
153 } 153 }
154 154
155 } // extern "C" 155 } // extern "C"
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | base/process_linux.cc » ('j') | ipc/ipc_message_utils.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698