1 #ifndef FILENAME_LIST_CLASS
2 #define FILENAME_LIST_CLASS
4 /*****************************************************************************\
6 * Name : filename_list *
7 * Author : Chris Koeritz *
9 *******************************************************************************
10 * Copyright (c) 2005-$now By Author. This program is free software; you can *
11 * redistribute it and/or modify it under the terms of the GNU General Public *
12 * License as published by the Free Software Foundation; either version 2 of *
13 * the License or (at your option) any later version. This is online at: *
14 * http://www.fsf.org/copyleft/gpl.html *
15 * Please send any updates to: fred@gruntose.com *
16 \*****************************************************************************/
18 //! Implements a list of filenames.
20 This is based on an amorph so that adding to the list is efficient.
21 The underlying type held is actually a file_info rather than a filename.
22 This should not impose much extra overhead.
24 Note: this is a heavyweight header; it shouldn't be used in other headers.
27 #include "file_info.h"
29 #include <basis/contracts.h>
30 #include <structures/amorph.h>
32 namespace filesystem {
35 : public structures::amorph<file_info>, public virtual basis::packable
40 filename_list &operator =(const filename_list &to_copy);
42 int total_files() const;
43 //!< returns the number of files currently held in the list.
45 double total_size() const;
46 //!< returns the full size of all files listed.
48 bool calculate_progress(const filename &file, double current_offset,
49 int ¤t_file, double ¤t_size);
50 //!< given the last "file" and position, this returns current positioning.
51 /*!< the "current_file" is set to the index of the "file" in the list
52 (using 1-based numbering for a 1,2,3,... series), and the "current_size"
53 is set to the total amount of bytes processed so far. */
55 filename_list &operator = (const structures::string_array &to_copy);
57 void fill(structures::string_array &to_fill);
58 //!< stuffs the array "to_fill" with the filesnames from our list.
60 const file_info *find(const filename &to_check) const;
61 //!< locates the record of information for the filename "to_check".
62 /*!< do not modify the returned object. it contains the current state
63 of the file in question. if the file wasn't in the list, then NULL_POINTER is
66 int locate(const filename &to_find) const;
67 //! finds the index for "to_find" or returns a negative number.
69 bool member(const filename &to_check) const;
70 //!< returns true if "to_check" is listed here.
72 bool member_with_state(const file_info &to_check, file_info::file_similarity comparison_method);
73 //!< returns true if the file "to_check" exists in the list with appropriate equivalence.
74 /*!< this will fail if the file name isn't present at all. and then it will also not return
75 true if the size is different (when EQUAL_FILESIZE is true), when the timestamp is different
76 (when EQUAL_TIMESTAMP is true), and when the checksum is different (you get the idea). */
78 //! max_lines is the maximum number of lines to print into the string.
79 basis::astring text_form(int max_lines = MAXINT32) const;
81 virtual int packed_size() const;
83 virtual void pack(basis::byte_array &packed_form) const;
85 virtual bool unpack(basis::byte_array &packed_form);