|
OpenXPKI::FileUtilsHelper class for file operations and temp file management.ParametersThe constructor expects arguments as a hash.
Functionsread_file filename, encodingReads the content of the given filename and returns it as string, pass utf8 as second parameter to read the file in utf8 mode. Throws an exception if the file can not be read.write_file { FILENAME, CONTENT, FORCE }Expects a hash with the keys CONTENT and FILENAME. The method will NOT overwrite an existing file but throw an exception if the target already exists, unless FORCE is passed a true value or the filename is a tempfile created by get_safe_tmpfile before.get_safe_tmpfile { TMP }Create an emtpty tempfile and returns its name. You can pass a hash with the key TMP set to the parent directory to use, if not set the directory given to the constructor is used.The file will NOT be removed unless you call the cleanup method of this class instance. get_safe_tmpdirCreate an emtpty directory and returns its name. You can pass a hash with the key TMP set to the parent directory to use, if not set the directory given to the constructor is used.The directory will NEVER be removed autmatically. get_tmp_handleCreate a temporary file and return the object handle of it. The return value can be used in string context to get the name of the directory created. The handle will be held open by the class so it will stay in the filesystem until the class is destroyed.get_tmp_dirhandleCreate a temporary directory and return the object handle of it. The return value can be used in string context to get the name of the directory created. The handle will be held open by the class so it will stay in the filesystem until the class is destroyed.write_temp_fileExpects the content to write as argument. Creates a temporary file handle using get_tmp_handle and writes the data to it. The filehandle is closed and the name of the file is returned.cleanupUnlink files created with get_safe_tempfile and remove all handles held by the instance so File::Temp should cleanup them.Warning: This method is not fork-safe and will delete any files created with get_safe_tempfile across forks!
Visit the GSP FreeBSD Man Page Interface. |