OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_DIR_READER_LINUX_H_ | 5 #ifndef BASE_DIR_READER_LINUX_H_ |
6 #define BASE_DIR_READER_LINUX_H_ | 6 #define BASE_DIR_READER_LINUX_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <fcntl.h> | 10 #include <fcntl.h> |
(...skipping 15 matching lines...) Expand all Loading... |
26 unsigned char d_type; | 26 unsigned char d_type; |
27 char d_name[0]; | 27 char d_name[0]; |
28 }; | 28 }; |
29 | 29 |
30 class DirReaderLinux { | 30 class DirReaderLinux { |
31 public: | 31 public: |
32 explicit DirReaderLinux(const char* directory_path) | 32 explicit DirReaderLinux(const char* directory_path) |
33 : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), | 33 : fd_(open(directory_path, O_RDONLY | O_DIRECTORY)), |
34 offset_(0), | 34 offset_(0), |
35 size_(0) { | 35 size_(0) { |
| 36 memset(buf_, 0, sizeof(buf_)); |
36 } | 37 } |
37 | 38 |
38 ~DirReaderLinux() { | 39 ~DirReaderLinux() { |
39 if (fd_ >= 0) { | 40 if (fd_ >= 0) { |
40 if (HANDLE_EINTR(close(fd_))) | 41 if (HANDLE_EINTR(close(fd_))) |
41 RAW_LOG(ERROR, "Failed to close directory handle"); | 42 RAW_LOG(ERROR, "Failed to close directory handle"); |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
45 bool IsValid() const { | 46 bool IsValid() const { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 const int fd_; | 90 const int fd_; |
90 unsigned char buf_[512]; | 91 unsigned char buf_[512]; |
91 size_t offset_, size_; | 92 size_t offset_, size_; |
92 | 93 |
93 DISALLOW_COPY_AND_ASSIGN(DirReaderLinux); | 94 DISALLOW_COPY_AND_ASSIGN(DirReaderLinux); |
94 }; | 95 }; |
95 | 96 |
96 } // namespace base | 97 } // namespace base |
97 | 98 |
98 #endif // BASE_DIR_READER_LINUX_H_ | 99 #endif // BASE_DIR_READER_LINUX_H_ |
OLD | NEW |