Chromium Code Reviews| 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 | 9 |
| 10 #include <errno.h> | 10 #include <errno.h> |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 return 0; | 116 return 0; |
| 117 } | 117 } |
| 118 return curr; | 118 return curr; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void sk_fclose(SkFILE* f) { | 121 void sk_fclose(SkFILE* f) { |
| 122 SkASSERT(f); | 122 SkASSERT(f); |
| 123 ::fclose((FILE*)f); | 123 ::fclose((FILE*)f); |
| 124 } | 124 } |
| 125 | 125 |
| 126 bool sk_exists(const char *path) { | 126 bool sk_exists(const char *path, SkFILE_Flags flags) { |
| 127 int mode = 0; | |
|
mtklein
2014/07/10 21:03:30
// F_OK
?
bungeman-skia
2014/07/10 21:50:07
Done.
| |
| 128 if (flags & kRead_SkFILE_Flag) { | |
| 129 mode |= 4; //R_OK | |
| 130 } | |
| 131 if (flags & kWrite_SkFILE_Flag) { | |
| 132 mode |= 2; //W_OK | |
| 133 } | |
| 127 #ifdef _WIN32 | 134 #ifdef _WIN32 |
| 128 return (0 == _access(path, 0)); | 135 return (0 == _access(path, mode)); |
| 129 #else | 136 #else |
| 130 return (0 == access(path, 0)); | 137 return (0 == access(path, mode)); |
| 131 #endif | 138 #endif |
| 132 } | 139 } |
| 133 | 140 |
| 134 bool sk_isdir(const char *path) { | 141 bool sk_isdir(const char *path) { |
| 135 struct stat status; | 142 struct stat status; |
| 136 if (0 != stat(path, &status)) { | 143 if (0 != stat(path, &status)) { |
| 137 return false; | 144 return false; |
| 138 } | 145 } |
| 139 return SkToBool(status.st_mode & S_IFDIR); | 146 return SkToBool(status.st_mode & S_IFDIR); |
| 140 } | 147 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 156 #else | 163 #else |
| 157 retval = mkdir(path, 0777); | 164 retval = mkdir(path, 0777); |
| 158 #endif | 165 #endif |
| 159 if (0 == retval) { | 166 if (0 == retval) { |
| 160 return true; | 167 return true; |
| 161 } else { | 168 } else { |
| 162 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); | 169 fprintf(stderr, "sk_mkdir: error %d creating dir '%s'\n", errno, path); |
| 163 return false; | 170 return false; |
| 164 } | 171 } |
| 165 } | 172 } |
| OLD | NEW |