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

Side by Side Diff: src/utils/SkOSFile.cpp

Issue 450743002: Add option to dump images from nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move the clear Created 6 years, 4 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 | « include/core/SkOSFile.h ('k') | tests/OSPathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkOSFile.h" 7 #include "SkOSFile.h"
8 8
9 SkString SkOSPath::Join(const char *rootPath, const char *relativePath) { 9 SkString SkOSPath::Join(const char *rootPath, const char *relativePath) {
10 SkString result(rootPath); 10 SkString result(rootPath);
11 if (!result.endsWith(SkPATH_SEPARATOR)) { 11 if (!result.endsWith(SkPATH_SEPARATOR) && !result.isEmpty()) {
12 result.appendUnichar(SkPATH_SEPARATOR); 12 result.appendUnichar(SkPATH_SEPARATOR);
13 } 13 }
14 result.append(relativePath); 14 result.append(relativePath);
15 return result; 15 return result;
16 } 16 }
17 17
18 SkString SkOSPath::Basename(const char* fullPath) { 18 SkString SkOSPath::Basename(const char* fullPath) {
19 if (!fullPath) { 19 if (!fullPath) {
20 return SkString(); 20 return SkString();
21 } 21 }
22 const char* filename = strrchr(fullPath, SkPATH_SEPARATOR); 22 const char* filename = strrchr(fullPath, SkPATH_SEPARATOR);
23 if (NULL == filename) { 23 if (NULL == filename) {
24 filename = fullPath; 24 filename = fullPath;
25 } else { 25 } else {
26 ++filename; 26 ++filename;
27 } 27 }
28 return SkString(filename); 28 return SkString(filename);
29 } 29 }
30 30
31 SkString SkOSPath::Dirname(const char* fullPath) {
32 if (!fullPath) {
33 return SkString();
34 }
35 const char* end = strrchr(fullPath, SkPATH_SEPARATOR);
36 if (NULL == end) {
37 return SkString();
38 }
39 if (end == fullPath) {
40 SkASSERT(fullPath[0] == SkPATH_SEPARATOR);
41 ++end;
42 }
43 return SkString(fullPath, end - fullPath);
44 }
45
31 #ifdef SK_BUILD_FOR_WIN 46 #ifdef SK_BUILD_FOR_WIN
32 47
33 static uint16_t* concat_to_16(const char src[], const char suffix[]) 48 static uint16_t* concat_to_16(const char src[], const char suffix[])
34 { 49 {
35 size_t i, len = strlen(src); 50 size_t i, len = strlen(src);
36 size_t len2 = 3 + (suffix ? strlen(suffix) : 0); 51 size_t len2 = 3 + (suffix ? strlen(suffix) : 0);
37 uint16_t* dst = (uint16_t*)sk_malloc_throw((len + len2) * sizeof(uint16_t)); 52 uint16_t* dst = (uint16_t*)sk_malloc_throw((len + len2) * sizeof(uint16_t));
38 53
39 for (i = 0; i < len; i++) 54 for (i = 0; i < len; i++)
40 dst[i] = src[i]; 55 dst[i] = src[i];
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (entry) // we broke out with a file 244 if (entry) // we broke out with a file
230 { 245 {
231 if (name) 246 if (name)
232 name->set(entry->d_name); 247 name->set(entry->d_name);
233 return true; 248 return true;
234 } 249 }
235 } 250 }
236 return false; 251 return false;
237 } 252 }
238 #endif // if one of:SK_BUILD_FOR_MAC, SK_BUILD_FOR_UNIX, SK_BUILD_FOR_ANDROID,SK _BUILD_FOR_IOS 253 #endif // if one of:SK_BUILD_FOR_MAC, SK_BUILD_FOR_UNIX, SK_BUILD_FOR_ANDROID,SK _BUILD_FOR_IOS
OLDNEW
« no previous file with comments | « include/core/SkOSFile.h ('k') | tests/OSPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698