summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc64
1 files changed, 2 insertions, 62 deletions
diff --git a/src/util.cc b/src/util.cc
index 76d380b..dbd4c3c 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -22,70 +22,10 @@ std::string readFile(const std::string& fileName)
std::ifstream::pos_type fileSize = ifs.tellg();
ifs.seekg(0, std::ios::beg);
- std::vector<char> bytes(fileSize);
+ std::vector<char> bytes(static_cast<std::size_t>(fileSize));
ifs.read(bytes.data(), fileSize);
- return std::string(bytes.data(), fileSize);
-}
-
-std::vector<std::string> readDeps(const std::string& depFile)
-{
- if(!std::filesystem::exists(depFile))
- {
- return {};
- }
-
- auto str = readFile(depFile);
-
- std::vector<std::string> output;
- std::string tmp;
- bool start{false};
- bool in_whitespace{false};
- for(const auto& c : str)
- {
- if(c == '\\' || c == '\n')
- {
- continue;
- }
-
- if(c == ':')
- {
- start = true;
- continue;
- }
-
- if(!start)
- {
- continue;
- }
-
- if(c == ' ' || c == '\t')
- {
- if(in_whitespace)
- {
- continue;
- }
-
- if(!tmp.empty())
- {
- output.push_back(tmp);
- }
- tmp.clear();
- in_whitespace = true;
- }
- else
- {
- in_whitespace = false;
- tmp += c;
- }
- }
-
- if(!tmp.empty())
- {
- output.push_back(tmp);
- }
-
- return output;
+ return {bytes.data(), static_cast<std::size_t>(fileSize)};
}
ctor::language languageFromExtension(const std::filesystem::path& file)