0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DirEntry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef HYPERSPACE_DIRENTRY_H
23 #define HYPERSPACE_DIRENTRY_H
24 
25 #include <string>
26 
27 namespace Hyperspace {
28 
29  /*
30  * Listing information for each node within a directory. A vector
31  * of these objects gets passed back to the application via a call to
32  * Readdir()
33  */
34  struct DirEntry {
36  std::string name;
38  bool is_dir;
39  };
40 
41  struct LtDirEntry {
42  bool operator()(const struct DirEntry &x, const struct DirEntry &y) const {
43  if (x.name == y.name)
44  return (int)x.is_dir < (int)y.is_dir;
45  return x.name < y.name;
46  }
47  };
48 
55  size_t encoded_length_dir_entry(const DirEntry &dir_entry);
56 
63  void encode_dir_entry(uint8_t **buf_ptr, const DirEntry &dir_entry);
64 
73  DirEntry &decode_dir_entry(const uint8_t **buf_ptr,
74  size_t *remaining_ptr, DirEntry &dir_entry);
75 
76 }
77 
78 #endif // HYPERSPACE_DIRENTRY_H
DirEntry & decode_dir_entry(const uint8_t **bufp, size_t *remainp, DirEntry &dir_entry)
Decodes (unserializes) a directory entry from a buffer.
Definition: DirEntry.cc:43
Hyperspace definitions
bool operator()(const struct DirEntry &x, const struct DirEntry &y) const
Definition: DirEntry.h:42
void encode_dir_entry(uint8_t **bufp, const DirEntry &dir_entry)
Encodes (serializes) the given directory entry to a buffer.
Definition: DirEntry.cc:37
Definition: DirEntry.h:34
bool is_dir
Boolean value indicating whether or not this entry is a directory.
Definition: DirEntry.h:38
size_t encoded_length_dir_entry(const DirEntry &dir_entry)
Returns the number of bytes required to encode (serialize) the given directory entry.
Definition: DirEntry.cc:33
Definition: DirEntry.h:41
std::string name
Directory entry name.
Definition: DirEntry.h:36