Module z_tempfile

Simple temporary file handling, deletes the file when the calling process stops or crashes.

Copyright © 2011-2020 Marc Worrell

Authors: Marc Worrell (marc@worrell.nl).

Description

Simple temporary file handling, deletes the file when the calling process stops or crashes.

Function Index

cleanup/0Delete all tempfiles not modified in the last day.
is_tempfile/1Check if the file is a temporary filename.
monitored_attach/1Add a process to the tempfile monitor.
monitored_detach/1Remove a process from the tempfile monitor.
monitored_new/0Like new/0 but also return yhe Pid of the monitoring process.
monitored_new/1Like new/1 but also return yhe Pid of the monitoring process.
new/0Return a new unique filename, start a monitoring process to clean it up after use.
new/1Return a new unique filename, start a monitoring process to clean it up after use.
tempfile/0return a unique temporary filename located in the TMP directory.
tempfile/1return a unique temporary filename with the given extension.
temppath/0Returns the path where to store temporary files.

Function Details

cleanup/0

cleanup() -> ok

Delete all tempfiles not modified in the last day.

is_tempfile/1

is_tempfile(Filename::file:filename_all()) -> boolean()

Check if the file is a temporary filename.

monitored_attach/1

monitored_attach(MonitorPid::pid()) -> ok

Add a process to the tempfile monitor. The tempfile is deleted after all attached processes stopped or are detached.

monitored_detach/1

monitored_detach(MonitorPid::pid()) -> ok

Remove a process from the tempfile monitor. The tempfile is deleted after all attached processes stopped or are detached.

monitored_new/0

monitored_new() -> {ok, {pid(), file:filename_all()}}

Like new/0 but also return yhe Pid of the monitoring process.

monitored_new/1

monitored_new(Extension::string() | binary()) -> {ok, {pid(), file:filename_all()}}

Like new/1 but also return yhe Pid of the monitoring process.

new/0

new() -> file:filename_all()

Return a new unique filename, start a monitoring process to clean it up after use. The file must be created and written within 10 seconds, or it will be deleted.

new/1

new(Extension::string() | binary()) -> file:filename_all()

Return a new unique filename, start a monitoring process to clean it up after use. The file must be created and written within 10 seconds, or it will be deleted.

tempfile/0

tempfile() -> file:filename_all()

return a unique temporary filename located in the TMP directory.

tempfile/1

tempfile(Extension::string() | binary()) -> file:filename_all()

return a unique temporary filename with the given extension.

temppath/0

temppath() -> file:filename_all()

Returns the path where to store temporary files.


Generated by EDoc