The FileManagerBackup project provides a set of utilities to manage file backups and search for files within a directory. The primary functionalities include:
- Backing up directories: Recursively copies files from a source directory to a destination directory.
- Searching for files: Allows searching for files within a directory based on a search term.
The project is implemented in C++17 and uses the std::filesystem library for handling file system operations.
- Backup Directory: Copy all files and subdirectories from the source directory to the destination directory.
- Search Files: Search for files in a given directory and its subdirectories based on a search term.
- C++17: The project requires a C++17 compatible compiler (e.g., GCC 9.0+ or Clang 8+).
- CMake: CMake 3.10 or higher for building the project.
- Filesystem Support: The project uses the
std::filesystemlibrary, which is available from C++17 onwards.
Ensure you have the following installed:
- A C++17 compatible compiler (e.g., GCC 9.0+, Clang 8+).
- CMake 3.10 or higher.
-
Clone the repository:
git clone https://github.com/your-username/FileManagerBackup.git cd FileManagerBackup -
Create a build directory and configure the project using CMake:
mkdir build cd build cmake .. -
Build the project using
make:make
-
The resulting executable will be created in the
builddirectory asFileManagerBackup.
-
If you're using GCC version 8.0 or below, you may need to link the filesystem library manually by adding the following line to your
CMakeLists.txt:target_link_libraries(FileManagerBackup stdc++fs)This is no longer required for GCC 9.0+ or Clang.
-
For Clang, no extra configuration is necessary, but ensure you're using the correct C++ standard library:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
The FileManager::backupDirectory function allows you to copy all files and subdirectories from a source directory to a destination directory. Here's an example of how to use it:
#include "FileManager.h"
int main() {
FileManager fileManager;
try {
fileManager.backupDirectory("/path/to/source", "/path/to/destination");
std::cout << "Backup completed successfully." << std::endl;
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}