| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 |
| 11 #if defined(WEBRTC_POSIX) | 11 #if defined(WEBRTC_POSIX) |
| 12 #include <sys/file.h> | 12 #include <sys/file.h> |
| 13 #endif // WEBRTC_POSIX | 13 #endif // WEBRTC_POSIX |
| 14 #include <sys/types.h> | 14 #include <sys/types.h> |
| 15 #include <sys/stat.h> | 15 #include <sys/stat.h> |
| 16 #include <errno.h> | 16 #include <errno.h> |
| 17 | 17 |
| 18 #include <algorithm> | 18 #include <algorithm> |
| 19 #include <string> | 19 #include <string> |
| 20 | 20 |
| 21 #include "webrtc/base/basictypes.h" | 21 #include "webrtc/base/basictypes.h" |
| 22 #include "webrtc/base/checks.h" |
| 22 #include "webrtc/base/common.h" | 23 #include "webrtc/base/common.h" |
| 23 #include "webrtc/base/logging.h" | 24 #include "webrtc/base/logging.h" |
| 24 #include "webrtc/base/messagequeue.h" | 25 #include "webrtc/base/messagequeue.h" |
| 25 #include "webrtc/base/stream.h" | 26 #include "webrtc/base/stream.h" |
| 26 #include "webrtc/base/stringencode.h" | 27 #include "webrtc/base/stringencode.h" |
| 27 #include "webrtc/base/stringutils.h" | 28 #include "webrtc/base/stringutils.h" |
| 28 #include "webrtc/base/thread.h" | 29 #include "webrtc/base/thread.h" |
| 29 #include "webrtc/base/timeutils.h" | 30 #include "webrtc/base/timeutils.h" |
| 30 | 31 |
| 31 #if defined(WEBRTC_WIN) | 32 #if defined(WEBRTC_WIN) |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 return false; | 480 return false; |
| 480 *size = file_stats.st_size; | 481 *size = file_stats.st_size; |
| 481 return true; | 482 return true; |
| 482 } | 483 } |
| 483 | 484 |
| 484 bool FileStream::Flush() { | 485 bool FileStream::Flush() { |
| 485 if (file_) { | 486 if (file_) { |
| 486 return (0 == fflush(file_)); | 487 return (0 == fflush(file_)); |
| 487 } | 488 } |
| 488 // try to flush empty file? | 489 // try to flush empty file? |
| 489 ASSERT(false); | 490 RTC_NOTREACHED(); |
| 490 return false; | 491 return false; |
| 491 } | 492 } |
| 492 | 493 |
| 493 #if defined(WEBRTC_POSIX) && !defined(__native_client__) | 494 #if defined(WEBRTC_POSIX) && !defined(__native_client__) |
| 494 | 495 |
| 495 bool FileStream::TryLock() { | 496 bool FileStream::TryLock() { |
| 496 if (file_ == NULL) { | 497 if (file_ == NULL) { |
| 497 // Stream not open. | 498 // Stream not open. |
| 498 ASSERT(false); | 499 RTC_NOTREACHED(); |
| 499 return false; | 500 return false; |
| 500 } | 501 } |
| 501 | 502 |
| 502 return flock(fileno(file_), LOCK_EX|LOCK_NB) == 0; | 503 return flock(fileno(file_), LOCK_EX|LOCK_NB) == 0; |
| 503 } | 504 } |
| 504 | 505 |
| 505 bool FileStream::Unlock() { | 506 bool FileStream::Unlock() { |
| 506 if (file_ == NULL) { | 507 if (file_ == NULL) { |
| 507 // Stream not open. | 508 // Stream not open. |
| 508 ASSERT(false); | 509 RTC_NOTREACHED(); |
| 509 return false; | 510 return false; |
| 510 } | 511 } |
| 511 | 512 |
| 512 return flock(fileno(file_), LOCK_UN) == 0; | 513 return flock(fileno(file_), LOCK_UN) == 0; |
| 513 } | 514 } |
| 514 | 515 |
| 515 #endif | 516 #endif |
| 516 | 517 |
| 517 void FileStream::DoClose() { | 518 void FileStream::DoClose() { |
| 518 fclose(file_); | 519 fclose(file_); |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1120 |
| 1120 if (data_len) { | 1121 if (data_len) { |
| 1121 *data_len = 0; | 1122 *data_len = 0; |
| 1122 } | 1123 } |
| 1123 return SR_SUCCESS; | 1124 return SR_SUCCESS; |
| 1124 } | 1125 } |
| 1125 | 1126 |
| 1126 /////////////////////////////////////////////////////////////////////////////// | 1127 /////////////////////////////////////////////////////////////////////////////// |
| 1127 | 1128 |
| 1128 } // namespace rtc | 1129 } // namespace rtc |
| OLD | NEW |