How do I set Windows-related file attributes in ruby?
How do I tel开发者_开发百科l ruby to create files with the attributes FILE_ATTRIBUTE_TEMPORARY
and FILE_FLAG_DELETE_ON_CLOSE
?
You can call Windows functions using the Ruby win32api library. See these examples. It's painful, but it works.
I grepped Ruby 1.8.7 source and did not find any mention of those attributes, so I'm thinking that you get to fix it and build from source...
Probably because of it's Unix roots, Ruby doesn't (yet) allow that. You can probably obtain the result you want with:
require 'tempfile'
Tempfile.new "my_temp_file" do |f|
#...
end
精彩评论