mirror of
https://github.com/johndoe6345789/WizardMerge.git
synced 2026-04-24 13:44:55 +00:00
Merge pull request #27 from johndoe6345789/copilot/fix-clang-format-issues
Fix clang-format violations in file_utils.{cpp,h}
This commit is contained in:
@@ -9,35 +9,37 @@
|
||||
*/
|
||||
class FileUtils {
|
||||
public:
|
||||
/**
|
||||
* @brief Read a file and split into lines
|
||||
* @param filePath Path to the file
|
||||
* @param lines Output vector of lines
|
||||
* @return true if successful, false on error
|
||||
*/
|
||||
static bool readLines(const std::string& filePath, std::vector<std::string>& lines);
|
||||
/**
|
||||
* @brief Read a file and split into lines
|
||||
* @param filePath Path to the file
|
||||
* @param lines Output vector of lines
|
||||
* @return true if successful, false on error
|
||||
*/
|
||||
static bool readLines(const std::string &filePath,
|
||||
std::vector<std::string> &lines);
|
||||
|
||||
/**
|
||||
* @brief Write lines to a file
|
||||
* @param filePath Path to the file
|
||||
* @param lines Vector of lines to write
|
||||
* @return true if successful, false on error
|
||||
*/
|
||||
static bool writeLines(const std::string& filePath, const std::vector<std::string>& lines);
|
||||
/**
|
||||
* @brief Write lines to a file
|
||||
* @param filePath Path to the file
|
||||
* @param lines Vector of lines to write
|
||||
* @return true if successful, false on error
|
||||
*/
|
||||
static bool writeLines(const std::string &filePath,
|
||||
const std::vector<std::string> &lines);
|
||||
|
||||
/**
|
||||
* @brief Check if a file exists
|
||||
* @param filePath Path to the file
|
||||
* @return true if file exists, false otherwise
|
||||
*/
|
||||
static bool fileExists(const std::string& filePath);
|
||||
/**
|
||||
* @brief Check if a file exists
|
||||
* @param filePath Path to the file
|
||||
* @return true if file exists, false otherwise
|
||||
*/
|
||||
static bool fileExists(const std::string &filePath);
|
||||
|
||||
/**
|
||||
* @brief Get file size in bytes
|
||||
* @param filePath Path to the file
|
||||
* @return File size, or -1 on error
|
||||
*/
|
||||
static long getFileSize(const std::string& filePath);
|
||||
/**
|
||||
* @brief Get file size in bytes
|
||||
* @param filePath Path to the file
|
||||
* @return File size, or -1 on error
|
||||
*/
|
||||
static long getFileSize(const std::string &filePath);
|
||||
};
|
||||
|
||||
#endif // FILE_UTILS_H
|
||||
|
||||
@@ -3,45 +3,47 @@
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
bool FileUtils::readLines(const std::string& filePath, std::vector<std::string>& lines) {
|
||||
std::ifstream file(filePath);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
bool FileUtils::readLines(const std::string &filePath,
|
||||
std::vector<std::string> &lines) {
|
||||
std::ifstream file(filePath);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
lines.clear();
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
lines.push_back(line);
|
||||
}
|
||||
lines.clear();
|
||||
std::string line;
|
||||
while (std::getline(file, line)) {
|
||||
lines.push_back(line);
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileUtils::writeLines(const std::string& filePath, const std::vector<std::string>& lines) {
|
||||
std::ofstream file(filePath);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
bool FileUtils::writeLines(const std::string &filePath,
|
||||
const std::vector<std::string> &lines) {
|
||||
std::ofstream file(filePath);
|
||||
if (!file.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& line : lines) {
|
||||
file << line << "\n";
|
||||
}
|
||||
for (const auto &line : lines) {
|
||||
file << line << "\n";
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileUtils::fileExists(const std::string& filePath) {
|
||||
struct stat buffer;
|
||||
return (stat(filePath.c_str(), &buffer) == 0);
|
||||
bool FileUtils::fileExists(const std::string &filePath) {
|
||||
struct stat buffer;
|
||||
return (stat(filePath.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
long FileUtils::getFileSize(const std::string& filePath) {
|
||||
struct stat buffer;
|
||||
if (stat(filePath.c_str(), &buffer) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return buffer.st_size;
|
||||
long FileUtils::getFileSize(const std::string &filePath) {
|
||||
struct stat buffer;
|
||||
if (stat(filePath.c_str(), &buffer) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return buffer.st_size;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user