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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 | 234 |
235 if (id_ == NULL) | 235 if (id_ == NULL) |
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 | |
Henrik Grunell WebRTC
2016/03/24 10:34:11
Nit: I think this empty line is nice to keep for r
terelius
2016/03/24 10:38:16
I agree. Done.
| |
245 size_t num_bytes = fwrite(buf, 1, length, id_); | 244 size_t num_bytes = fwrite(buf, 1, length, id_); |
246 if (num_bytes > 0) { | 245 size_in_bytes_ += num_bytes; |
247 size_in_bytes_ += num_bytes; | 246 if (num_bytes != length) { |
248 return true; | 247 CloseFileImpl(); |
248 return false; | |
249 } | 249 } |
250 | 250 return true; |
251 CloseFileImpl(); | |
252 return false; | |
253 } | 251 } |
254 | 252 |
255 int FileWrapperImpl::CloseFileImpl() { | 253 int FileWrapperImpl::CloseFileImpl() { |
256 if (id_ != NULL) { | 254 if (id_ != NULL) { |
257 if (managed_file_handle_) | 255 if (managed_file_handle_) |
258 fclose(id_); | 256 fclose(id_); |
259 id_ = NULL; | 257 id_ = NULL; |
260 } | 258 } |
261 memset(file_name_utf8_, 0, kMaxFileNameSize); | 259 memset(file_name_utf8_, 0, kMaxFileNameSize); |
262 open_ = false; | 260 open_ = false; |
263 return 0; | 261 return 0; |
264 } | 262 } |
265 | 263 |
266 int FileWrapperImpl::FlushImpl() { | 264 int FileWrapperImpl::FlushImpl() { |
267 if (id_ != NULL) { | 265 if (id_ != NULL) { |
268 return fflush(id_); | 266 return fflush(id_); |
269 } | 267 } |
270 return -1; | 268 return -1; |
271 } | 269 } |
272 | 270 |
273 int FileWrapper::Rewind() { | 271 int FileWrapper::Rewind() { |
274 RTC_DCHECK(false); | 272 RTC_DCHECK(false); |
275 return -1; | 273 return -1; |
276 } | 274 } |
277 | 275 |
278 } // namespace webrtc | 276 } // namespace webrtc |
OLD | NEW |