22#ifdef SK_BUILD_FOR_IOS
27static bool is_ascii(
const char*
s) {
28 while (
char v = *
s++) {
29 if ((v & 0x80) != 0) {
36static FILE* fopen_win(
const char* utf8path,
const char* perm) {
37 if (is_ascii(utf8path)) {
38 return fopen(utf8path, perm);
41 const char* ptr = utf8path;
42 const char*
end = utf8path + strlen(utf8path);
51 std::vector<uint16_t> wchars(n + 1);
52 uint16_t*
out = wchars.data();
59 wchar_t wperms[4] = {(wchar_t)perm[0], (
wchar_t)perm[1], (wchar_t)perm[2], (
wchar_t)perm[3]};
60 return _wfopen((
wchar_t*)wchars.data(), wperms);
65 char perm[4] = {0, 0, 0, 0};
78 file = fopen_win(path, perm);
80 file = fopen(path, perm);
82#ifdef SK_BUILD_FOR_IOS
86 if (ios_get_path_in_bundle(path, &bundlePath)) {
87 file = fopen(bundlePath.
c_str(), perm);
93 SkDEBUGF(
"sk_fopen: fopen(\"%s\", \"%s\") returned nullptr (errno:%d): %s\n",
94 path, perm, errno, strerror(errno));
102 long curr = ftell(f);
107 fseek(f, 0, SEEK_END);
108 long size = ftell(f);
113 fseek(f, curr, SEEK_SET);
119 return fwrite(
buffer, 1, byteCount, f);
128 long curr = ftell(f);
142 struct stat status = {};
143 if (0 != stat(path, &status)) {
144#ifdef SK_BUILD_FOR_IOS
147 if (ios_get_path_in_bundle(path, &bundlePath)) {
148 if (0 != stat(bundlePath.
c_str(), &status)) {
156 return SkToBool(status.st_mode & S_IFDIR);
165 "sk_mkdir: path '%s' already exists but is not a directory\n",
172 retval = _mkdir(path);
174 retval = mkdir(path, 0777);
176 perror(
"mkdir() failed with error: ");
bool sk_exists(const char *path, SkFILE_Flags=(SkFILE_Flags) 0)
bool sk_mkdir(const char *path)
size_t sk_fwrite(const void *buffer, size_t byteCount, FILE *f)
FILE * sk_fopen(const char path[], SkFILE_Flags flags)
size_t sk_fgetsize(FILE *f)
bool sk_isdir(const char *path)
static constexpr bool SkToBool(const T &x)
const char * c_str() const
FlutterSemanticsFlag flags
static const uint8_t buffer[]
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
SK_SPI size_t ToUTF16(SkUnichar uni, uint16_t utf16[2]=nullptr)