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

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

Issue 15740024: Reland 'Add path utils, plus a test for it.' (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 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
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * 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
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 #include "SkOSFile.h" 7 #include "SkOSFile.h"
9 8
9 SkString SkOSPath::SkPathJoin(const char *rootPath, const char *relativePath) {
scroggo 2013/05/28 16:44:40 This file is the only one that has changed from th
10 SkString result(rootPath);
11 if (!result.endsWith(SkPATH_SEPARATOR)) {
12 result.appendUnichar(SkPATH_SEPARATOR);
13 }
14 result.append(relativePath);
15 return result;
16 }
17
18 SkString SkOSPath::SkBasename(const char* fullPath) {
19 if (!fullPath) {
20 return SkString();
21 }
22 const char* filename = strrchr(fullPath, SkPATH_SEPARATOR);
23 if (NULL == filename) {
24 filename = fullPath;
25 } else {
26 ++filename;
27 }
28 return SkString(filename);
29 }
30
10 #ifdef SK_BUILD_FOR_WIN 31 #ifdef SK_BUILD_FOR_WIN
11 32
12 static uint16_t* concat_to_16(const char src[], const char suffix[]) 33 static uint16_t* concat_to_16(const char src[], const char suffix[])
13 { 34 {
14 size_t i, len = strlen(src); 35 size_t i, len = strlen(src);
15 size_t len2 = 3 + (suffix ? strlen(suffix) : 0); 36 size_t len2 = 3 + (suffix ? strlen(suffix) : 0);
16 uint16_t* dst = (uint16_t*)sk_malloc_throw((len + len2) * sizeof(uint16_t)); 37 uint16_t* dst = (uint16_t*)sk_malloc_throw((len + len2) * sizeof(uint16_t));
17 38
18 for (i = 0; i < len; i++) 39 for (i = 0; i < len; i++)
19 dst[i] = src[i]; 40 dst[i] = src[i];
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 239 }
219 if (entry) // we broke out with a file 240 if (entry) // we broke out with a file
220 { 241 {
221 if (name) 242 if (name)
222 name->set(entry->d_name); 243 name->set(entry->d_name);
223 return true; 244 return true;
224 } 245 }
225 } 246 }
226 return false; 247 return false;
227 } 248 }
228 249 #endif // if one of:SK_BUILD_FOR_MAC, SK_BUILD_FOR_UNIX, SK_BUILD_FOR_ANDROID,SK _BUILD_FOR_IOS
229 #endif
OLDNEW
« gm/factory.cpp ('K') | « include/core/SkOSFile.h ('k') | tests/OSPathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698