39 #include <boost/algorithm/string.hpp>
65 last_modification_time =
decode_i32(bufp, remainp);
72 std::vector<Dirent> &listing) {
73 const uint8_t *decode_ptr = event_ptr->payload;
74 size_t decode_remain = event_ptr->payload_len;
76 int error =
decode_i32(&decode_ptr, &decode_remain);
81 uint32_t len =
decode_i32(&decode_ptr, &decode_remain);
86 for (uint32_t i = 0; i < len; i++) {
87 entry.
decode(&decode_ptr, &decode_remain);
88 listing.push_back(entry);
95 const uint8_t *decode_ptr = event_ptr->payload;
96 size_t decode_remain = event_ptr->payload_len;
98 int error =
decode_i32(&decode_ptr, &decode_remain);
109 const uint8_t *decode_ptr = event_ptr->payload;
110 size_t decode_remain = event_ptr->payload_len;
112 return decode_i32(&decode_ptr, &decode_remain);
117 while (s.size() > 1) {
118 if (s[s.size()-1] == separator)
119 s.resize(s.size() - 1);
128 if (name.size() == 1 && name[0] == separator)
132 std::string::size_type cur = name.length();
133 while (cur > 0 && name[cur - 1] == separator)
138 std::string::size_type pos = name.rfind(separator);
140 if (pos == std::string::npos)
142 else if (pos == 0 && name.length() == 1 && name[0] == separator)
144 else if (pos == 0 && name.length() > 1 && name[0] == separator)
155 if (name.size() == 1 && name[0] == separator)
159 std::string::size_type cur = name.length();
160 while (cur > 0 && name[cur - 1] == separator)
165 std::string::size_type pos = name.rfind(separator);
168 if (pos == std::string::npos)
170 else if (pos == 0 && name.length() == 1 && name[0] == separator)
173 name = name.substr(pos + 1);
181 boost::trim_if(str, boost::is_any_of(
"\"'"));
182 if (!strcasecmp(str.c_str(),
"FLUSH"))
184 else if (!strcasecmp(str.c_str(),
"SYNC"))
186 else if (!strcasecmp(str.c_str(),
"NONE"))
char * decode_vstr(const uint8_t **bufp, size_t *remainp)
Decode a vstr (vint64, data, null).
static String & remove_trailing_duplicates(String &s, char separator)
virtual bool decode_response_exists(EventPtr &event)=0
Decodes the response from an exists request.
Abstract base class for a filesystem.
std::string String
A String is simply a typedef to std::string.
Filesystem::Flags convert(std::string str)
Converts string mnemonic to corresponding Filesystem::Flags value.
Flags
Enumeration type for append flags.
Po::typed_value< String > * str(String *v=0)
static int decode_response(EventPtr &event)
Decodes the response from an request that only returns an error code.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
size_t encoded_length_vstr(size_t len)
Computes the encoded length of vstr (vint64, data, null)
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Decode a 64-bit integer in little-endian order.
virtual void decode_response_readdir(EventPtr &event, std::vector< Dirent > &listing)=0
Decodes the response from a readdir request.
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
void encode_i64(uint8_t **bufp, uint64_t val)
Encode a 64-bit integer in little-endian order.
Functions to serialize/deserialize primitives to/from a memory buffer.
static String basename(String name, char separator= '/')
A posix-compliant basename() which strips directory names from a filename.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
void encode_vstr(uint8_t **bufp, const void *buf, size_t len)
Encode a buffer as variable length string (vint64, data, null)
void encode_bool(uint8_t **bufp, bool bval)
Encodes a boolean into the given buffer.
void encode_internal(uint8_t **bufp) const override
Writes serialized representation of object to a buffer.
#define HT_THROWF(_code_, _fmt_,...)
size_t encoded_length_internal() const override
Returns internal serialized length.
static String dirname(String name, char separator= '/')
A posix-compliant dirname() which strips the last component from a file name.
uint8_t encoding_version() const override
Returns encoding version.
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
void decode_internal(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Reads serialized representation of object from a buffer.