42 lines
1.3 KiB
C++
42 lines
1.3 KiB
C++
#ifndef FILE_UTILS_H
|
|
#define FILE_UTILS_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// File utility functions
|
|
class FileUtils {
|
|
public:
|
|
// Read entire file content
|
|
static std::string readFile(const std::string& filepath);
|
|
|
|
// Write content to file
|
|
static bool writeFile(const std::string& filepath, const std::string& content);
|
|
|
|
// Check if file exists
|
|
static bool fileExists(const std::string& filepath);
|
|
|
|
// Create directory if it doesn't exist (recursive)
|
|
static bool createDirectory(const std::string& dirpath);
|
|
|
|
// Delete all files in a directory
|
|
static bool cleanDirectory(const std::string& dirpath);
|
|
|
|
// Join paths with proper separators
|
|
static std::string joinPath(const std::string& path1, const std::string& path2);
|
|
|
|
// Get files in directory matching pattern
|
|
static std::vector<std::string> listFiles(const std::string& dirpath, const std::string& extension = "");
|
|
|
|
// Replace all occurrences in string
|
|
static std::string replaceAll(const std::string& str, const std::string& from, const std::string& to);
|
|
|
|
// Trim whitespace from string
|
|
static std::string trim(const std::string& str);
|
|
|
|
// Split string by delimiter
|
|
static std::vector<std::string> split(const std::string& str, char delimiter);
|
|
};
|
|
|
|
#endif
|