forked from sarnold/cccc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileList.h
103 lines (84 loc) · 2.24 KB
/
FileList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef FILELIST_H
#define FILELIST_H
#include <afxtempl.h>
///
class File
{
friend class FileList;
public:
File();
static bool Create(File& file, const CString& rootPath, CString filename, bool resolve = true);
void* GetParent(void) const;
const CString& GetShortName(void) const;
const CString& GetTitle(void) const;
const CString& GetExt(void) const;
const CString& GetPath(void) const;
void SetParent(void* parent);
void SetShortName(const CString& shortName);
void SetTitle(const CString& title);
void SetExt(const CString& ext);
void SetPath(const CString& path);
void SetDuplicate(bool duplicate);
protected:
void* m_parent;
CString m_shortName;
CString m_title;
CString m_ext;
CString m_path;
bool m_duplicate;
}; //File
class FileList
{
public:
FileList();
~FileList();
// Attributes
int GetCount(void) const;
// Operations
File& Add(const File& file);
void RemoveAll(void);
void Sort(void);
File& operator[](int index) const;
int FindExact(File& file) const;
int FindNext(int startPos, File& file) const;
int FindPrevious(int startPos, File& file) const;
struct Info
{
POSITION m_pos;
File* m_file;
};
protected:
void BuildArray(void);
CList<File, File&> m_fileList;
CArray<Info, Info&> m_fileArray;
};
inline File::File()
: m_duplicate(false)
{ }
inline void* File::GetParent(void) const
{ return m_parent; }
inline const CString& File::GetShortName(void) const
{ return m_shortName; }
inline const CString& File::GetTitle(void) const
{ return m_title; }
inline const CString& File::GetExt(void) const
{ return m_ext; }
inline const CString& File::GetPath(void) const
{ return m_path; }
inline void File::SetParent(void* parent)
{ m_parent = parent; }
inline void File::SetShortName(const CString& shortName)
{ m_shortName = shortName; }
inline void File::SetTitle(const CString& title)
{ m_title = title; }
inline void File::SetExt(const CString& ext)
{ m_ext = ext; }
inline void File::SetPath(const CString& path)
{ m_path = path; }
inline void File::SetDuplicate(bool duplicate)
{ m_duplicate = duplicate; }
inline int FileList::GetCount(void) const
{ return m_fileList.GetCount(); }
inline File& FileList::operator[](int index) const
{ return *m_fileArray[index].m_file; }
#endif FILELIST_H