1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LIBRARIES_NACL_IO_GETDENTS_HELPER_H_ 6 #define LIBRARIES_NACL_IO_GETDENTS_HELPER_H_ 7 8 #include <vector> 9 10 #include "nacl_io/error.h" 11 #include "nacl_io/osdirent.h" 12 13 namespace nacl_io { 14 15 class GetDentsHelper { 16 public: 17 // Initialize the helper without any defaults. 18 GetDentsHelper(); 19 GetDentsHelper(ino_t curdir_ino, ino_t parentdir_ino); 20 21 void Reset(); 22 void AddDirent(ino_t ino, const char* name, size_t namelen); 23 Error GetDents(size_t offs, dirent* pdir, size_t size, int* out_bytes) const; 24 25 private: 26 void Initialize(); 27 28 std::vector<dirent> dirents_; 29 ino_t curdir_ino_; 30 ino_t parentdir_ino_; 31 bool init_defaults_; 32 }; 33 34 } // namespace nacl_io 35 36 #endif // LIBRARIES_NACL_IO_GETDENTS_HELPER_H_ 37