OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 return false; | 236 return false; |
237 | 237 |
238 // Check if it's time to stop writing. | 238 // Check if it's time to stop writing. |
239 if (max_size_in_bytes_ > 0 && | 239 if (max_size_in_bytes_ > 0 && |
240 (size_in_bytes_ + length) > max_size_in_bytes_) { | 240 (size_in_bytes_ + length) > max_size_in_bytes_) { |
241 FlushImpl(); | 241 FlushImpl(); |
242 return false; | 242 return false; |
243 } | 243 } |
244 | 244 |
245 size_t num_bytes = fwrite(buf, 1, length, id_); | 245 size_t num_bytes = fwrite(buf, 1, length, id_); |
246 if (num_bytes > 0) { | 246 size_in_bytes_ += num_bytes; |
247 size_in_bytes_ += num_bytes; | 247 if (num_bytes != length) { |
248 return true; | 248 CloseFileImpl(); |
| 249 return false; |
249 } | 250 } |
250 | 251 return true; |
251 CloseFileImpl(); | |
252 return false; | |
253 } | 252 } |
254 | 253 |
255 int FileWrapperImpl::CloseFileImpl() { | 254 int FileWrapperImpl::CloseFileImpl() { |
256 if (id_ != NULL) { | 255 if (id_ != NULL) { |
257 if (managed_file_handle_) | 256 if (managed_file_handle_) |
258 fclose(id_); | 257 fclose(id_); |
259 id_ = NULL; | 258 id_ = NULL; |
260 } | 259 } |
261 memset(file_name_utf8_, 0, kMaxFileNameSize); | 260 memset(file_name_utf8_, 0, kMaxFileNameSize); |
262 open_ = false; | 261 open_ = false; |
263 return 0; | 262 return 0; |
264 } | 263 } |
265 | 264 |
266 int FileWrapperImpl::FlushImpl() { | 265 int FileWrapperImpl::FlushImpl() { |
267 if (id_ != NULL) { | 266 if (id_ != NULL) { |
268 return fflush(id_); | 267 return fflush(id_); |
269 } | 268 } |
270 return -1; | 269 return -1; |
271 } | 270 } |
272 | 271 |
273 int FileWrapper::Rewind() { | 272 int FileWrapper::Rewind() { |
274 RTC_DCHECK(false); | 273 RTC_DCHECK(false); |
275 return -1; | 274 return -1; |
276 } | 275 } |
277 | 276 |
278 } // namespace webrtc | 277 } // namespace webrtc |
OLD | NEW |