如何在ruby中设置与Windows相关的文件属性?

时间:2022-10-30 08:08:44

How do I tell ruby to create files with the attributes FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE?

如何告诉ruby创建具有FILE_ATTRIBUTE_TEMPORARY和FILE_FLAG_DELETE_ON_CLOSE属性的文件?

3 个解决方案

#1


3  

You can call Windows functions using the Ruby win32api library. See these examples. It's painful, but it works.

您可以使用Ruby win32api库调用Windows函数。见这些例子。这很痛苦,但它确实有效。

#2


0  

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...

我grepped Ruby 1.8.7源代码并没有找到任何提及这些属性,所以我认为你可以修复它并从源码构建...

#3


0  

Probably because of it's Unix roots, Ruby doesn't (yet) allow that. You can probably obtain the result you want with:

可能是因为它的Unix根源,Ruby(尚未)允许这样做。你可以获得你想要的结果:

require 'tempfile'
Tempfile.new "my_temp_file" do |f|
  #...
end

#1


3  

You can call Windows functions using the Ruby win32api library. See these examples. It's painful, but it works.

您可以使用Ruby win32api库调用Windows函数。见这些例子。这很痛苦,但它确实有效。

#2


0  

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...

我grepped Ruby 1.8.7源代码并没有找到任何提及这些属性,所以我认为你可以修复它并从源码构建...

#3


0  

Probably because of it's Unix roots, Ruby doesn't (yet) allow that. You can probably obtain the result you want with:

可能是因为它的Unix根源,Ruby(尚未)允许这样做。你可以获得你想要的结果:

require 'tempfile'
Tempfile.new "my_temp_file" do |f|
  #...
end