Skip to content

Instantly share code, notes, and snippets.

@AbePralle
Created May 29, 2020 09:57
Show Gist options
  • Select an option

  • Save AbePralle/ae4b5176a1e8ec2053d2c76a044e3ba8 to your computer and use it in GitHub Desktop.

Select an option

Save AbePralle/ae4b5176a1e8ec2053d2c76a044e3ba8 to your computer and use it in GitHub Desktop.
Using 'use' to create temporary files
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