https://github.com/verifytests/emptyfiles
A collection of minimal binary files.
https://github.com/verifytests/emptyfiles
Last synced: about 1 year ago
JSON representation
A collection of minimal binary files.
- Host: GitHub
- URL: https://github.com/verifytests/emptyfiles
- Owner: VerifyTests
- License: mit
- Created: 2019-12-28T09:38:40.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-05-14T10:35:48.000Z (about 1 year ago)
- Last Synced: 2025-05-16T08:04:42.719Z (about 1 year ago)
- Language: C#
- Homepage:
- Size: 533 KB
- Stars: 52
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.txt
- Code of conduct: code_of_conduct.md
Awesome Lists containing this project
README
#
EmptyFiles
[](https://github.com/orgs/VerifyTests/discussions)
[](https://ci.appveyor.com/project/SimonCropp/EmptyFiles)
[](https://www.nuget.org/packages/EmptyFiles/)
[](https://www.nuget.org/packages/EmptyFiles.Tool/)
A collection of minimal binary files.
**See [Milestones](../../milestones?state=closed) for release notes.**
## NuGet package
* https://nuget.org/packages/EmptyFiles/
* https://nuget.org/packages/EmptyFiles.Tool/
## 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 (29 bytes)
* .gzip (29 bytes)
* .tar (1.5 KB)
* .xz (32 bytes)
* .zip (22 bytes)
### Document
* .docx (1.9 KB)
* .odt (2.2 KB)
* .pdf (280 bytes)
* .rtf (6 bytes)
### Image
* .avif (298 bytes)
* .bmp (58 bytes)
* .dds (136 bytes)
* .dib (58 bytes)
* .emf (620 bytes)
* .exif (734 bytes)
* .gif (799 bytes)
* .heic (3.2 KB)
* .heif (209 bytes)
* .ico (70 bytes)
* .j2c (270 bytes)
* .jfif (734 bytes)
* .jp2 (354 bytes)
* .jpc (270 bytes)
* .jpe (734 bytes)
* .jpeg (734 bytes)
* .jpg (734 bytes)
* .jxr (300 bytes)
* .pbm (8 bytes)
* .pcx (131 bytes)
* .pgm (12 bytes)
* .png (119 bytes)
* .ppm (14 bytes)
* .rle (58 bytes)
* .tga (543 bytes)
* .tif (250 bytes)
* .tiff (250 bytes)
* .wdp (300 bytes)
* .webp (228 bytes)
* .wmp (300 bytes)
### Sheet
* .ods (2.7 KB)
* .xlsx (4.5 KB)
### Slide
* .odp (7.8 KB)
* .pptx (13.3 KB)
## 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](https://docs.microsoft.com/en-us/dotnet/core/tools/).
Install [EmptyFiles.Tool](https://nuget.org/packages/EmptyFiles.Tool/)
```ps
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
```cs
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
```cs
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.
```cs
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
```cs
foreach (var path in AllFiles.AllPaths)
{
Trace.WriteLine(path);
}
```
snippet source | anchor
### UseFile
Use or replace a file
```cs
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
```cs
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
```cs
FileExtensions.AddTextExtension(".ext1");
True(FileExtensions.IsTextExtension(".ext1"));
True(FileExtensions.IsTextFile("file.ext1"));
```
snippet source | anchor
#### RemoveTextExtension
```cs
FileExtensions.AddTextExtension(".ext1");
True(FileExtensions.IsTextExtension(".ext1"));
FileExtensions.RemoveTextExtension(".ext1");
False(FileExtensions.IsTextExtension(".ext1"));
```
snippet source | anchor
## Icon
[Hollow](https://thenounproject.com/term/hollow/51835/) designed by [Michael Senkow](https://thenounproject.com/mhsenkow/) from [The Noun Project](https://thenounproject.com).