Initial commit - restart from existing code

This commit is contained in:
Tom Ray
2026-02-13 19:15:05 +01:00
parent 11df621bb2
commit 7c352bc280
1906 changed files with 491226 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
#ifndef CFILEMANAGER_HPP
#define CFILEMANAGER_HPP
#include "../Exception/CFileException.hpp"
#include "../../Context/CContext.hpp"
#include <cstdio>
#include <string>
#include <stdexcept>
/**
* @file CFileManager.hpp
* @brief File of CException, a class to manage program file.
*/
/**
* @brief Class to manage file.
*/
class CFileManager {
private:
// The pointer to file.
FILE* m_filePtr;
// The file path.
std::string m_filePath;
/**
* @brief Open the file with the given mode
* @param[in] mode The mode of opening file, must be 'r' or 'w';
* @post throw a std::invalid_argument if mode is invalid, or a CFileException if the file can't be opened.
*/
void open(const char mode);
/**
* @brief Close the file
* @post Do nothing if the file isn't opened.
*/
void close(void);
public:
CFileManager(void) = delete;
CFileManager(const CFileManager& param) = delete;
CFileManager& operator=(const CFileManager& param) = delete;
/**
* @brief Build a file manager to the file's given path.
* @param[in] path The path of the file;
*/
CFileManager(std::string path);
/**
* @brief the destructor.
* @pre The file must be close before destroying this.
*/
~CFileManager(void);
/**
* @brief The file path getter.
* @return std::string The path of the file;
*/
std::string getPath(void) const;
/**
* @brief Write the file function.
* @param[in] content The new content of the file.
*
* This function erase the old content of the file and replace it by "content"
*/
void write(std::string content);
/**
* @brief Read the file function.
* @return std::string, The content of the file.
*/
std::string read(void);
};
#endif