Ghidra Decompiler Analysis Engine
filemanage.hh
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 // Generic (POSIX) class for searching files and managing paths
17 
18 #ifndef __FILEMANAGE__
19 #define __FILEMANAGE__
20 
21 #include <vector>
22 #include <string>
23 #include <iostream>
24 #include <sstream>
25 #include <fstream>
26 
27 using namespace std;
28 
29 class FileManage {
30  vector<string> pathlist; // List of paths to search for files
31  static char separator;
32  static string buildPath(const vector<string> &pathels,int level);
33  static bool testDevelopmentPath(const vector<string> &pathels,int level,string &root);
34  static bool testInstallPath(const vector<string> &pathels,int level,string &root);
35 public:
36  void addDir2Path(const string &path);
37  void addCurrentDir(void);
38  void findFile(string &res,const string &name) const; // Resolve full pathname
39  void matchList(vector<string> &res,const string &match,bool isSuffix) const; // List of files with suffix
40  static bool isDirectory(const string &path);
41  static void matchListDir(vector<string> &res,const string &match,bool isSuffix,const string &dir,bool allowdot);
42  static void directoryList(vector<string> &res,const string &dirname,bool allowdot=false);
43  static void scanDirectoryRecursive(vector<string> &res,const string &matchname,const string &rootpath,int maxdepth);
44  static void splitPath(const string &full,string &path,string &base);
45  static bool isAbsolutePath(const string &full) { if (full.empty()) return false; return (full[0] == separator); }
46  static string discoverGhidraRoot(const char *argv0);
47 };
48 
49 #endif
FileManage
Definition: filemanage.hh:29