Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

EmptyFiles

Discussions Build status NuGet Status NuGet Status

A collection of minimal binary files.

See Milestones for release notes.

Sponsors

Entity Framework Extensions

Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.

Entity Framework Extensions

Developed using JetBrains IDEs

JetBrains logo.

NuGet

Files

All files: https://github.com/VerifyTests/EmptyFiles/tree/main/files

Archive

  • .7z (32 bytes)
  • .7zip (32 bytes)
  • .bz2 (14 bytes)
  • .bzip2 (14 bytes)
  • .gz (20 bytes)
  • .gzip (20 bytes)
  • .kmz (204 bytes)
  • .nupkg (258 bytes)
  • .tar (1 KB)
  • .xz (32 bytes)
  • .zip (22 bytes)

Document

  • .docx (810 bytes)
  • .odt (647 bytes)
  • .pdf (212 bytes)
  • .rtf (6 bytes)

Image

  • .avif (70 bytes)
  • .bmp (58 bytes)
  • .dds (132 bytes)
  • .dib (58 bytes)
  • .emf (132 bytes)
  • .exif (139 bytes)
  • .gif (28 bytes)
  • .heic (32 bytes)
  • .heif (32 bytes)
  • .ico (68 bytes)
  • .j2c (44 bytes)
  • .jfif (139 bytes)
  • .jp2 (77 bytes)
  • .jpc (44 bytes)
  • .jpe (139 bytes)
  • .jpeg (139 bytes)
  • .jpg (139 bytes)
  • .jxr (48 bytes)
  • .pbm (8 bytes)
  • .pcx (129 bytes)
  • .pgm (10 bytes)
  • .png (67 bytes)
  • .ppm (12 bytes)
  • .rle (58 bytes)
  • .tga (21 bytes)
  • .tif (198 bytes)
  • .tiff (198 bytes)
  • .wdp (48 bytes)
  • .webp (26 bytes)
  • .wmp (48 bytes)

Sheet

  • .ods (683 bytes)
  • .xlsx (1.4 KB)

Slide

  • .odp (667 bytes)
  • .pptx (842 bytes)

Binary

  • .bin (0 bytes)

Consuming files as a web resource

Files can be consumed as a web resource using the following url:

https://github.com/VerifyTests/EmptyFiles/raw/main/index/empty.{extension}

So for example to consume a jpg use

https://github.com/VerifyTests/EmptyFiles/raw/main/index/empty.jpg

A 404 will result for non-existent files.

Tool Usage

Installation

Ensure dotnet CLI is installed.

Install EmptyFiles.Tool

dotnet tool install -g EmptyFiles.Tool

Extension only Usage

emptyfile bmp

Creates {CurrentDirectory}/empty.bmp

File Usage

emptyfile myfile.bmp

Creates {CurrentDirectory}/myfile.bmp

Path Usage

emptyfile path/myfile.bmp

Creates path/myfile.bmp

Library Usage

CreateFile

Creates a new empty file

AllFiles.CreateFile(pathOfFileToCreate);

snippet source | anchor

Throws an exception if the extension is not known. There is also a TryCreateFile that will return false if the extension is not known.

Use the optional useEmptyStringForTextFiles to create a empty text file if the extension is text. The file will be UTF8 no BOM as per https://www.unicode.org/versions/Unicode5.0.0/ch02.pdf "Use of a BOM is neither required nor recommended for UTF-8".

GetPathFor

Gets the path to an empty file for a given extension

var path = AllFiles.GetPathFor(".jpg");

snippet source | anchor

Throws an exception if the extension is not known. There is also a TryGetPathFor that will return false if the extension is not known.

IsEmptyFile

Returns true if the target file is an empty file.

var path = AllFiles.GetPathFor(".jpg");
True(AllFiles.IsEmptyFile(path));
var temp = Path.GetTempFileName();
False(AllFiles.IsEmptyFile(temp));

snippet source | anchor

AllPaths

Enumerates all empty files

foreach (var path in AllFiles.AllPaths)
{
    Trace.WriteLine(path);
}

snippet source | anchor

UseFile

Use or replace a file

AllFiles.UseFile(Category.Document, pathToFile);
IsTrue(AllFiles.DocumentPaths.Contains(pathToFile));

snippet source | anchor

Extensions helper

IsText

https://github.com/sindresorhus/text-extensions/blob/master/text-extensions.json

True(FileExtensions.IsTextFile("file.txt"));
False(FileExtensions.IsTextFile("file.bin"));
True(FileExtensions.IsTextExtension(".txt"));
False(FileExtensions.IsTextExtension(".bin"));
True(FileExtensions.IsTextExtension("txt"));
False(FileExtensions.IsTextExtension("bin"));

snippet source | anchor

AddTextExtension

FileExtensions.AddTextExtension(".ext1");
True(FileExtensions.IsTextExtension(".ext1"));
True(FileExtensions.IsTextFile("file.ext1"));

snippet source | anchor

RemoveTextExtension

FileExtensions.AddTextExtension(".ext1");
True(FileExtensions.IsTextExtension(".ext1"));
FileExtensions.RemoveTextExtension(".ext1");
False(FileExtensions.IsTextExtension(".ext1"));

snippet source | anchor

AddTextFileConvention

AddTextFileConvention allows the use of a convention based text file detection via a callback.

At app startup add a convention using FileExtensions.AddTextFileConvention:

[ModuleInitializer]
public static void AddTextFileConvention() =>
    // Treat files ending with .txtViaConvention as text files
    FileExtensions.AddTextFileConvention(path => path.EndsWith(".txtViaConvention"));

snippet source | anchor

Then any call to FileExtensions.IsTextFile will, in addition to checking the known text extensions, also check if any of the added text contentions return true.

True(FileExtensions.IsTextFile("c:/path/file.txtViaConvention"));

snippet source | anchor

An alternative approach to a text file convention would be to check if a file has a preamble that matches an known text encoding.

Icon

Hollow designed by Michael Senkow from The Noun Project.

About

A collection of minimal binary files.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

Sponsor this project

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.