1 /*****************************************************************************\
3 * Name : filename_tree *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 2004-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "filename_tree.h"
17 #include <structures/object_packers.h>
19 using namespace basis;
20 using namespace nodes;
21 using namespace structures;
23 namespace filesystem {
25 nodes::packable_tree *fname_tree_creator::create() { return new filename_tree; }
29 filename_tree::filename_tree() : _depth(0) {}
31 filename_tree::~filename_tree() { _dirname = ""; _files.reset(); }
33 int filename_tree::packed_size() const {
34 return PACKED_SIZE_INT32 + _dirname.packed_size() + _files.packed_size();
37 void filename_tree::pack(byte_array &packed_form) const {
38 structures::attach(packed_form, _depth);
39 _dirname.pack(packed_form);
40 _files.pack(packed_form);
43 bool filename_tree::unpack(byte_array &packed_form) {
44 if (!structures::detach(packed_form, _depth)) return false;
45 if (!_dirname.unpack(packed_form)) return false;
46 if (!_files.unpack(packed_form)) return false;