https://github.com/coplt/coplt.mar
Simple uncompressed random access archive format
https://github.com/coplt/coplt.mar
archive archive-format mar random-access
Last synced: 7 months ago
JSON representation
Simple uncompressed random access archive format
- Host: GitHub
- URL: https://github.com/coplt/coplt.mar
- Owner: coplt
- License: mit
- Created: 2025-06-06T15:36:08.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-06-06T15:47:16.000Z (7 months ago)
- Last Synced: 2025-06-06T15:53:33.992Z (7 months ago)
- Topics: archive, archive-format, mar, random-access
- Language: C#
- Homepage: https://www.nuget.org/packages/Coplt.Mar/
- Size: 0 Bytes
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Coplt.Mar
[](https://www.nuget.org/packages/Coplt.Mar/)
**M**emory mapped **AR**chiver format
- Random Access
- No compression
- No hash verification (CRC SHA ...)
- Get `ReadOnlySpan` directly through memory mapping
### Detail
File layout:
```
...
```
- Head
`"\0MAR📦"` in utf8, 📦 is emoji
`00 4D 41 52 F0 9F 93 A6`
- Version
`(int Major, int Minor, int Patch)` ser by MsgPack
It is the format version, not the library version
`0.1.0` is `93 00 01 00`
- Data
Just simply bytes
- Manifest
`Dictionary` ser by MsgPack
- Tail
Little endian `uint` manifest size
## Usage
```csharp
{
await using var builder = await MarBuilder.CreateAsync("./test.mar");
await builder.AddFileAsync("test.txt", "Hello, World!");
// await builder.AddFileAsync("test.txt", "Hello, World!", Encoding.Utf16); // Specify encoding
await builder.AddFileAsync("some.bin", new byte[] { 1, 2, 3, 4, 5 });
// await builder.AddFileAsync("test.txt", SomeStream);
}
{
using var mar = MarArchive.Open("./test.mar");
mar.TryGetString("test.txt", out string data);
Console.WriteLine(data);
// Output: Hello, World!
mar.TryGet("test.txt", out ReadOnlySpan span);
Console.WriteLine(string.Join(", ", span.ToArray()));
// Output: 1, 2, 3, 4, 5
Console.WriteLine(mar.TryGet("asd", out _));
// Output: False
}
```