Created
May 29, 2020 09:57
-
-
Save AbePralle/ae4b5176a1e8ec2053d2c76a044e3ba8 to your computer and use it in GitHub Desktop.
Using 'use' to create temporary files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use file = TempFile("test") | |
| trace file.filepath | |
| local printer = file.print_writer | |
| printer.println "Hello World!" | |
| printer.close | |
| endUse | |
| class TempFile( base_name:String ) | |
| METHODS | |
| method on_use->File | |
| return File( "/tmp/$-$" (base_name,Random.int32->String(&hex)) ) | |
| method on_end_use( file:File ) | |
| if (file.exists) file.delete | |
| endClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment