| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 | 7 |
| 8 #include "SkOSFile.h" | 8 #include "SkOSFile.h" |
| 9 #include "SkTypes.h" | 9 #include "SkTypes.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Get a reference to the file's URL | 31 // Get a reference to the file's URL |
| 32 CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodin
gUTF8); | 32 CFStringRef pathRef = CFStringCreateWithCString(NULL, path, kCFStringEncodin
gUTF8); |
| 33 CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL)
; | 33 CFURLRef imageURL = CFBundleCopyResourceURL(mainBundle, pathRef, NULL, NULL)
; |
| 34 CFRelease(pathRef); | 34 CFRelease(pathRef); |
| 35 if (!imageURL) { | 35 if (!imageURL) { |
| 36 return nullptr; | 36 return nullptr; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Convert the URL reference into a string reference | 39 // Convert the URL reference into a string reference |
| 40 CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathSty
le); | 40 CFStringRef imagePath = CFURLCopyFileSystemPath(imageURL, kCFURLPOSIXPathSty
le); |
| 41 CFRelease(imageURL); |
| 41 | 42 |
| 42 // Get the system encoding method | 43 // Get the system encoding method |
| 43 CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); | 44 CFStringEncoding encodingMethod = CFStringGetSystemEncoding(); |
| 44 | 45 |
| 45 // Convert the string reference into a C string | 46 // Convert the string reference into a C string |
| 46 const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod); | 47 const char *finalPath = CFStringGetCStringPtr(imagePath, encodingMethod); |
| 47 | 48 FILE* fileHandle = fopen(finalPath, perm); |
| 48 return fopen(finalPath, perm); | 49 CFRelease(imagePath); |
| 50 return fileHandle; |
| 49 } | 51 } |
| 50 #endif | 52 #endif |
| 51 | 53 |
| 52 | 54 |
| 53 FILE* sk_fopen(const char path[], SkFILE_Flags flags) { | 55 FILE* sk_fopen(const char path[], SkFILE_Flags flags) { |
| 54 char perm[4]; | 56 char perm[4]; |
| 55 char* p = perm; | 57 char* p = perm; |
| 56 | 58 |
| 57 if (flags & kRead_SkFILE_Flag) { | 59 if (flags & kRead_SkFILE_Flag) { |
| 58 *p++ = 'r'; | 60 *p++ = 'r'; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 #else | 206 #else |
| 205 retval = mkdir(path, 0777); | 207 retval = mkdir(path, 0777); |
| 206 #endif | 208 #endif |
| 207 if (0 == retval) { | 209 if (0 == retval) { |
| 208 return true; | 210 return true; |
| 209 } else { | 211 } else { |
| 210 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); | 212 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); |
| 211 return false; | 213 return false; |
| 212 } | 214 } |
| 213 } | 215 } |
| OLD | NEW |