OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 return true; | 178 return true; |
179 } | 179 } |
180 | 180 |
181 /////////////////////////////////////////////////////////////////////////////// | 181 /////////////////////////////////////////////////////////////////////////////// |
182 | 182 |
183 SkFILEStream::SkFILEStream(const char file[]) : fName(file), fOwnership(kCallerP
asses_Ownership) { | 183 SkFILEStream::SkFILEStream(const char file[]) : fName(file), fOwnership(kCallerP
asses_Ownership) { |
184 fFILE = file ? sk_fopen(fName.c_str(), kRead_SkFILE_Flag) : nullptr; | 184 fFILE = file ? sk_fopen(fName.c_str(), kRead_SkFILE_Flag) : nullptr; |
185 } | 185 } |
186 | 186 |
187 SkFILEStream::SkFILEStream(FILE* file, Ownership ownership) | 187 SkFILEStream::SkFILEStream(FILE* file, Ownership ownership) |
188 : fFILE((SkFILE*)file) | 188 : fFILE(file) |
189 , fOwnership(ownership) { | 189 , fOwnership(ownership) { |
190 } | 190 } |
191 | 191 |
192 SkFILEStream::~SkFILEStream() { | 192 SkFILEStream::~SkFILEStream() { |
193 if (fFILE && fOwnership != kCallerRetains_Ownership) { | 193 if (fFILE && fOwnership != kCallerRetains_Ownership) { |
194 sk_fclose(fFILE); | 194 sk_fclose(fFILE); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 void SkFILEStream::setPath(const char path[]) { | 198 void SkFILEStream::setPath(const char path[]) { |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 fBytesWritten += size; | 843 fBytesWritten += size; |
844 #endif | 844 #endif |
845 return true; | 845 return true; |
846 } | 846 } |
847 | 847 |
848 /////////////////////////////////////////////////////////////////////////////// | 848 /////////////////////////////////////////////////////////////////////////////// |
849 /////////////////////////////////////////////////////////////////////////////// | 849 /////////////////////////////////////////////////////////////////////////////// |
850 | 850 |
851 | 851 |
852 static SkData* mmap_filename(const char path[]) { | 852 static SkData* mmap_filename(const char path[]) { |
853 SkFILE* file = sk_fopen(path, kRead_SkFILE_Flag); | 853 FILE* file = sk_fopen(path, kRead_SkFILE_Flag); |
854 if (nullptr == file) { | 854 if (nullptr == file) { |
855 return nullptr; | 855 return nullptr; |
856 } | 856 } |
857 | 857 |
858 SkData* data = SkData::NewFromFILE(file); | 858 SkData* data = SkData::NewFromFILE(file); |
859 sk_fclose(file); | 859 sk_fclose(file); |
860 return data; | 860 return data; |
861 } | 861 } |
862 | 862 |
863 SkStreamAsset* SkStream::NewFromFile(const char path[]) { | 863 SkStreamAsset* SkStream::NewFromFile(const char path[]) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 while (true) { | 972 while (true) { |
973 count = input->read(scratch, sizeof(scratch)); | 973 count = input->read(scratch, sizeof(scratch)); |
974 if (0 == count) { | 974 if (0 == count) { |
975 return true; | 975 return true; |
976 } | 976 } |
977 if (!out->write(scratch, count)) { | 977 if (!out->write(scratch, count)) { |
978 return false; | 978 return false; |
979 } | 979 } |
980 } | 980 } |
981 } | 981 } |
OLD | NEW |