Fake File System
A fully in-memory file system useful for testing. It includes features to support writing better tests.
Use openPaths to see which paths have been opened for read or write, but not yet closed. Tests should call checkNoOpenFiles in tearDown()
to confirm that no file streams were leaked.
Strict By Default
-----------------These actions are not allowed and throw an IOException if attempted:
Moving a file that is currently open for reading or writing.
Deleting a file that is currently open for reading or writing.
Moving a file to a path that currently resolves to an empty directory.
Reading and writing the same file at the same time.
Opening a file for writing that is already open for writing.
Programs that do not attempt any of the above operations should work fine on both UNIX and Windows systems. Relax these constraints individually or call emulateWindows or emulateUnix; to apply the constraints of a particular operating system.
Constructors
Functions
Confirm that all files that have been opened on this file system (with source, sink, and appendingSink) have since been closed. Call this in your test's tearDown()
function to confirm that your program hasn't leaked any open files.
Configure this file system to use a UNIX-like working directory (/
, unless the working directory is already UNIX-like) and to follow a UNIX-like policy on what operations are permitted.
Configure this file system to use a Windows-like working directory (F:\
, unless the working directory is already Windows-like) and to follow a Windows-like policy on what operations are permitted.
Properties
True to allow the target of an atomicMove operation to be an empty directory. Windows file systems typically allow files to replace empty directories; UNIX file systems do not.
True to permit a file to have multiple sinks open at the same time. Both Windows and UNIX file systems permit this but the result may be undefined.