Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: src/ports/SkOSFile_posix.cpp

Issue 1467533003: Eliminate SkFILE - it always is the same as FILE. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-11-20 (Friday) 14:01:26 EST Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkStream.cpp ('k') | src/ports/SkOSFile_stdio.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "SkString.h" 9 #include "SkString.h"
10 #include "SkTFitsIn.h" 10 #include "SkTFitsIn.h"
(...skipping 17 matching lines...) Expand all
28 mode |= W_OK; 28 mode |= W_OK;
29 } 29 }
30 return (0 == access(path, mode)); 30 return (0 == access(path, mode));
31 } 31 }
32 32
33 typedef struct { 33 typedef struct {
34 dev_t dev; 34 dev_t dev;
35 ino_t ino; 35 ino_t ino;
36 } SkFILEID; 36 } SkFILEID;
37 37
38 static bool sk_ino(SkFILE* a, SkFILEID* id) { 38 static bool sk_ino(FILE* a, SkFILEID* id) {
39 int fd = fileno((FILE*)a); 39 int fd = fileno(a);
40 if (fd < 0) { 40 if (fd < 0) {
41 return 0; 41 return 0;
42 } 42 }
43 struct stat status; 43 struct stat status;
44 if (0 != fstat(fd, &status)) { 44 if (0 != fstat(fd, &status)) {
45 return 0; 45 return 0;
46 } 46 }
47 id->dev = status.st_dev; 47 id->dev = status.st_dev;
48 id->ino = status.st_ino; 48 id->ino = status.st_ino;
49 return true; 49 return true;
50 } 50 }
51 51
52 bool sk_fidentical(SkFILE* a, SkFILE* b) { 52 bool sk_fidentical(FILE* a, FILE* b) {
53 SkFILEID aID, bID; 53 SkFILEID aID, bID;
54 return sk_ino(a, &aID) && sk_ino(b, &bID) 54 return sk_ino(a, &aID) && sk_ino(b, &bID)
55 && aID.ino == bID.ino 55 && aID.ino == bID.ino
56 && aID.dev == bID.dev; 56 && aID.dev == bID.dev;
57 } 57 }
58 58
59 void sk_fmunmap(const void* addr, size_t length) { 59 void sk_fmunmap(const void* addr, size_t length) {
60 munmap(const_cast<void*>(addr), length); 60 munmap(const_cast<void*>(addr), length);
61 } 61 }
62 62
(...skipping 12 matching lines...) Expand all
75 75
76 void* addr = mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, fd, 0); 76 void* addr = mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, fd, 0);
77 if (MAP_FAILED == addr) { 77 if (MAP_FAILED == addr) {
78 return nullptr; 78 return nullptr;
79 } 79 }
80 80
81 *size = fileSize; 81 *size = fileSize;
82 return addr; 82 return addr;
83 } 83 }
84 84
85 int sk_fileno(SkFILE* f) { 85 int sk_fileno(FILE* f) {
86 return fileno((FILE*)f); 86 return fileno(f);
87 } 87 }
88 88
89 void* sk_fmmap(SkFILE* f, size_t* size) { 89 void* sk_fmmap(FILE* f, size_t* size) {
90 int fd = sk_fileno(f); 90 int fd = sk_fileno(f);
91 if (fd < 0) { 91 if (fd < 0) {
92 return nullptr; 92 return nullptr;
93 } 93 }
94 94
95 return sk_fdmmap(fd, size); 95 return sk_fdmmap(fd, size);
96 } 96 }
97 97
98 //////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////
99 99
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 if (entry) { // we broke out with a file 173 if (entry) { // we broke out with a file
174 if (name) { 174 if (name) {
175 name->set(entry->d_name); 175 name->set(entry->d_name);
176 } 176 }
177 return true; 177 return true;
178 } 178 }
179 } 179 }
180 return false; 180 return false;
181 } 181 }
OLDNEW
« no previous file with comments | « src/core/SkStream.cpp ('k') | src/ports/SkOSFile_stdio.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698