This enumeration is used to control whether the temporary file should persist after the TempFile object has been destroyed.
Indicates the style that this TempFile was created with.
Returns the path to the directory where temporary files will be created. The returned path is safe to mutate.
TempStyle for creating a permanent temporary file that only the current user can access.
TempStyle for creating a transient temporary file that only the current user can access.
This structure is used to determine how the temporary files should be opened and used.
Exception class thrown on errors.
Fits into 32 bits ...
Read an existing file.
Read an existing file.
Write on an existing file. Do not create.
Write on a clean file. Create if necessary.
Read from the beginning, append at the end of the file.
Write at the end of the file.
Read and write an existing file.
Read & write on a clean file. Create if necessary.
Read and Write. Use existing file if present.
Return the Style used for this file.
Return the path used by this file.
Convenience function to return the content of a file.
Convenience function to return the content of a file.
Convenience function to set file content and length to reflect the given array.
Convenience function to append content to a file.
Low level open for sub-classes that need to apply specific attributes.
Open a file with the provided style.
Wraps the already open file descriptor into a File instance.
Set the file size to be that of the current seek position. The file must be writable for this to succeed.
Set the file size to be the specified length. The file must be writable for this to succeed.
Set the file seek position to the specified offset from the given anchor.
Return the current file position.
Return the total length of this file.
Instructs the OS to flush it's internal buffers to the disk device.
Throw a potentially reusable IOException, with the provided message, function name and error code.
Throw an IOException, with the provided message.
Throw an IOException noting the last error.
The TempFile class aims to provide a safe way of creating and destroying temporary files. The TempFile class will automatically close temporary files when the object is destroyed, so it is recommended that you make appropriate use of scoped destruction.
Temporary files can be created with one of several styles, much like normal Files. TempFile styles have the following properties:
Eventually, this will be expanded to give you greater control over the temporary file's properties.
For the typical use-case (creating a file to temporarily store data too large to fit into memory,) the following is sufficient:
Important: It is recommended that you do not use files created by this class to store sensitive information. There are several known issues with the current implementation that could allow an attacker to access the contents of these temporary files.
Todo: Detail security properties and guarantees.