InspIRCd  4.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 FilePosition
25 {
26  public:
28  std::string name;
29 
31  unsigned long line;
32 
34  unsigned long column;
35 
41  FilePosition(const std::string& Name, unsigned long Line, unsigned long Column);
42 
44  std::string str() const;
45 };
46 
48 class CoreExport FileReader
49 {
51  std::vector<std::string> lines;
52 
54  unsigned long totalSize = 0;
55 
56  public:
58  FileReader() = default;
59 
63  FileReader(const std::string& filename);
64 
69  void Load(const std::string& filename);
70 
72  std::string GetString() const;
73 
75  const std::vector<std::string>& GetVector() const { return lines; }
76 
78  unsigned long TotalSize() const { return totalSize; }
79 };
80 
82 class CoreExport FileSystem
83 {
84 private:
85  FileSystem() = delete;
86 
87 public:
92  static std::string ExpandPath(const std::string& base, const std::string& fragment);
93 
99  static bool FileExists(const std::string& path);
100 
105  static std::string GetFileName(const std::string& path);
106 
111  static bool StartsWithWindowsDriveLetter(const std::string& path);
112 };
Definition: fileutils.h:25
unsigned long line
Definition: fileutils.h:31
unsigned long column
Definition: fileutils.h:34
std::string name
Definition: fileutils.h:28
Definition: fileutils.h:49
FileReader()=default
unsigned long TotalSize() const
Definition: fileutils.h:78
const std::vector< std::string > & GetVector() const
Definition: fileutils.h:75
Definition: fileutils.h:83