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 14 matching lines...) Expand all Loading... |
25 *p++ = 'r'; | 25 *p++ = 'r'; |
26 } | 26 } |
27 if (flags & kWrite_SkFILE_Flag) { | 27 if (flags & kWrite_SkFILE_Flag) { |
28 *p++ = 'w'; | 28 *p++ = 'w'; |
29 } | 29 } |
30 *p++ = 'b'; | 30 *p++ = 'b'; |
31 *p = 0; | 31 *p = 0; |
32 | 32 |
33 //TODO: on Windows fopen is just ASCII or the current code page, | 33 //TODO: on Windows fopen is just ASCII or the current code page, |
34 //convert to utf16 and use _wfopen | 34 //convert to utf16 and use _wfopen |
35 return (SkFILE*)::fopen(path, perm); | 35 SkFILE* file = (SkFILE*)::fopen(path, perm); |
| 36 if (nullptr == file && (flags & kWrite_SkFILE_Flag)) { |
| 37 SkDEBUGF(("sk_fopen: fopen(\"%s\", \"%s\") returned NULL (errno:%d): %s\
n", |
| 38 path, perm, errno, strerror(errno))); |
| 39 } |
| 40 return file; |
36 } | 41 } |
37 | 42 |
38 char* sk_fgets(char* str, int size, SkFILE* f) { | 43 char* sk_fgets(char* str, int size, SkFILE* f) { |
39 return ::fgets(str, size, (FILE *)f); | 44 return ::fgets(str, size, (FILE *)f); |
40 } | 45 } |
41 | 46 |
42 int sk_feof(SkFILE *f) { | 47 int sk_feof(SkFILE *f) { |
43 // no :: namespace qualifier because it breaks android | 48 // no :: namespace qualifier because it breaks android |
44 return feof((FILE *)f); | 49 return feof((FILE *)f); |
45 } | 50 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 #else | 151 #else |
147 retval = mkdir(path, 0777); | 152 retval = mkdir(path, 0777); |
148 #endif | 153 #endif |
149 if (0 == retval) { | 154 if (0 == retval) { |
150 return true; | 155 return true; |
151 } else { | 156 } else { |
152 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); | 157 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); |
153 return false; | 158 return false; |
154 } | 159 } |
155 } | 160 } |
OLD | NEW |