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 <io.h> | 12 #include <io.h> |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include <sys/stat.h> | 14 #include <sys/stat.h> |
15 | 15 |
| 16 bool sk_exists(const char *path, SkFILE_Flags flags) { |
| 17 int mode = 0; // existence |
| 18 if (flags & kRead_SkFILE_Flag) { |
| 19 mode |= 4; // read |
| 20 } |
| 21 if (flags & kWrite_SkFILE_Flag) { |
| 22 mode |= 2; // write |
| 23 } |
| 24 return (0 == _access(path, mode)); |
| 25 } |
| 26 |
16 typedef struct { | 27 typedef struct { |
17 ULONGLONG fVolume; | 28 ULONGLONG fVolume; |
18 ULONGLONG fLsbSize; | 29 ULONGLONG fLsbSize; |
19 ULONGLONG fMsbSize; | 30 ULONGLONG fMsbSize; |
20 } SkFILEID; | 31 } SkFILEID; |
21 | 32 |
22 static bool sk_ino(SkFILE* f, SkFILEID* id) { | 33 static bool sk_ino(SkFILE* f, SkFILEID* id) { |
23 int fileno = _fileno((FILE*)f); | 34 int fileno = _fileno((FILE*)f); |
24 if (fileno < 0) { | 35 if (fileno < 0) { |
25 return false; | 36 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 113 } |
103 | 114 |
104 void* sk_fmmap(SkFILE* f, size_t* length) { | 115 void* sk_fmmap(SkFILE* f, size_t* length) { |
105 int fileno = sk_fileno(f); | 116 int fileno = sk_fileno(f); |
106 if (fileno < 0) { | 117 if (fileno < 0) { |
107 return NULL; | 118 return NULL; |
108 } | 119 } |
109 | 120 |
110 return sk_fdmmap(fileno, length); | 121 return sk_fdmmap(fileno, length); |
111 } | 122 } |
OLD | NEW |