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
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 <>.
20  */
25 #include "fs/virtfs/fileapi.h"
27 #include "utils/stringvector.h"
29 #include "localconsts.h"
31 namespace VirtFs
32 {
34 struct File;
35 struct FsEntry;
36 struct FsFuncs;
37 struct List;
39 namespace FsDir
40 {
41  File *openInternal(FsEntry *restrict const entry,
42  const std::string &filename,
43  const FILEMTYPE mode);
44  File *openRead(FsEntry *restrict const entry,
45  std::string filename);
46  File *openWrite(FsEntry *restrict const entry,
47  const std::string &filename);
48  File *openAppend(FsEntry *restrict const entry,
49  const std::string &filename);
50  const char *getBaseDir();
51  const char *getUserDir();
52  FsFuncs *getFuncs();
53  void init(const std::string &restrict name);
54  void initFuncs(FsFuncs *restrict const ptr);
55  void deinit();
56  bool exists(FsEntry *restrict const entry,
57  std::string fileName,
58  std::string dirName);
59  void enumerate(FsEntry *restrict const entry,
60  std::string dirName,
61  StringVect &names);
62  void getFiles(FsEntry *restrict const entry,
63  std::string dirName,
64  StringVect &names);
65  void getFilesWithDir(FsEntry *restrict const entry,
66  const std::string &dirName,
67  StringVect &names);
68  void getDirs(FsEntry *restrict const entry,
69  std::string dirName,
70  StringVect &names);
71  bool isDirectory(FsEntry *restrict const entry,
72  std::string dirName,
73  bool &isDirFlag);
74  bool isSymbolicLink(std::string name);
75  void freeList(List *restrict const handle);
76  bool setWriteDir(std::string newDir);
77  bool getRealDir(FsEntry *restrict const entry,
78  std::string filename,
79  std::string dirName,
80  std::string &realDir);
81  bool mkdir(std::string dirName);
82  bool remove(std::string filename);
83  void permitLinks(const bool val);
84  int64_t read(File *restrict const handle,
85  void *restrict const buffer,
86  const uint32_t objSize,
87  const uint32_t objCount);
88  int64_t write(File *restrict const file,
89  const void *restrict const buffer,
90  const uint32_t objSize,
91  const uint32_t objCount);
92  int close(File *restrict const file);
93  int64_t fileLength(File *restrict const file);
94  int64_t tell(File *restrict const file);
95  int seek(File *restrict const file,
96  const uint64_t pos);
97  int eof(File *restrict const file);
98  const char *loadFile(FsEntry *restrict const entry,
99  std::string fileName,
100  int &restrict fileSize);
101 } // namespace FsDir
103 } // namespace VirtFs
105 #endif // UTILS_VIRTFSDIR_H
Definition: fileapi.h:29
#define restrict
Definition: localconsts.h:165
File * openRead(FsEntry *const entry, std::string filename)
Definition: fsdir.cpp:83
const char * getBaseDir()
Definition: fsdir.cpp:160
File * openAppend(FsEntry *const entry, const std::string &filename)
Definition: fsdir.cpp:95
bool isSymbolicLink(std::string name)
Definition: fsdir.cpp:250
bool exists(FsEntry *const entry, std::string fileName, std::string dirName)
Definition: fsdir.cpp:184
int close(File *const file)
Definition: fsdir.cpp:312
int64_t fileLength(File *const file)
Definition: fsdir.cpp:368
bool setWriteDir(std::string newDir)
Definition: fsdir.cpp:276
void freeList(List *const handle)
Definition: fsdir.cpp:271
File * openInternal(FsEntry *const entry, const std::string &filename, const char *mode)
Definition: fsdir.cpp:64
int eof(File *const file)
Definition: fsdir.cpp:436
void getFilesWithDir(FsEntry *const entry, const std::string &dirName, StringVect &names)
Definition: fsdir.cpp:586
File * openWrite(FsEntry *const entry, const std::string &filename)
Definition: fsdir.cpp:89
int64_t read(File *const file, void *const buffer, const uint32_t objSize, const uint32_t objCount)
Definition: fsdir.cpp:320
bool getRealDir(FsEntry *const entry, std::string filename, std::string dirName, std::string &realDir)
Definition: fsdir.cpp:170
const char * getUserDir()
Definition: fsdir.cpp:165
void getDirs(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsdir.cpp:636
void deinit()
Definition: fsdir.cpp:101
const char * loadFile(FsEntry *const entry, std::string filename, int &fileSize)
Definition: fsdir.cpp:466
int seek(File *const file, const uint64_t pos)
Definition: fsdir.cpp:418
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 isDirectory(FsEntry *const entry, std::string dirName, bool &isDirFlag)
Definition: fsdir.cpp:235
bool remove(std::string filename)
Definition: fsdir.cpp:296
void getFiles(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsdir.cpp:536
void enumerate(FsEntry *const entry, std::string dirName, StringVect &names)
Definition: fsdir.cpp:192
bool mkdir(std::string dirname)
Definition: fsdir.cpp:285
void initFuncs(FsFuncs *const ptr)
Definition: fsdir.cpp:126
int64_t tell(File *const file)
Definition: fsdir.cpp:400
int64_t write(File *const file, const void *const buffer, const uint32_t objSize, const uint32_t objCount)
Definition: fsdir.cpp:344
std::vector< std::string > StringVect
Definition: stringvector.h:29
std::string fileName
Definition: testmain.cpp:39