ManaPlus
fs.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2013-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include "fs/virtfs/fs.h"
23 
24 #include "fs/files.h"
25 #include "fs/paths.h"
26 
27 #include "fs/virtfs/direntry.h"
28 #include "fs/virtfs/file.h"
29 #include "fs/virtfs/fsdir.h"
30 #include "fs/virtfs/fsfuncs.h"
31 #include "fs/virtfs/fszip.h"
32 #include "fs/virtfs/list.h"
33 #include "fs/virtfs/zipentry.h"
34 #include "fs/virtfs/zipreader.h"
35 
36 #include "utils/checkutils.h"
37 #include "utils/foreach.h"
38 #include "utils/stdmove.h"
39 #include "utils/stringutils.h"
40 
41 #include "debug.h"
42 
43 const char *dirSeparator = nullptr;
44 
45 #ifdef UNITTESTS
46 #define reportNonTests(a, b) logger->log(a, b);
47 #else // UNITTESTS
48 #define reportNonTests(a, b) reportAlways(a, b)
49 #endif // UNITTESTS
50 
51 namespace VirtFs
52 {
53  namespace
54  {
55  STD_VECTOR<FsEntry*> mEntries;
56  } // namespace
57 
58  void init(const std::string &restrict name)
59  {
61  FsDir::init(name);
62  FsZip::init();
63  }
64 
66  {
67 #ifdef WIN32
68  dirSeparator = "\\";
69 #else // WIN32
70  dirSeparator = "/";
71 #endif // WIN32
72  }
73 
74  const char *getDirSeparator()
75  {
76  return dirSeparator;
77  }
78 
79  const char *getBaseDir()
80  {
81  return FsDir::getBaseDir();
82  }
83 
84  const char *getUserDir()
85  {
86  return FsDir::getUserDir();
87  }
88 
89  STD_VECTOR<FsEntry*> &getEntries()
90  {
91  return mEntries;
92  }
93 
94  FsEntry *searchByRootInternal(const std::string &restrict root,
95  const std::string &restrict subDir)
96  {
97  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
98  {
99  const FsEntry *const entry = *it;
100  if (entry->root == root &&
101  entry->subDir == subDir)
102  {
103  return *it;
104  }
105  }
106  return nullptr;
107  }
108 
109  FsEntry *searchByTypeInternal(const std::string &restrict root,
110  const FsEntryTypeT type)
111  {
112  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
113  {
114  const FsEntry *const entry = *it;
115  if (entry->root == root &&
116  entry->type == type)
117  {
118  return *it;
119  }
120  }
121  return nullptr;
122  }
123 
124  bool exists(std::string name)
125  {
126  prepareFsPath(name);
127  if (checkPath(name) == false)
128  {
129  reportAlways("FsDir::exists invalid path: %s",
130  name.c_str())
131  return false;
132  }
133 
134  std::string rootDir = name;
135  if (findLast(rootDir, std::string(dirSeparator)) == false)
136  rootDir += dirSeparator;
137 
138  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
139  {
140  FsEntry *const entry = *it;
141  if (entry->funcs->exists(entry, name, rootDir) == true)
142  return true;
143  }
144  return false;
145  }
146 
147  List *enumerateFiles(std::string dirName)
148  {
149  List *const list = new List;
150  prepareFsPath(dirName);
151  if (checkPath(dirName) == false)
152  {
153  reportAlways("VirtFs::enumerateFiles invalid path: %s",
154  dirName.c_str())
155  return list;
156  }
157 
158  std::string rootDir = STD_MOVE(dirName);
159  if (findLast(rootDir, std::string(dirSeparator)) == false)
160  rootDir += dirSeparator;
161  StringVect &names = list->names;
162 
163  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
164  {
165  FsEntry *const entry = *it;
166  entry->funcs->enumerate(entry, rootDir, names);
167  }
168 
169  return list;
170  }
171 
172  void getFiles(std::string dirName,
173  StringVect &list)
174  {
175  prepareFsPath(dirName);
176  if (checkPath(dirName) == false)
177  {
178  reportAlways("VirtFs::enumerateFiles invalid path: %s",
179  dirName.c_str())
180  return;
181  }
182 
183  std::string rootDir = STD_MOVE(dirName);
184  if (findLast(rootDir, std::string(dirSeparator)) == false)
185  rootDir += dirSeparator;
186 
187  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
188  {
189  FsEntry *const entry = *it;
190  entry->funcs->getFiles(entry, rootDir, list);
191  }
192  }
193 
194  void getFilesWithDir(std::string dirName,
195  StringVect &list)
196  {
197  prepareFsPath(dirName);
198  if (checkPath(dirName) == false)
199  {
200  reportAlways("VirtFs::enumerateFiles invalid path: %s",
201  dirName.c_str())
202  return;
203  }
204 
205  std::string rootDir = STD_MOVE(dirName);
206  if (findLast(rootDir, std::string(dirSeparator)) == false)
207  rootDir += dirSeparator;
208 
209  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
210  {
211  FsEntry *const entry = *it;
212  entry->funcs->getFilesWithDir(entry, rootDir, list);
213  }
214  }
215 
216 
217  void getDirs(std::string dirName,
218  StringVect &list)
219  {
220  prepareFsPath(dirName);
221  if (checkPath(dirName) == false)
222  {
223  reportAlways("VirtFs::enumerateFiles invalid path: %s",
224  dirName.c_str())
225  return;
226  }
227 
228  std::string rootDir = STD_MOVE(dirName);
229  if (findLast(rootDir, std::string(dirSeparator)) == false)
230  rootDir += dirSeparator;
231 
232  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
233  {
234  FsEntry *const entry = *it;
235  entry->funcs->getDirs(entry, rootDir, list);
236  }
237  }
238 
239  bool isDirectory(std::string name)
240  {
241  prepareFsPath(name);
242  if (checkPath(name) == false)
243  {
244  reportAlways("VirtFs::isDirectory invalid path: %s",
245  name.c_str())
246  return false;
247  }
248  std::string dirName = STD_MOVE(name);
249  if (findLast(dirName, std::string(dirSeparator)) == false)
250  dirName += dirSeparator;
251 
252  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
253  {
254  FsEntry *const entry = *it;
255  bool isDirFlag(false);
256  if (entry->funcs->isDirectory(entry, dirName, isDirFlag) == true)
257  {
258  return isDirFlag;
259  }
260  }
261  return false;
262  }
263 
264  bool isSymbolicLink(const std::string &restrict name)
265  {
266  return FsDir::isSymbolicLink(name);
267  }
268 
269  void freeList(List *restrict const handle)
270  {
271  delete handle;
272  }
273 
274  File *openRead(std::string filename)
275  {
276  prepareFsPath(filename);
277  if (checkPath(filename) == false)
278  {
279  reportAlways("VirtFs::openRead invalid path: %s",
280  filename.c_str())
281  return nullptr;
282  }
283  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
284  {
285  FsEntry *const entry = *it;
286  File *const file = entry->funcs->openRead(entry, filename);
287  if (file != nullptr)
288  return file;
289  }
290  return nullptr;
291  }
292 
293  File *openWrite(std::string filename)
294  {
295  prepareFsPath(filename);
296  if (checkPath(filename) == false)
297  {
298  reportAlways("VirtFs::openWrite invalid path: %s",
299  filename.c_str())
300  return nullptr;
301  }
302  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
303  {
304  FsEntry *const entry = *it;
305  File *const file = entry->funcs->openWrite(entry, filename);
306  if (file != nullptr)
307  return file;
308  }
309  return nullptr;
310  }
311 
312  File *openAppend(std::string filename)
313  {
314  prepareFsPath(filename);
315  if (checkPath(filename) == false)
316  {
317  reportAlways("VirtFs::openAppend invalid path: %s",
318  filename.c_str())
319  return nullptr;
320  }
321  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
322  {
323  FsEntry *const entry = *it;
324  File *const file = entry->funcs->openAppend(entry, filename);
325  if (file != nullptr)
326  return file;
327  }
328  return nullptr;
329  }
330 
331  bool setWriteDir(const std::string &restrict newDir)
332  {
333  return FsDir::setWriteDir(newDir);
334  }
335 
336  void addEntry(FsEntry *const entry,
337  const Append append)
338  {
339  if (append == Append_true)
340  mEntries.push_back(entry);
341  else
342  mEntries.insert(mEntries.begin(), entry);
343  }
344 
345  bool mountDirInternal(const std::string &restrict newDir,
346  std::string subDir,
347  const Append append)
348  {
349  if (newDir.find(".zip") != std::string::npos)
350  {
351  reportAlways("Called FsDir::mount with zip archive")
352  return false;
353  }
354  std::string rootDir = newDir;
355  if (findLast(rootDir, std::string(dirSeparator)) == false)
356  rootDir += dirSeparator;
357  if (subDir == dirSeparator)
358  {
359  subDir.clear();
360  }
361  else if (!subDir.empty() &&
362  findLast(subDir, std::string(dirSeparator)) == false)
363  {
364  subDir += dirSeparator;
365  }
366  const FsEntry *const entry = searchByRootInternal(rootDir, subDir);
367  if (entry != nullptr)
368  {
369  reportAlways("VirtFs::mount already exists: %s",
370  newDir.c_str())
371  return false;
372  }
373  if (subDir.empty())
374  {
375  logger->log("Add virtual directory: " + newDir);
376  }
377  else
378  {
379  logger->log("Add virtual directory: %s with dir %s",
380  newDir.c_str(),
381  subDir.c_str());
382  }
383 
384  addEntry(new DirEntry(newDir,
385  rootDir,
386  subDir,
387  rootDir + subDir,
388  FsDir::getFuncs()),
389  append);
390  return true;
391  }
392 
393  bool mountDir(std::string newDir,
394  const Append append)
395  {
396  prepareFsPath(newDir);
397  if (Files::existsLocal(newDir) == false)
398  {
399  reportNonTests("VirtFs::mount directory not exists: %s",
400  newDir.c_str())
401  return false;
402  }
403  return mountDirInternal(newDir, dirSeparator, append);
404  }
405 
406  bool mountDir2(std::string newDir,
407  std::string subDir,
408  const Append append)
409  {
410  prepareFsPath(newDir);
411  prepareFsPath(subDir);
412  if (Files::existsLocal(newDir) == false)
413  {
414  reportNonTests("VirtFs::mount directory not exists: %s",
415  newDir.c_str())
416  return false;
417  }
418  return mountDirInternal(newDir, subDir, append);
419  }
420 
421  bool mountDirSilent(std::string newDir,
422  const Append append)
423  {
424  prepareFsPath(newDir);
425  if (Files::existsLocal(newDir) == false)
426  {
427  logger->log("VirtFs::mount directory not exists: %s",
428  newDir.c_str());
429  return false;
430  }
431  return mountDirInternal(newDir, std::string(), append);
432  }
433 
434  bool mountDirSilent2(std::string newDir,
435  std::string subDir,
436  const Append append)
437  {
438  prepareFsPath(newDir);
439  prepareFsPath(subDir);
440  if (Files::existsLocal(newDir) == false)
441  {
442  logger->log("VirtFs::mount directory not exists: %s",
443  newDir.c_str());
444  return false;
445  }
446  return mountDirInternal(newDir, subDir, append);
447  }
448 
449 #ifdef UNITTESTS
450  bool mountDirSilentTest(std::string newDir,
451  const Append append)
452  {
453  prepareFsPath(newDir);
454  if (Files::existsLocal(newDir) == false)
455  {
456  logger->log("VirtFs::mount directory not exists: %s",
457  newDir.c_str());
458  }
459  return mountDirInternal(newDir, std::string(), append);
460  }
461 
462  bool mountDirSilentTest2(std::string newDir,
463  std::string subDir,
464  const Append append)
465  {
466  prepareFsPath(newDir);
467  prepareFsPath(subDir);
468  if (Files::existsLocal(newDir) == false)
469  {
470  logger->log("VirtFs::mount directory not exists: %s",
471  newDir.c_str());
472  }
473  return mountDirInternal(newDir, subDir, append);
474  }
475 #endif // UNITTESTS
476 
477  bool unmountDirInternal(std::string oldDir,
478  std::string subDir)
479  {
480  if (findLast(oldDir, std::string(dirSeparator)) == false)
481  oldDir += dirSeparator;
482  if (subDir == dirSeparator)
483  {
484  subDir.clear();
485  }
486  else if (!subDir.empty() &&
487  findLast(subDir, std::string(dirSeparator)) == false)
488  {
489  subDir += dirSeparator;
490  }
491  FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
492  {
493  FsEntry *const entry = *it;
494  if (entry->root == oldDir &&
495  entry->type == FsEntryType::Dir &&
496  entry->subDir == subDir)
497  {
498  DirEntry *const dirEntry = static_cast<DirEntry*>(
499  entry);
500  if (subDir.empty())
501  {
502  logger->log("Remove virtual directory: " + oldDir);
503  }
504  else
505  {
506  logger->log("Remove virtual directory: %s with dir %s",
507  oldDir.c_str(),
508  subDir.c_str());
509  }
510  mEntries.erase(it);
511  delete dirEntry;
512  return true;
513  }
514  }
515  return false;
516  }
517 
518  bool unmountDir(std::string oldDir)
519  {
520  prepareFsPath(oldDir);
521  if (oldDir.find(".zip") != std::string::npos)
522  {
523  reportAlways("Called unmount with zip archive")
524  return false;
525  }
526  if (unmountDirInternal(oldDir, std::string()) == false)
527  {
528  reportAlways("VirtFs::unmountDir not exists: %s",
529  oldDir.c_str())
530  return false;
531  }
532  return true;
533  }
534 
535  bool unmountDir2(std::string oldDir,
536  std::string subDir)
537  {
538  prepareFsPath(oldDir);
539  if (oldDir.find(".zip") != std::string::npos)
540  {
541  reportAlways("Called unmount with zip archive")
542  return false;
543  }
544  prepareFsPath(subDir);
545  if (unmountDirInternal(oldDir, subDir) == false)
546  {
547  reportAlways("VirtFs::unmountDir not exists: %s",
548  oldDir.c_str())
549  return false;
550  }
551  return true;
552  }
553 
554  bool unmountDirSilent(std::string oldDir)
555  {
556  prepareFsPath(oldDir);
557  if (oldDir.find(".zip") != std::string::npos)
558  {
559  reportAlways("Called unmount with zip archive")
560  return false;
561  }
562  if (unmountDirInternal(oldDir, std::string()) == false)
563  {
564  logger->log("VirtFs::unmountDir not exists: %s",
565  oldDir.c_str());
566  return false;
567  }
568  return true;
569  }
570 
571  bool unmountDirSilent2(std::string oldDir,
572  std::string subDir)
573  {
574  prepareFsPath(oldDir);
575  if (oldDir.find(".zip") != std::string::npos)
576  {
577  reportAlways("Called unmount with zip archive")
578  return false;
579  }
580  prepareFsPath(subDir);
581  if (unmountDirInternal(oldDir, subDir) == false)
582  {
583  logger->log("VirtFs::unmountDir not exists: %s",
584  oldDir.c_str());
585  return false;
586  }
587  return true;
588  }
589 
590  bool mountZip(std::string newDir,
591  const Append append)
592  {
593  prepareFsPath(newDir);
594  if (Files::existsLocal(newDir) == false)
595  {
596  reportNonTests("FsZip::mount file not exists: %s",
597  newDir.c_str())
598  return false;
599  }
600  if (findLast(newDir, ".zip") == false)
601  {
602  reportAlways("Called VirtFs::mount without "
603  "zip archive")
604  return false;
605  }
606  if (searchByRootInternal(newDir, std::string()) != nullptr)
607  {
608  reportAlways("FsZip::mount already exists: %s",
609  newDir.c_str())
610  return false;
611  }
612  ZipEntry *const entry = new ZipEntry(newDir,
613  std::string(),
614  FsZip::getFuncs());
615  if (ZipReader::readArchiveInfo(entry) == false)
616  {
617  delete entry;
618  return false;
619  }
620 
621  logger->log("Add virtual zip: " + newDir);
622  addEntry(entry, append);
623  return true;
624  }
625 
626  bool mountZip2(std::string newDir,
627  std::string subDir,
628  const Append append)
629  {
630  prepareFsPath(newDir);
631  if (Files::existsLocal(newDir) == false)
632  {
633  reportNonTests("FsZip::mount file not exists: %s",
634  newDir.c_str())
635  return false;
636  }
637  if (findLast(newDir, ".zip") == false)
638  {
639  reportAlways("Called VirtFs::mount without "
640  "zip archive")
641  return false;
642  }
643  prepareFsPath(subDir);
644  if (subDir == dirSeparator)
645  {
646  subDir.clear();
647  }
648  else if (!subDir.empty() &&
649  findLast(subDir, std::string(dirSeparator)) == false)
650  {
651  subDir += dirSeparator;
652  }
653  if (searchByRootInternal(newDir, subDir) != nullptr)
654  {
655  reportAlways("FsZip::mount already exists: %s",
656  newDir.c_str())
657  return false;
658  }
659  ZipEntry *const entry = new ZipEntry(newDir,
660  subDir,
661  FsZip::getFuncs());
662  if (ZipReader::readArchiveInfo(entry) == false)
663  {
664  delete entry;
665  return false;
666  }
667 
668  logger->log("Add virtual zip: %s with dir %s",
669  newDir.c_str(),
670  subDir.c_str());
671  addEntry(entry, append);
672  return true;
673  }
674 
675  bool unmountZip(std::string oldDir)
676  {
677  prepareFsPath(oldDir);
678  if (findLast(oldDir, ".zip") == false)
679  {
680  reportAlways("Called unmount without zip archive")
681  return false;
682  }
683  FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
684  {
685  FsEntry *const entry = *it;
686  if (entry->root == oldDir &&
687  entry->type == FsEntryType::Zip &&
688  entry->subDir.empty())
689  {
690  ZipEntry *const zipEntry = static_cast<ZipEntry*>(
691  entry);
692  logger->log("Remove virtual zip: " + oldDir);
693  mEntries.erase(it);
694  delete zipEntry;
695  return true;
696  }
697  }
698 
699  reportAlways("VirtFs::unmountZip not exists: %s",
700  oldDir.c_str())
701  return false;
702  }
703 
704  bool unmountZip2(std::string oldDir,
705  std::string subDir)
706  {
707  prepareFsPath(oldDir);
708  if (findLast(oldDir, ".zip") == false)
709  {
710  reportAlways("Called unmount without zip archive")
711  return false;
712  }
713  prepareFsPath(subDir);
714  if (subDir == dirSeparator)
715  {
716  subDir.clear();
717  }
718  else if (!subDir.empty() &&
719  findLast(subDir, std::string(dirSeparator)) == false)
720  {
721  subDir += dirSeparator;
722  }
723  FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
724  {
725  FsEntry *const entry = *it;
726  if (entry->root == oldDir &&
727  entry->type == FsEntryType::Zip &&
728  entry->subDir == subDir)
729  {
730  ZipEntry *const zipEntry = static_cast<ZipEntry*>(
731  entry);
732  logger->log("Remove virtual zip: %s with dir %s",
733  oldDir.c_str(),
734  subDir.c_str());
735  mEntries.erase(it);
736  delete zipEntry;
737  return true;
738  }
739  }
740 
741  reportAlways("VirtFs::unmountZip not exists: %s",
742  oldDir.c_str())
743  return false;
744  }
745 
746  std::string getRealDir(std::string fileName)
747  {
749  if (checkPath(fileName) == false)
750  {
751  reportAlways("FsDir::getRealDir invalid path: %s",
752  fileName.c_str())
753  return std::string();
754  }
755 
756  std::string rootDir = fileName;
757  if (findLast(rootDir, std::string(dirSeparator)) == false)
758  rootDir += dirSeparator;
759 
760  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
761  {
762  FsEntry *const entry = *it;
763  std::string realDir;
764  if (entry->funcs->getRealDir(entry,
765  fileName,
766  rootDir,
767  realDir) == true)
768  {
769  return realDir;
770  }
771  }
772  return std::string();
773  }
774 
775  bool mkdir(const std::string &restrict dirname)
776  {
777  return FsDir::mkdir(dirname);
778  }
779 
780  bool remove(const std::string &restrict filename)
781  {
782  return FsDir::remove(filename);
783  }
784 
785  bool deinit()
786  {
787  FsDir::deinit();
788  FsZip::deinit();
789  FOR_EACH (STD_VECTOR<FsEntry*>::iterator, it, mEntries)
790  {
791  FsEntry *const entry = *it;
792  if (entry->type == FsEntryType::Dir)
793  delete static_cast<DirEntry*>(entry);
794  else if (entry->type == FsEntryType::Zip)
795  delete static_cast<ZipEntry*>(entry);
796  else
797  delete entry;
798  }
799  mEntries.clear();
800  return true;
801  }
802 
803  void permitLinks(const bool val)
804  {
805  FsDir::permitLinks(val);
806  }
807 
808  int close(File *restrict const file)
809  {
810  if (file == nullptr)
811  return 0;
812  return file->funcs->close(file);
813  }
814 
815  int64_t read(File *restrict const file,
816  void *restrict const buffer,
817  const uint32_t objSize,
818  const uint32_t objCount)
819  {
820  return file->funcs->read(file,
821  buffer,
822  objSize,
823  objCount);
824  }
825 
826  int64_t write(File *restrict const file,
827  const void *restrict const buffer,
828  const uint32_t objSize,
829  const uint32_t objCount)
830  {
831  return file->funcs->write(file,
832  buffer,
833  objSize,
834  objCount);
835  }
836 
837  int64_t fileLength(File *restrict const file)
838  {
839  return file->funcs->fileLength(file);
840  }
841 
842  int64_t tell(File *restrict const file)
843  {
844  return file->funcs->tell(file);
845  }
846 
847  int seek(File *restrict const file,
848  const uint64_t pos)
849  {
850  return file->funcs->seek(file,
851  pos);
852  }
853 
854  int eof(File *restrict const file)
855  {
856  return file->funcs->eof(file);
857  }
858 
859  const char *loadFile(std::string filename,
860  int &restrict fileSize)
861  {
862  prepareFsPath(filename);
863  if (checkPath(filename) == false)
864  {
865  reportAlways("VirtFs::loadFile invalid path: %s",
866  filename.c_str())
867  return nullptr;
868  }
869  FOR_EACH (STD_VECTOR<FsEntry*>::const_iterator, it, mEntries)
870  {
871  FsEntry *const entry = *it;
872  const char *const buf = entry->funcs->loadFile(entry,
873  filename,
874  fileSize);
875  if (buf != nullptr)
876  return buf;
877  }
878  return nullptr;
879  }
880 
881 } // namespace VirtFs
const bool Append_true
Definition: append.h:30
bool Append
Definition: append.h:30
#define reportAlways(...)
Definition: checkutils.h:253
void log(const char *const log_text,...)
Definition: logger.cpp:269
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
const char * dirSeparator
Definition: fs.cpp:43
#define reportNonTests(a, b)
Definition: fs.cpp:48
FsEntryType ::T FsEntryTypeT
Definition: fsentrytype.h:32
#define restrict
Definition: localconsts.h:165
Logger * logger
Definition: logger.cpp:89
bool existsLocal(const std::string &path)
Definition: files.cpp:209
const char * getBaseDir()
Definition: fsdir.cpp:160
bool isSymbolicLink(std::string name)
Definition: fsdir.cpp:250
bool setWriteDir(std::string newDir)
Definition: fsdir.cpp:276
const char * getUserDir()
Definition: fsdir.cpp:165
void deinit()
Definition: fsdir.cpp:101
void init(const std::string &name)
Definition: fsdir.cpp:115
FsFuncs * getFuncs()
Definition: fsdir.cpp:155
void permitLinks(const bool val)
Definition: fsdir.cpp:307
bool remove(std::string filename)
Definition: fsdir.cpp:296
bool mkdir(std::string dirname)
Definition: fsdir.cpp:285
void deinit()
Definition: fszip.cpp:56
FsFuncs * getFuncs()
Definition: fszip.cpp:51
void init()
Definition: fszip.cpp:60
bool readArchiveInfo(ZipEntry *entry)
Definition: zipreader.cpp:75
std::vector< FsEntry * > mEntries
Definition: fs.cpp:55
File * openRead(std::string filename)
Definition: fs.cpp:274
bool deinit()
Definition: fs.cpp:785
void getDirs(std::string dirName, StringVect &list)
Definition: fs.cpp:217
void init(const std::string &name)
Definition: fs.cpp:58
bool mkdir(const std::string &dirname)
Definition: fs.cpp:775
void updateDirSeparator()
Definition: fs.cpp:65
int64_t fileLength(File *const file)
Definition: fs.cpp:837
bool mountDir2(std::string newDir, std::string subDir, const Append append)
Definition: fs.cpp:406
std::string getRealDir(std::string fileName)
Definition: fs.cpp:746
bool remove(const std::string &filename)
Definition: fs.cpp:780
bool unmountDirSilent2(std::string oldDir, std::string subDir)
Definition: fs.cpp:571
int64_t tell(File *const file)
Definition: fs.cpp:842
bool mountDirSilent2(std::string newDir, std::string subDir, const Append append)
Definition: fs.cpp:434
const char * getBaseDir()
Definition: fs.cpp:79
void freeList(List *const handle)
Definition: fs.cpp:269
bool isSymbolicLink(const std::string &name)
Definition: fs.cpp:264
int64_t write(File *const file, const void *const buffer, const uint32_t objSize, const uint32_t objCount)
Definition: fs.cpp:826
bool mountDirInternal(const std::string &newDir, std::string subDir, const Append append)
Definition: fs.cpp:345
bool unmountDirSilent(std::string oldDir)
Definition: fs.cpp:554
int close(File *const file)
Definition: fs.cpp:808
bool mountZip(std::string newDir, const Append append)
Definition: fs.cpp:590
int seek(File *const file, const uint64_t pos)
Definition: fs.cpp:847
FsEntry * searchByTypeInternal(const std::string &root, const FsEntryTypeT type)
Definition: fs.cpp:109
bool unmountZip(std::string oldDir)
Definition: fs.cpp:675
int64_t read(File *const file, void *const buffer, const uint32_t objSize, const uint32_t objCount)
Definition: fs.cpp:815
bool unmountDir2(std::string oldDir, std::string subDir)
Definition: fs.cpp:535
std::vector< FsEntry * > & getEntries()
Definition: fs.cpp:89
bool isDirectory(std::string name)
Definition: fs.cpp:239
void getFilesWithDir(std::string dirName, StringVect &list)
Definition: fs.cpp:194
const char * loadFile(std::string filename, int &fileSize)
Definition: fs.cpp:859
void addEntry(FsEntry *const entry, const Append append)
Definition: fs.cpp:336
void permitLinks(const bool val)
Definition: fs.cpp:803
FsEntry * searchByRootInternal(const std::string &root, const std::string &subDir)
Definition: fs.cpp:94
List * enumerateFiles(std::string dirName)
Definition: fs.cpp:147
bool setWriteDir(const std::string &newDir)
Definition: fs.cpp:331
const char * getUserDir()
Definition: fs.cpp:84
bool mountDir(std::string newDir, const Append append)
Definition: fs.cpp:393
bool mountDirSilent(std::string newDir, const Append append)
Definition: fs.cpp:421
const char * getDirSeparator()
Definition: fs.cpp:74
bool unmountZip2(std::string oldDir, std::string subDir)
Definition: fs.cpp:704
void getFiles(std::string dirName, StringVect &list)
Definition: fs.cpp:172
File * openWrite(std::string filename)
Definition: fs.cpp:293
bool unmountDir(std::string oldDir)
Definition: fs.cpp:518
bool unmountDirInternal(std::string oldDir, std::string subDir)
Definition: fs.cpp:477
File * openAppend(std::string filename)
Definition: fs.cpp:312
bool mountZip2(std::string newDir, std::string subDir, const Append append)
Definition: fs.cpp:626
int eof(File *const file)
Definition: fs.cpp:854
bool exists(std::string name)
Definition: fs.cpp:124
bool checkPath(const std::string &path)
Definition: paths.cpp:121
void prepareFsPath(std::string &path)
Definition: paths.cpp:132
#define STD_MOVE(var)
Definition: stdmove.h:28
bool findLast(const std::string &str1, const std::string &str2)
std::vector< std::string > StringVect
Definition: stringvector.h:29
std::string subDir
Definition: fsentry.h:47
std::string root
Definition: fsentry.h:45
FsFuncs * funcs
Definition: fsentry.h:51
FsEntryTypeT type
Definition: fsentry.h:49
void(* getDirs)(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsfuncs.h:101
File *(* openWrite)(FsEntry *const entry, const std::string &filename)
Definition: fsfuncs.h:109
bool(* exists)(FsEntry *const entry, std::string filename, std::string dirName)
Definition: fsfuncs.h:85
void(* enumerate)(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsfuncs.h:92
File *(* openAppend)(FsEntry *const entry, const std::string &filename)
Definition: fsfuncs.h:111
File *(* openRead)(FsEntry *const entry, std::string filename)
Definition: fsfuncs.h:107
const char *(* loadFile)(FsEntry *const entry, std::string fileName, int &fileSize)
Definition: fsfuncs.h:114
void(* getFilesWithDir)(FsEntry *const entry, const std::string &dirName, StringVect &names)
Definition: fsfuncs.h:98
bool(* getRealDir)(FsEntry *const entry, std::string filename, std::string dirName, std::string &realDir)
Definition: fsfuncs.h:88
void(* getFiles)(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsfuncs.h:95
bool(* isDirectory)(FsEntry *const entry, std::string dirName, bool &isDirFlag)
Definition: fsfuncs.h:104
StringVect names
Definition: list.h:40
std::string fileName
Definition: testmain.cpp:39