forked from andig/canprogs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVList.h
executable file
·141 lines (124 loc) · 3.64 KB
/
VList.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
*
* Copyright (C) 2015 Jürg Müller, CH-5524
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/ .
*/
#if !defined(VList_H)
#define VList_H
#include <time.h>
#include "KStream.h"
class KSortItem
{
public:
const char * Name;
KSortItem() { Name = NULL; }
~KSortItem();
void SetName(const char * NewName);
};
class KSortItemList
{
private:
bool IsSorted;
unsigned SortItemCount;
unsigned MaxItemCount;
const KSortItem ** SortItemList;
public:
KSortItemList() { IsSorted = false; SortItemCount = 0; MaxItemCount = 0; SortItemList = NULL; }
~KSortItemList();
void Clear();
void Reset();
unsigned GetCount() const { return SortItemCount; }
const KSortItem * GetItem(unsigned Index) const;
const char * GetName(unsigned Index) const;
unsigned AppendItem(const KSortItem * Item);
bool Append(const char * NewName);
int FindItem(const char * FindName) const;
virtual int Compare(unsigned Index, const char * FindName) const;
virtual int Compare(unsigned Index1, unsigned Index2) const;
bool ReadFile(const char * Filename);
bool Sort();
};
/*
class VList : public KStream
{
private:
bool is_sorted;
public:
unsigned string_count;
VList()
{
Init();
}
void Init()
{
string_count = 0;
is_sorted = false;
mSize = 0;
}
bool AddString(const char * string);
bool Sort();
const char * GetString(unsigned index);
int FindString(const char * string) const;
bool DeleteString(unsigned index);
bool InsertString(unsigned index, const char *string);
virtual bool ReadFile(const char * Filename, unsigned long Max = 0);
virtual bool SaveFile(const char * Filename) const;
};
*/
class VExploreDir
{
public:
int Level;
bool dir_first;
bool use_hidden_files;
char FromPath[2048];
char RelPath[2048];
VExploreDir()
{
Level = 0;
RelPath[0] = 0;
dir_first = true;
use_hidden_files = false;
}
virtual bool ExploreFile(const char * Filename) = 0;
virtual bool ExploreDir(const char * DirName);
bool ExploreSortedList(bool dirs);
bool Start(const char * StartFromDir);
bool Start(const char StartFromDirList[][1000]);
};
class VListFileDir
{
private:
void * dir;
long PathLen;
#if defined(__VC__) || defined(_MSC_VER)
void * FindFileData;
bool FirstRead;
#endif
public:
char Name[256];
char FullPath[2048];
long mode;
long size;
time_t time;
VListFileDir();
~VListFileDir();
virtual bool Open(const char * Path);
bool Open(const char * Path, const char * RelPath);
virtual void Close();
virtual bool Next();
bool IsFile() const;
bool IsDir() const;
};
#endif