|
@@ -99,18 +99,15 @@ Folder &Folder::getFolder(unsigned long i) {
|
99
|
99
|
|
100
|
100
|
unsigned long Folder::countRecursiveItems() {
|
101
|
101
|
unsigned long count = fileCount();
|
102
|
|
-
|
103
|
|
- for (unsigned long i = 0; i < folderCount(); i++) {
|
|
102
|
+ for (unsigned long i = 0; i < folderCount(); i++)
|
104
|
103
|
count += getFolder(i).countRecursiveItems();
|
105
|
|
- }
|
106
|
|
-
|
107
|
104
|
return count;
|
108
|
105
|
}
|
109
|
106
|
|
110
|
107
|
void Folder::executeRemoveRecursiveItems(std::function<bool (File &f)> func) {
|
111
|
108
|
for (unsigned long i = 0; i < fileCount(); i++) {
|
112
|
109
|
if (func(getFile(i))) {
|
113
|
|
- files.erase(files.begin() + (long)i);
|
|
110
|
+ files.erase(files.begin() + (long)i--);
|
114
|
111
|
}
|
115
|
112
|
}
|
116
|
113
|
|
|
@@ -124,11 +121,13 @@ std::string Folder::getRecursiveItemName(unsigned long i) {
|
124
|
121
|
if (i < fileCount()) {
|
125
|
122
|
return getFile(i).getName();
|
126
|
123
|
} else {
|
|
124
|
+ unsigned long count = fileCount();
|
127
|
125
|
for (unsigned long n = 0; n < folderCount(); n++) {
|
128
|
|
- if ((i - fileCount()) < getFolder(n).countRecursiveItems()) {
|
|
126
|
+ if ((i - count) < getFolder(n).countRecursiveItems()) {
|
129
|
127
|
return getFolder(n).getName() + '/'
|
130
|
|
- + getFolder(n).getRecursiveItemName(i - fileCount());
|
|
128
|
+ + getFolder(n).getRecursiveItemName(i - count);
|
131
|
129
|
}
|
|
130
|
+ count += getFolder(n).countRecursiveItems();
|
132
|
131
|
}
|
133
|
132
|
}
|
134
|
133
|
|
|
@@ -142,10 +141,12 @@ File &Folder::getRecursiveItem(unsigned long i) {
|
142
|
141
|
if (i < fileCount()) {
|
143
|
142
|
return getFile(i);
|
144
|
143
|
} else {
|
|
144
|
+ unsigned long count = fileCount();
|
145
|
145
|
for (unsigned long n = 0; n < folderCount(); n++) {
|
146
|
|
- if ((i - fileCount()) < getFolder(n).countRecursiveItems()) {
|
147
|
|
- return getFolder(n).getRecursiveItem(i - fileCount());
|
|
146
|
+ if ((i - count) < getFolder(n).countRecursiveItems()) {
|
|
147
|
+ return getFolder(n).getRecursiveItem(i - count);
|
148
|
148
|
}
|
|
149
|
+ count += getFolder(n).countRecursiveItems();
|
149
|
150
|
}
|
150
|
151
|
}
|
151
|
152
|
|