InspIRCd  3.0
fileutils.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2014 Attila Molnar <[email protected]>
5  * Copyright (C) 2013, 2019 Sadie Powell <[email protected]>
6  *
7  * This file is part of InspIRCd. InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 
21 #pragma once
22 
24 class CoreExport FileReader
25 {
27  std::vector<std::string> lines;
28 
30  unsigned long totalSize;
31 
32  public:
34  FileReader() : totalSize(0) { }
35 
39  FileReader(const std::string& filename);
40 
45  void Load(const std::string& filename);
46 
48  std::string GetString() const;
49 
51  const std::vector<std::string>& GetVector() const { return lines; }
52 
54  unsigned long TotalSize() const { return totalSize; }
55 };
56 
58 class CoreExport FileSystem
59 {
60 private:
61  FileSystem() { }
62 
63 public:
68  static std::string ExpandPath(const std::string& base, const std::string& fragment);
69 
75  static bool FileExists(const std::string& path);
76 
81  static std::string GetFileName(const std::string& path);
82 
89  static bool GetFileList(const std::string& directory, std::vector<std::string>& entries, const std::string& match = "*");
90 
95  static bool StartsWithWindowsDriveLetter(const std::string& path);
96 };
FileReader
Definition: fileutils.h:24
FileSystem
Definition: fileutils.h:58
FileReader::TotalSize
unsigned long TotalSize() const
Definition: fileutils.h:54
FileReader::GetVector
const std::vector< std::string > & GetVector() const
Definition: fileutils.h:51
FileReader::FileReader
FileReader()
Definition: fileutils.h:34