ruby / tempfile

A utility class for managing temporary files.
Other
29 stars 10 forks source link

Add 'perm' keyword argument. #22

Closed 0x1eef closed 5 months ago

0x1eef commented 11 months ago

Allow a temporary file to be created with no read, write or execute permissions for any user or group. You could also choose another set of permissions. Similar to File.new and File.open. Continue with the default of 0600.

Example:

tmpfile = Tempfile.new("foo", perm: 0)
tmpfile.write("bar") # => 3
tmpfile.rewind
tmpfile.read # => bar
tmpfile.stat.mode & 0777 # => 0

I don't know if this will be accepted or not; if there is interest in it I can update the docs. Thanks.

0x1eef commented 5 months ago

It doesn't look like this pull request will be merged. Closing.