Microsoft.SurfaceAutomationTeam.SAF 1.0.2

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Microsoft.SurfaceAutomationTeam.SAF --version 1.0.2
NuGet\Install-Package Microsoft.SurfaceAutomationTeam.SAF -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.SurfaceAutomationTeam.SAF" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.SurfaceAutomationTeam.SAF --version 1.0.2
#r "nuget: Microsoft.SurfaceAutomationTeam.SAF, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.SurfaceAutomationTeam.SAF as a Cake Addin
#addin nuget:?package=Microsoft.SurfaceAutomationTeam.SAF&version=1.0.2

// Install Microsoft.SurfaceAutomationTeam.SAF as a Cake Tool
#tool nuget:?package=Microsoft.SurfaceAutomationTeam.SAF&version=1.0.2

Overview

The Simple Archive Format, or SAF, is a simple, lightweight, extendable file archive format designed by the Surface Automation Team. It has similar functionality to tar or cpio.

Why another archive format?

The only file archive format built into .NET is Zip, which cannot be read efficiently from a non-seekable stream (such as a network or crypto stream).

While SAF was designed to allow for efficient reading and writing from a non-seekable stream, it is more comparable to protobuf than tar – it’s something developers can use and build upon. Headers in an archive are application specific and can be customized per entry (all we define is the base structure; applications can freely extend the header type).

Obtaining the Library

SAF can be compiled easily from source, and nuget.org packages are available (Microsoft.SurfaceAutomationTeam.SAF).

Note: SAF targets .NET Standard 2.1 - it cannot be used from .NET Framework 4.

Using the library

If you aren't extending SAF, it can be used easily via the SAFArchive class. Here is a simple example of writing a directory to a SAF file:

using (var fs = new FileStream(archivePath, FileMode.Create))
{
  var archive = new SAFArchive(fs, SAFMode.Write, sourcePath, true);
  archive.WriteDirectoryToArchive();
}

And here is how you'd read that same archive to extract the contents:

using (var fs = new FileStream(archivePath, FileMode.Open))
{
  var archive = new SAFArchive(fs, SAFMode.Read, extractPath);
  archive.ReadAllEntriesToDisk();
}

You can use other functions to seek through the record for specific files, or to control extraction parameters. In the default configuration, SAF also calculates MD5 checksums for all files written to the archive, and verifies them on extraction.

SAF Basic Architecture

SAF is designed to be minimal. There is a one-line file header at the beginning of the archive ('SAF1' followed by a newline), then each entry in the archive only has three components:

  • The header size (represented as a UTF-8 string of digits, followed by a newline)
  • The header (a json object, as a set of UTF-8 bytes)
  • The payload (the file contents, or nothing for a directory)

The header is flexible, and can contain as many or as few fields as required by the application. While we provide a basic header in the library that is used by the high level SAFArchive class, users who want to customize the format can use their own header types.

Default Record Metadata

In its default configuration, when used with the included SAFArchive class, the format keeps the following metadata

  • Name of entry
  • Size of entry (in bytes)
  • MD5 Hash of entry (for files only)
  • Last Write Time
  • Entry Type (file or directory)

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 351 1/9/2023
1.0.1 606 7/7/2020