https://github.com/nir3x/fs.cpp
Fs.cpp Library - A C++ Filesystem Utility Library
https://github.com/nir3x/fs.cpp
c-plus-plus c-plus-plus-library cpp cpp-library filesystem filesystem-operations modern-cpp std-expected utility
Last synced: 10 months ago
JSON representation
Fs.cpp Library - A C++ Filesystem Utility Library
- Host: GitHub
- URL: https://github.com/nir3x/fs.cpp
- Owner: NIR3X
- License: agpl-3.0
- Created: 2024-02-21T04:19:14.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-22T14:13:26.000Z (almost 2 years ago)
- Last Synced: 2024-02-23T14:55:54.541Z (almost 2 years ago)
- Topics: c-plus-plus, c-plus-plus-library, cpp, cpp-library, filesystem, filesystem-operations, modern-cpp, std-expected, utility
- Language: C++
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fs.cpp Library - A C++ Filesystem Utility Library
Fs.cpp is a C++ library providing a set of convenient functions for working with the filesystem. It aims to simplify common filesystem operations and provide error-handling using `std::expected`.
## Features
* **Filesystem Operations**: Perform various filesystem tasks such as file copy, symlink creation, directory operations, and more.
* **Error Handling**: Uses `std::expected` to handle errors and provide clear feedback.
* **Convenient API**: Designed for ease of use with straightforward functions for common filesystem tasks.
## Requirements
* C++23 or later.
* A compiler that supports the C++23 standard.
## Installation
To use this package, you can clone the repository and compile it using a C++ compiler:
```bash
git clone https://github.com/NIR3X/Fs.cpp
cd Fs.cpp
make
```
## Usage
Here's a simple example demonstrating the usage of the library:
```cpp
#include "Fs.h"
#include
#include
#include
#include
int main() {
// Example usage of Fs.cpp functions
NSFs::CPath filePath = L"test.txt";
std::string content = "Hello, World!";
// Write content to file
assert(NSFs::WriteFile(filePath, content).has_value());
// Check if file exists
auto exists = NSFs::Exists(filePath);
assert(exists.has_value());
assert(exists.value());
// Check if it's a regular file
auto isRegularFile = NSFs::IsRegularFile(filePath);
assert(isRegularFile.has_value());
assert(isRegularFile.value());
// Read file content
auto read = NSFs::ReadFile>(filePath);
assert(read.has_value());
assert(content == std::string(read.value().begin(), read.value().end()));
// Remove the file
assert(NSFs::Remove(filePath).has_value());
// Verify removal
exists = NSFs::Exists(filePath);
assert(exists.has_value());
assert(!exists.value());
std::cout << "PASS" << std::endl;
return 0;
}
```
## License
[](https://www.gnu.org/licenses/agpl-3.0.html)
This program is Free Software: You can use, study share and improve it at your
will. Specifically you can redistribute and/or modify it under the terms of the
[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html) as
published by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.