OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 "SkTFitsIn.h" | 10 #include "SkTFitsIn.h" |
11 | 11 |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include <sys/mman.h> | 13 #include <sys/mman.h> |
14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
15 #include <sys/types.h> | 15 #include <sys/types.h> |
| 16 #include <unistd.h> |
| 17 |
| 18 bool sk_exists(const char *path, SkFILE_Flags flags) { |
| 19 int mode = F_OK; |
| 20 if (flags & kRead_SkFILE_Flag) { |
| 21 mode |= R_OK; |
| 22 } |
| 23 if (flags & kWrite_SkFILE_Flag) { |
| 24 mode |= W_OK; |
| 25 } |
| 26 return (0 == access(path, mode)); |
| 27 } |
16 | 28 |
17 typedef struct { | 29 typedef struct { |
18 dev_t dev; | 30 dev_t dev; |
19 ino_t ino; | 31 ino_t ino; |
20 } SkFILEID; | 32 } SkFILEID; |
21 | 33 |
22 static bool sk_ino(SkFILE* a, SkFILEID* id) { | 34 static bool sk_ino(SkFILE* a, SkFILEID* id) { |
23 int fd = fileno((FILE*)a); | 35 int fd = fileno((FILE*)a); |
24 if (fd < 0) { | 36 if (fd < 0) { |
25 return 0; | 37 return 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 83 } |
72 | 84 |
73 void* sk_fmmap(SkFILE* f, size_t* size) { | 85 void* sk_fmmap(SkFILE* f, size_t* size) { |
74 int fd = sk_fileno(f); | 86 int fd = sk_fileno(f); |
75 if (fd < 0) { | 87 if (fd < 0) { |
76 return NULL; | 88 return NULL; |
77 } | 89 } |
78 | 90 |
79 return sk_fdmmap(fd, size); | 91 return sk_fdmmap(fd, size); |
80 } | 92 } |
OLD | NEW |