Module: BC3::Attrib
- Defined in:
- lib/bc3/helper.rb
Overview
Define DOS-Attributs.
Bit 0 Read-Only
Bit 1 Hidden
Bit 2 System
Bit 3 Volume Label
Bit 4 Directory
Bit 5 Archive
http://www.computerhope.com/attribhl.htm
Bit Positions Hex Description
0 0 0 0 0 0 0 1 01h Read Only file
0 0 0 0 0 0 1 0 02h Hidden file
0 0 0 0 0 1 0 0 04h System file
0 0 0 0 1 0 0 0 08h Volume Label
0 0 0 1 0 0 0 0 10h Subdirectory
0 0 1 0 0 0 0 0 20h Archive
0 1 0 0 0 0 0 0 40h Reserved
1 0 0 0 0 0 0 0 80h Reserved
Usage
attrib = Attrib::ReadOnly | Attrib::Hidden
Constant Summary collapse
- ReadOnly =
1- Hidden =
2- System =
4- VolumeLabel =
8- Directory =
16- Archive =
32
Class Method Summary collapse
-
.fileattrib(filename) ⇒ Object
How to read attributs/windows: blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/68298.
Class Method Details
.fileattrib(filename) ⇒ Object
How to read attributs/windows: blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/68298
Easier: call attrib and analyse output
fixme: CHeck OS
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bc3/helper.rb', line 42 def self.fileattrib(filename) attrib = 0 raise ArgumentError, "Filename #{filename} not found" unless ::File.exists?(filename) attrib += Directory if ::File.directory?(filename) res = `attrib #{filename}` attrib += ReadOnly if res =~ /\A\S*R/ attrib += Hidden if res =~ /\A\S*H/ attrib += System if res =~ /\A\S*S/ #~ attrib += VolumeLabel = if res =~ /\A\S*/ attrib += Archive if res =~ /\A\S*A/ attrib end |