https://github.com/agent-hellboy/cpp-filetype
A minimal cpp based filetype library
https://github.com/agent-hellboy/cpp-filetype
Last synced: about 1 year ago
JSON representation
A minimal cpp based filetype library
- Host: GitHub
- URL: https://github.com/agent-hellboy/cpp-filetype
- Owner: Agent-Hellboy
- License: mit
- Created: 2025-03-12T13:28:51.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-12T16:56:42.000Z (over 1 year ago)
- Last Synced: 2025-03-12T17:40:08.268Z (over 1 year ago)
- Language: C++
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cpp-filetype
A C++ library for detecting file types based on their magic bytes.
## Installation
### From Source
1. Clone the repository:
```bash
$ git clone https://github.com/agent-hellboy/cpp-filetype.git
```
2. Build and install:
```bash
$ rm -rf build
$ cd build
$ cmake -DBUILD_TESTS=ON ..
$ cmake --build .
$ ctest --output-on-failure
```
## Usage
```cpp
#include "filetype/filetype.hpp"
int main() {
std::vector data = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
const ::filetype::Type* type = ::filetype::match(data);
if (type) {
std::cout << "Detected: " << type->mime << " (" << type->extension << ")\n";
} else {
std::cout << "Unknown file type\n";
}
return 0;
}
```
## License
MIT License (c) 2025 Prince Roshan