1 #ifndef ROSE_FileUtility_H
2 #define ROSE_FileUtility_H
4 #include "commandline_processing.h"
6 #include <Rose/StringUtility.h>
13 namespace StringUtility {
46 : str(str), filename(filename), line(line) {}
48 ROSE_UTIL_API std::string toString()
const;
64 ROSE_UTIL_API
void writeFile(
const std::string& outputString,
const std::string& fileNameString,
65 const std::string& directoryName);
73 ROSE_UTIL_API std::string
readFile(
const std::string& fileName);
89 ROSE_UTIL_API
void homeDir(std::string& dir);
126 ROSE_UTIL_API std::string
fileNameSuffix(
const std::string &fileName);
143 ROSE_UTIL_API std::list<std::string>
findfile(std::string patternString, std::string pathString)
144 SAWYER_DEPRECATED(
"use Rose::FileSystem functions instead");
150 enum FileNameLocation {
151 FILENAME_LOCATION_UNKNOWN,
152 FILENAME_LOCATION_USER,
153 FILENAME_LOCATION_LIBRARY,
154 FILENAME_LOCATION_NOT_EXIST
157 static const std::string FILENAME_LIBRARY_UNKNOWN =
"Unknown";
158 static const std::string FILENAME_LIBRARY_USER =
"User";
159 static const std::string FILENAME_LIBRARY_C =
"C";
160 static const std::string FILENAME_LIBRARY_STDCXX =
"C++";
161 static const std::string FILENAME_LIBRARY_STL =
"STL";
162 static const std::string FILENAME_LIBRARY_LINUX =
"Linux";
163 static const std::string FILENAME_LIBRARY_GCC =
"GCC";
164 static const std::string FILENAME_LIBRARY_BOOST =
"Boost";
165 static const std::string FILENAME_LIBRARY_ROSE =
"Rose";
168 typedef std::string FileNameLibrary;
173 FileNameLocation location;
176 FileNameLibrary library;
181 : location(loc), library(lib), distance(dist) {}
184 : location(FILENAME_LOCATION_UNKNOWN), library(
"Unknown"), distance(0) {}
187 FileNameLocation getLocation()
const {
192 FileNameLibrary getLibrary()
const {
205 int getDistanceFromSourceDirectory()
const {
209 bool isUserCode()
const {
210 return location == FILENAME_LOCATION_USER;
213 bool isLibraryCode()
const {
214 return location == FILENAME_LOCATION_LIBRARY;
218 std::string getLibraryName()
const {
242 const std::map<std::string, std::string>& libPathCollection);
249 const std::map<std::string, std::string>& libPathCollection,
265 ROSE_UTIL_API
int directoryDistance(
const std::string& left,
const std::string& right);
272 ROSE_UTIL_API std::vector<std::string>
readWordsInFile(std::string filename);
281 bool popen_wrapper(
const std::string &command, std::vector<std::string> &result);
304 a.insert(a.end(), b.begin(), b.end());
331 if (!f.empty() && f.back().filename ==
"") {
340 f << std::string(str);
351 ROSE_UTIL_API std::string
copyEdit(
const std::string& inputString,
const std::string & oldToken,
const std::string & newToken);
353 const std::string& newToken);