Skip to content

A small tool for creating random sparse (dummy) files, written in Node.js

License

Notifications You must be signed in to change notification settings

lv3-himeme/sparse-file-creator

Repository files navigation

sparse-file-creator

Screenshot

sparse-file-creator is a small application written in NW.js (which is basically HTML for front-end and Node.JS for back-end), and it can be used to make multiple sparse (dummy) files for testing or "entertainment" purposes (yes, I find using this tool a bit entertaining).

Main Features

  • Create (multiple) sparse file(s) based on the defined settings
  • The file name and size can be randomized, or defined using JavaScript based on the current index (from 0 to length - 1)
  • Blazing-fast file creation because of fs.ftruncate() (uses only one system call to create the sparse file (almost) instantly). Due to it being blazing-fast, you won't see the progress bar going up most of the time, although the progress bar actually exists.

Supported systems

As soon as your operating system supports NW.js and your disk's filesystem supports fs.ftruncate(), this application will likely work. If it doesn't work, consider re-checking your file system. I've tested it on:

  • Arch Linux with ext4 and NTFS filesystem
  • macOS with APFS filesystem

Prebuilt binaries

This is your destination. Just download the binary made for your current operating system.

"Building" from source

Since this application uses NW.js, the building process is very easy to perform:

Windows

NW.js 0.72.0 is recommended because of it being the latest version supporting Windows 7 and 8.1. If you're using Windows 10, you can indeed download the latest version instead of older ones.

I'm doing this using PowerShell command line, but of course, you can do all of these things with respective GUI applications if you want.

Replace nwjs-v0.72.0-win-x64 in every command with nwjs-v0.72.0-win-ia32 if you're building the 32-bit version.

  1. Download NW.js binaries from the server:

32-bit

wget -O nwjs.zip https://dl.nwjs.io/v0.72.0/nwjs-v0.72.0-win-ia32.zip

64-bit

wget -O nwjs.zip https://dl.nwjs.io/v0.72.0/nwjs-v0.72.0-win-x64.zip
  1. Extract the downloaded .zip file:
Expand-Archive -Path nwjs.zip -DestinationPath .
  1. Clone this repository:
git clone https://github.com/lv3-himeme/sparse-file-creator.git
  1. Copy the source code into the NW.js folder:
Copy-Item -Path ".\sparse-file-creator\*" -Destination ".\nwjs-v0.72.0-win-x64" -Recurse -Exclude ".git*"
  1. (Optional) Rename nw.exe to sparse-file-creator.exe:
Rename-Item -Path ".\nwjs-v0.72.0-win-x64\nw.exe" -NewName "sparse-file-creator.exe"

Now you can run sparse-file-creator.exe (or nw.exe if you don't rename it) in nwjs-v0.72.0-win-x64 folder. Of course you can rename or compress the folder if you want.

macOS

NW.js 0.72.0 is also recommended for this OS to bring back macOS 10.15 support. Of course you can still download the latest version if you don't care.

Replace nwjs-v0-72.0-osx-x64 in every command with nwjs-v0.95.0-osx-arm64 if you're building the arm64 (Apple Silicon) version.

  1. Download NW.js binaries from the server:
wget -O nwjs.zip https://dl.nwjs.io/v0.72.0/nwjs-v0.72.0-osx-x64.zip

For arm64 (Apple Silicon), you need to download the latest arm64 version:

wget -O nwjs.zip https://dl.nwjs.io/v0.95.0/nwjs-v0.95.0-osx-arm64.zip
  1. Extract the downloaded .zip file:
unzip -o nwjs.zip -d .
  1. Create a new folder called app.nw in nwjs.app/Contents/Resources:
mkdir nwjs-v0.72.0-osx-x64/nwjs.app/Contents/Resources/app.nw
  1. Clone this repository:
git clone https://github.com/lv3-himeme/sparse-file-creator.git
  1. Copy the source code to NW.js folder:
rsync -av --exclude=".git*" sparse-file-creator/ nwjs-v0.72.0-osx-x64/nwjs.app/Contents/Resources/app.nw/
  1. (Optional) Rename nwjs.app to sparse-file-creator.app:
mv nwjs-v0.72.0-osx-x64/nwjs.app nwjs-v0.72.0-osx-x64/sparse-file-creator.app

Now you can run sparse-file-creator.app (or nwjs.app if you don't rename it) in nwjs-v0.72.0-osx-x64 folder, and of course you can rename or compress it if you want.

Linux

Replace nwjs-v0.95.0-linux-x64 in every command with nwjs-v0.95.0-linux-ia32 if you're building the 32-bit version.

  1. Download the latest NW.js binaries:

32-bit

wget -O nwjs.tar.gz https://dl.nwjs.io/v0.95.0/nwjs-v0.95.0-linux-ia32.tar.gz

64-bit

wget -O nwjs.tar.gz https://dl.nwjs.io/v0.95.0/nwjs-v0.95.0-linux-x64.tar.gz
  1. Extract the downloaded .tar.gz file:
tar -xzvf nwjs.tar.gz
  1. Clone this repository:
git clone https://github.com/lv3-himeme/sparse-file-creator.git
  1. Copy the source code to NW.js folder:
rsync -av --exclude=".git*" sparse-file-creator/ nwjs-v0.95.0-linux-x64/
  1. Make the nw file executable:
chmod +x nwjs-v0.95.0-linux-x64/nw
  1. (Optional) Rename nw to sparse-file-creator if you want:
mv nwjs-v0.95.0-linux-x64/nw nwjs-v0.95.0-linux-x64/sparse-file-creator

Now you can run sparse-file-creator (or nw if you don't rename it) in nwjs-v0.95.0-linux-x64 folder, and of course you can rename or compress it if you want.

Libraries used

  • Bootstrap v5.3.3
  • jQuery v3.7.1
  • CodeMirror v5.65.18

You can view their respective license in the licenses folder.

License

This application is licensed under MIT License.