TOM::Temp::file
From Cyclone3 Wiki
Temporary file toolbox.
Contents |
new()
Creates a temporary file and returns a temp file object, that can be used to manage it. The object automatically removes the file, when the object is destroyed by garbage collector.
Parameters
dir
- description: Specifies a directory, where the temporary file should be created. The filename is a random 32-char long hash. When specified, the filename will be prefixed with Cyclone3TMP-. If not specified, file will be created in the $TOM::P/_temp/ directory, prefixed with tmp-.
ext
- description: Extension for the generated file.
unlink_ext
- description: When specified, not only the original file is removed, but also file with unlink_ext filename suffix added.
nocreate
- description: Generates the file location, but doesn't create it
Syntax
my $tempfile = TOM::Temp::file::new( 'ext' => '.tmp', 'nocreate => 1 )
Return value
{ 'filename' => '/www/TOM/!mydomain.com/_tmp/tmp-ea1cec4c03e0688a178deec97363806b.tmp' }
save_content()
Called upon a tempfile class, updates the temporary file's content.
Parameters
(unnamed)
- description: Either an object reference or text.
Syntax
my $content_was_saved = $tempfile->save_content('write this into the tempfile');
Return value
1
Categories: TOM | TOM::Temp | Libs