-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
FileUtil.h
33 lines (27 loc) · 922 Bytes
/
FileUtil.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2021-2024 ChilliBits. All rights reserved.
#pragma once
#include <filesystem>
#include <string>
namespace spice::compiler {
struct ExecResult {
std::string output;
int exitCode;
};
/**
* Util class for file-related work
*/
class FileUtil {
public:
static void writeToFile(const std::filesystem::path &fileName, const std::string &fileContent);
static std::string getFileContent(const std::filesystem::path &filePath);
static size_t getLineCount(const std::filesystem::path &filePath);
static ExecResult exec(const std::string &command);
static bool isCommandAvailable(const std::string &cmd);
static bool isGraphvizInstalled();
static std::string findLinkerInvoker();
static std::string findLinker();
static std::filesystem::path getStdDir();
static std::filesystem::path getBootstrapDir();
static std::filesystem::path getSpiceBinDir();
};
} // namespace spice::compiler