开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜