sys-filesystem 1.1.6 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +162 -0
- data/Gemfile +2 -0
- data/LICENSE +177 -0
- data/{MANIFEST → MANIFEST.md} +9 -6
- data/README.md +92 -0
- data/Rakefile +14 -24
- data/certs/djberg96_pub.pem +22 -17
- data/examples/example_mount.rb +73 -0
- data/examples/example_stat.rb +2 -0
- data/lib/sys/filesystem.rb +72 -1
- data/lib/sys/unix/sys/filesystem/constants.rb +32 -3
- data/lib/sys/unix/sys/filesystem/functions.rb +36 -9
- data/lib/sys/unix/sys/filesystem/structs.rb +77 -11
- data/lib/sys/unix/sys/filesystem.rb +105 -58
- data/lib/sys/windows/sys/filesystem/functions.rb +11 -8
- data/lib/sys/windows/sys/filesystem/helper.rb +1 -1
- data/lib/sys/windows/sys/filesystem.rb +100 -81
- data/spec/spec_helper.rb +6 -0
- data/spec/sys_filesystem_unix_spec.rb +396 -0
- data/spec/sys_filesystem_windows_spec.rb +348 -0
- data/sys-filesystem.gemspec +15 -7
- data.tar.gz.sig +0 -0
- metadata +75 -61
- metadata.gz.sig +0 -0
- data/CHANGES +0 -89
- data/README +0 -80
- data/test/test_sys_filesystem.rb +0 -7
- data/test/test_sys_filesystem_unix.rb +0 -278
- data/test/test_sys_filesystem_windows.rb +0 -250
data/README
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
= Description
|
2
|
-
A Ruby interface for getting file system information.
|
3
|
-
|
4
|
-
= Installation
|
5
|
-
gem install sys-filesystem
|
6
|
-
|
7
|
-
= Synopsis
|
8
|
-
require 'sys/filesystem'
|
9
|
-
include Sys
|
10
|
-
|
11
|
-
# Display information about a particular filesystem.
|
12
|
-
p Filesystem.stat('/')
|
13
|
-
|
14
|
-
# Sample output
|
15
|
-
|
16
|
-
#<Sys::Filesystem::Stat:0x517440
|
17
|
-
@base_type = "ufs",
|
18
|
-
@flags = 4,
|
19
|
-
@files_available = 3817457,
|
20
|
-
@block_size = 8192,
|
21
|
-
@blocks_available = 19957633,
|
22
|
-
@blocks = 34349612,
|
23
|
-
@name_max = 255,
|
24
|
-
@path = "/",
|
25
|
-
@filesystem_id = 35651592,
|
26
|
-
@files = 4135040,
|
27
|
-
@fragment_size = 1024,
|
28
|
-
@files_free = 3817457,
|
29
|
-
@blocks_free = 20301129
|
30
|
-
>
|
31
|
-
|
32
|
-
# Describe all mount points on the system
|
33
|
-
Filesystem.mounts{ |mount| p mount }
|
34
|
-
|
35
|
-
# Find the mount point of any particular file
|
36
|
-
puts Filesystem.mount_point('/home/djberge/some_file.txt') => '/home'
|
37
|
-
|
38
|
-
= Notes
|
39
|
-
This is a pure Ruby implementation that uses FFI. This means it should work
|
40
|
-
with JRuby, too.
|
41
|
-
|
42
|
-
= Sample code
|
43
|
-
Run 'rake example' if you want to see a basic sample run. The actual code
|
44
|
-
is 'example_stat.rb' in the 'examples' directory. Modify it as you see fit.
|
45
|
-
|
46
|
-
= Known Bugs
|
47
|
-
None that I'm aware of. Please report bugs on the project page at
|
48
|
-
https://github.com/djberg96/sys-filesystem
|
49
|
-
|
50
|
-
= Future Plans
|
51
|
-
Add better 64-bit support for Linux and BSD.
|
52
|
-
Other suggestions welcome.
|
53
|
-
|
54
|
-
= Acknowledgements
|
55
|
-
Mike Hall, for ideas and code that I borrowed from his 'filesystem' library.
|
56
|
-
|
57
|
-
Park Heesob, for implementation and API ideas for the MS Windows version.
|
58
|
-
|
59
|
-
Nobuyoshi Miyokawa, for adding the original FreeBSD and OS X support.
|
60
|
-
|
61
|
-
= License
|
62
|
-
Artistic 2.0
|
63
|
-
|
64
|
-
== Contributions
|
65
|
-
Although this library is free, please consider having your company
|
66
|
-
setup a gittip if used by your company professionally.
|
67
|
-
|
68
|
-
http://www.gittip.com/djberg96/
|
69
|
-
|
70
|
-
= Copyright
|
71
|
-
(C) 2003-2016 Daniel J. Berger
|
72
|
-
All Rights Reserved
|
73
|
-
|
74
|
-
= Warranty
|
75
|
-
This library is provided "as is" and without any express or
|
76
|
-
implied warranties, including, without limitation, the implied
|
77
|
-
warranties of merchantability and fitness for a particular purpose.
|
78
|
-
|
79
|
-
= Author
|
80
|
-
Daniel J. Berger
|
data/test/test_sys_filesystem.rb
DELETED
@@ -1,278 +0,0 @@
|
|
1
|
-
####################################################################
|
2
|
-
# test_sys_filesystem_unix.rb
|
3
|
-
#
|
4
|
-
# Test case for the Sys::Filesystem.stat method and related stuff.
|
5
|
-
# This test suite should be run via the 'rake test' task.
|
6
|
-
####################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'sys/filesystem'
|
9
|
-
include Sys
|
10
|
-
|
11
|
-
class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
|
12
|
-
def self.startup
|
13
|
-
@@solaris = RbConfig::CONFIG['host_os'] =~ /solaris/i
|
14
|
-
@@linux = RbConfig::CONFIG['host_os'] =~ /linux/i
|
15
|
-
@@freebsd = RbConfig::CONFIG['host_os'] =~ /freebsd/i
|
16
|
-
@@darwin = RbConfig::CONFIG['host_os'] =~ /darwin/i
|
17
|
-
end
|
18
|
-
|
19
|
-
def setup
|
20
|
-
@dir = "/"
|
21
|
-
@stat = Filesystem.stat(@dir)
|
22
|
-
@mnt = Filesystem.mounts[0]
|
23
|
-
@size = 58720256
|
24
|
-
@array = []
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_version
|
28
|
-
assert_equal('1.1.6', Filesystem::VERSION)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_stat_path
|
32
|
-
assert_respond_to(@stat, :path)
|
33
|
-
assert_equal("/", @stat.path)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_stat_block_size
|
37
|
-
assert_respond_to(@stat, :block_size)
|
38
|
-
assert_kind_of(Fixnum, @stat.block_size)
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_block_size_is_a_plausible_value
|
42
|
-
assert_true(@stat.block_size >= 1024)
|
43
|
-
assert_true(@stat.block_size <= 16384)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_stat_fragment_size
|
47
|
-
assert_respond_to(@stat, :fragment_size)
|
48
|
-
assert_kind_of(Fixnum, @stat.fragment_size)
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_stat_blocks
|
52
|
-
assert_respond_to(@stat, :blocks)
|
53
|
-
assert_kind_of(Fixnum, @stat.blocks)
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_stat_blocks_free
|
57
|
-
assert_respond_to(@stat, :blocks_free)
|
58
|
-
assert_kind_of(Fixnum, @stat.blocks_free)
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_stat_blocks_available
|
62
|
-
assert_respond_to(@stat, :blocks_available)
|
63
|
-
assert_kind_of(Fixnum, @stat.blocks_available)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_stat_files
|
67
|
-
assert_respond_to(@stat, :files)
|
68
|
-
assert_kind_of(Fixnum, @stat.files)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_inodes_alias
|
72
|
-
assert_respond_to(@stat, :inodes)
|
73
|
-
assert_true(@stat.method(:inodes) == @stat.method(:files))
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_stat_files_free
|
77
|
-
assert_respond_to(@stat, :files_free)
|
78
|
-
assert_kind_of(Fixnum, @stat.files_free)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_stat_inodes_free_alias
|
82
|
-
assert_respond_to(@stat, :inodes_free)
|
83
|
-
assert_true(@stat.method(:inodes_free) == @stat.method(:files_free))
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_stat_files_available
|
87
|
-
assert_respond_to(@stat, :files_available)
|
88
|
-
assert_kind_of(Fixnum, @stat.files_available)
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_stat_inodes_available_alias
|
92
|
-
assert_respond_to(@stat, :inodes_available)
|
93
|
-
assert_true(@stat.method(:inodes_available) == @stat.method(:files_available))
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_stat_filesystem_id
|
97
|
-
assert_respond_to(@stat, :filesystem_id)
|
98
|
-
assert_kind_of(Integer, @stat.filesystem_id)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_stat_flags
|
102
|
-
assert_respond_to(@stat, :flags)
|
103
|
-
assert_kind_of(Fixnum, @stat.flags)
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_stat_name_max
|
107
|
-
assert_respond_to(@stat, :name_max)
|
108
|
-
assert_kind_of(Fixnum, @stat.name_max)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_stat_base_type
|
112
|
-
omit_unless(@@solaris, "base_type test skipped except on Solaris")
|
113
|
-
|
114
|
-
assert_respond_to(@stat, :base_type)
|
115
|
-
assert_kind_of(String, @stat.base_type)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_stat_constants
|
119
|
-
assert_not_nil(Filesystem::Stat::RDONLY)
|
120
|
-
assert_not_nil(Filesystem::Stat::NOSUID)
|
121
|
-
|
122
|
-
omit_unless(@@solaris, "NOTRUNC test skipped except on Solaris")
|
123
|
-
|
124
|
-
assert_not_nil(Filesystem::Stat::NOTRUNC)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_stat_bytes_total
|
128
|
-
assert_respond_to(@stat, :bytes_total)
|
129
|
-
assert_kind_of(Numeric, @stat.bytes_total)
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_stat_bytes_free
|
133
|
-
assert_respond_to(@stat, :bytes_free)
|
134
|
-
assert_kind_of(Numeric, @stat.bytes_free)
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_stat_bytes_used
|
138
|
-
assert_respond_to(@stat, :bytes_used)
|
139
|
-
assert_kind_of(Numeric, @stat.bytes_used)
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_stat_percent_used
|
143
|
-
assert_respond_to(@stat, :percent_used)
|
144
|
-
assert_kind_of(Float, @stat.percent_used)
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_stat_expected_errors
|
148
|
-
assert_raises(ArgumentError){ Filesystem.stat }
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_numeric_methods_basic
|
152
|
-
assert_respond_to(@size, :to_kb)
|
153
|
-
assert_respond_to(@size, :to_mb)
|
154
|
-
assert_respond_to(@size, :to_gb)
|
155
|
-
assert_respond_to(@size, :to_tb)
|
156
|
-
end
|
157
|
-
|
158
|
-
def test_to_kb
|
159
|
-
assert_equal(57344, @size.to_kb)
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_to_mb
|
163
|
-
assert_equal(56, @size.to_mb)
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_to_gb
|
167
|
-
assert_equal(0, @size.to_gb)
|
168
|
-
end
|
169
|
-
|
170
|
-
# Filesystem::Mount tests
|
171
|
-
|
172
|
-
def test_mounts_with_no_block
|
173
|
-
assert_nothing_raised{ @array = Filesystem.mounts }
|
174
|
-
assert_kind_of(Filesystem::Mount, @array[0])
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_mounts_with_block
|
178
|
-
assert_nothing_raised{ Filesystem.mounts{ |m| @array << m } }
|
179
|
-
assert_kind_of(Filesystem::Mount, @array[0])
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_mounts_high_iteration
|
183
|
-
assert_nothing_raised{ 1000.times{ @array = Filesystem.mounts } }
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_mount_name
|
187
|
-
assert_respond_to(@mnt, :name)
|
188
|
-
assert_kind_of(String, @mnt.name)
|
189
|
-
end
|
190
|
-
|
191
|
-
def test_fsname_alias
|
192
|
-
assert_respond_to(@mnt, :fsname)
|
193
|
-
assert_true(@mnt.method(:fsname) == @mnt.method(:name))
|
194
|
-
end
|
195
|
-
|
196
|
-
def test_mount_point
|
197
|
-
assert_respond_to(@mnt, :mount_point)
|
198
|
-
assert_kind_of(String, @mnt.mount_point)
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_dir_alias
|
202
|
-
assert_respond_to(@mnt, :dir)
|
203
|
-
assert_true(@mnt.method(:dir) == @mnt.method(:mount_point))
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_mount_type
|
207
|
-
assert_respond_to(@mnt, :mount_type)
|
208
|
-
assert_kind_of(String, @mnt.mount_type)
|
209
|
-
end
|
210
|
-
|
211
|
-
def test_mount_options
|
212
|
-
assert_respond_to(@mnt, :options)
|
213
|
-
assert_kind_of(String, @mnt.options)
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_opts_alias
|
217
|
-
assert_respond_to(@mnt, :opts)
|
218
|
-
assert_true(@mnt.method(:opts) == @mnt.method(:options))
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_mount_time
|
222
|
-
assert_respond_to(@mnt, :mount_time)
|
223
|
-
|
224
|
-
if @@solaris
|
225
|
-
assert_kind_of(Time, @mnt.mount_time)
|
226
|
-
else
|
227
|
-
assert_nil(@mnt.mount_time)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_mount_dump_frequency
|
232
|
-
msg = 'dump_frequency test skipped on this platform'
|
233
|
-
omit_if(@@solaris || @@freebsd || @@darwin, msg)
|
234
|
-
assert_respond_to(@mnt, :dump_frequency)
|
235
|
-
assert_kind_of(Fixnum, @mnt.dump_frequency)
|
236
|
-
end
|
237
|
-
|
238
|
-
def test_freq_alias
|
239
|
-
assert_respond_to(@mnt, :freq)
|
240
|
-
assert_true(@mnt.method(:freq) == @mnt.method(:dump_frequency))
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_mount_pass_number
|
244
|
-
msg = 'pass_number test skipped on this platform'
|
245
|
-
omit_if(@@solaris || @@freebsd || @@darwin, msg)
|
246
|
-
assert_respond_to(@mnt, :pass_number)
|
247
|
-
assert_kind_of(Fixnum, @mnt.pass_number)
|
248
|
-
end
|
249
|
-
|
250
|
-
def test_passno_alias
|
251
|
-
assert_respond_to(@mnt, :passno)
|
252
|
-
assert_true(@mnt.method(:passno) == @mnt.method(:pass_number))
|
253
|
-
end
|
254
|
-
|
255
|
-
def test_mount_point_singleton
|
256
|
-
assert_respond_to(Filesystem, :mount_point)
|
257
|
-
assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
|
258
|
-
assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_ffi_functions_are_private
|
262
|
-
assert_false(Filesystem.methods.include?('statvfs'))
|
263
|
-
assert_false(Filesystem.methods.include?('strerror'))
|
264
|
-
end
|
265
|
-
|
266
|
-
def teardown
|
267
|
-
@dir = nil
|
268
|
-
@stat = nil
|
269
|
-
@array = nil
|
270
|
-
end
|
271
|
-
|
272
|
-
def self.shutdown
|
273
|
-
@@solaris = nil
|
274
|
-
@@linux = nil
|
275
|
-
@@freebsd = nil
|
276
|
-
@@darwin = nil
|
277
|
-
end
|
278
|
-
end
|
@@ -1,250 +0,0 @@
|
|
1
|
-
####################################################################
|
2
|
-
# test_sys_filesystem_windows.rb
|
3
|
-
#
|
4
|
-
# Test case for the Sys::Filesystem.stat method and related stuff.
|
5
|
-
# This should be run via the 'rake test' task.
|
6
|
-
####################################################################
|
7
|
-
require 'test-unit'
|
8
|
-
require 'sys/filesystem'
|
9
|
-
require 'rbconfig'
|
10
|
-
include Sys
|
11
|
-
|
12
|
-
class TC_Sys_Filesystem_Windows < Test::Unit::TestCase
|
13
|
-
def setup
|
14
|
-
@dir = 'C:/'
|
15
|
-
@stat = Filesystem.stat(@dir)
|
16
|
-
@mount = Filesystem.mounts[0]
|
17
|
-
@size = 58720256
|
18
|
-
@array = []
|
19
|
-
end
|
20
|
-
|
21
|
-
test "version number is set to the expected value" do
|
22
|
-
assert_equal('1.1.6', Filesystem::VERSION)
|
23
|
-
end
|
24
|
-
|
25
|
-
test "stat path works as expected" do
|
26
|
-
assert_respond_to(@stat, :path)
|
27
|
-
assert_equal("C:/", @stat.path)
|
28
|
-
end
|
29
|
-
|
30
|
-
test "stat block_size works as expected" do
|
31
|
-
assert_respond_to(@stat, :block_size)
|
32
|
-
assert_kind_of(Fixnum, @stat.block_size)
|
33
|
-
end
|
34
|
-
|
35
|
-
test "stat fragment_size works as expected" do
|
36
|
-
assert_respond_to(@stat, :fragment_size)
|
37
|
-
assert_nil(@stat.fragment_size)
|
38
|
-
end
|
39
|
-
|
40
|
-
test "stat blocks works as expected" do
|
41
|
-
assert_respond_to(@stat, :blocks)
|
42
|
-
assert_kind_of(Fixnum, @stat.blocks)
|
43
|
-
end
|
44
|
-
|
45
|
-
test "stat blocks_free works as expected" do
|
46
|
-
assert_respond_to(@stat, :blocks_free)
|
47
|
-
assert_kind_of(Fixnum, @stat.blocks_free)
|
48
|
-
end
|
49
|
-
|
50
|
-
test "stat blocks_available works as expected" do
|
51
|
-
assert_respond_to(@stat, :blocks_available)
|
52
|
-
assert_kind_of(Fixnum, @stat.blocks_available)
|
53
|
-
end
|
54
|
-
|
55
|
-
test "stat files works as expected" do
|
56
|
-
assert_respond_to(@stat, :files)
|
57
|
-
assert_nil(@stat.files)
|
58
|
-
end
|
59
|
-
|
60
|
-
test "stat inodes is an alias for files" do
|
61
|
-
assert_alias_method(@stat, :inodes, :files)
|
62
|
-
end
|
63
|
-
|
64
|
-
test "stat files_free works as expected" do
|
65
|
-
assert_respond_to(@stat, :files_free)
|
66
|
-
assert_nil(@stat.files_free)
|
67
|
-
end
|
68
|
-
|
69
|
-
test "stat inodes_free is an alias for files_free" do
|
70
|
-
assert_respond_to(@stat, :inodes_free)
|
71
|
-
end
|
72
|
-
|
73
|
-
test "stat files available works as expected" do
|
74
|
-
assert_respond_to(@stat, :files_available)
|
75
|
-
assert_nil(@stat.files_available)
|
76
|
-
end
|
77
|
-
|
78
|
-
test "stat inodes_available is an alias for files_available" do
|
79
|
-
assert_alias_method(@stat, :inodes_available, :files_available)
|
80
|
-
end
|
81
|
-
|
82
|
-
test "stat filesystem_id works as expected" do
|
83
|
-
assert_respond_to(@stat, :filesystem_id)
|
84
|
-
assert_kind_of(Integer, @stat.filesystem_id)
|
85
|
-
end
|
86
|
-
|
87
|
-
test "stat flags works as expected" do
|
88
|
-
assert_respond_to(@stat, :flags)
|
89
|
-
assert_kind_of(Fixnum, @stat.flags)
|
90
|
-
end
|
91
|
-
|
92
|
-
test "stat name_max works as expected" do
|
93
|
-
assert_respond_to(@stat, :name_max)
|
94
|
-
assert_kind_of(Fixnum, @stat.name_max)
|
95
|
-
end
|
96
|
-
|
97
|
-
test "stat base_type works as expected" do
|
98
|
-
assert_respond_to(@stat, :base_type)
|
99
|
-
assert_kind_of(String, @stat.base_type)
|
100
|
-
end
|
101
|
-
|
102
|
-
test "stat bytes_total basic functionality" do
|
103
|
-
assert_respond_to(@stat, :bytes_total)
|
104
|
-
assert_kind_of(Numeric, @stat.bytes_total)
|
105
|
-
end
|
106
|
-
|
107
|
-
test "stat bytes_free basic functionality" do
|
108
|
-
assert_respond_to(@stat, :bytes_free)
|
109
|
-
assert_kind_of(Numeric, @stat.bytes_free)
|
110
|
-
end
|
111
|
-
|
112
|
-
test "stat bytes_used basic functionality" do
|
113
|
-
assert_respond_to(@stat, :bytes_used)
|
114
|
-
assert_kind_of(Numeric, @stat.bytes_used)
|
115
|
-
end
|
116
|
-
|
117
|
-
test "stat percent_used basic functionality" do
|
118
|
-
assert_respond_to(@stat, :percent_used)
|
119
|
-
assert_kind_of(Float, @stat.percent_used)
|
120
|
-
end
|
121
|
-
|
122
|
-
test "mount_point singleton method basic functionality" do
|
123
|
-
assert_respond_to(Filesystem, :mount_point)
|
124
|
-
assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
|
125
|
-
assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
|
126
|
-
end
|
127
|
-
|
128
|
-
test "mount_point singleton method returns expected value" do
|
129
|
-
assert_equal("C:\\", Filesystem.mount_point("C:\\Users\\foo"))
|
130
|
-
assert_equal("\\\\foo\\bar", Filesystem.mount_point("//foo/bar/baz"))
|
131
|
-
end
|
132
|
-
|
133
|
-
test "filesystem constants are defined" do
|
134
|
-
assert_not_nil(Filesystem::CASE_SENSITIVE_SEARCH)
|
135
|
-
assert_not_nil(Filesystem::CASE_PRESERVED_NAMES)
|
136
|
-
assert_not_nil(Filesystem::UNICODE_ON_DISK)
|
137
|
-
assert_not_nil(Filesystem::PERSISTENT_ACLS)
|
138
|
-
assert_not_nil(Filesystem::FILE_COMPRESSION)
|
139
|
-
assert_not_nil(Filesystem::VOLUME_QUOTAS)
|
140
|
-
assert_not_nil(Filesystem::SUPPORTS_SPARSE_FILES)
|
141
|
-
assert_not_nil(Filesystem::SUPPORTS_REPARSE_POINTS)
|
142
|
-
assert_not_nil(Filesystem::SUPPORTS_REMOTE_STORAGE)
|
143
|
-
assert_not_nil(Filesystem::VOLUME_IS_COMPRESSED)
|
144
|
-
assert_not_nil(Filesystem::SUPPORTS_OBJECT_IDS)
|
145
|
-
assert_not_nil(Filesystem::SUPPORTS_ENCRYPTION)
|
146
|
-
assert_not_nil(Filesystem::NAMED_STREAMS)
|
147
|
-
assert_not_nil(Filesystem::READ_ONLY_VOLUME)
|
148
|
-
end
|
149
|
-
|
150
|
-
test "stat singleton method defaults to root path if proviced" do
|
151
|
-
assert_nothing_raised{ Filesystem.stat("C://Program Files") }
|
152
|
-
end
|
153
|
-
|
154
|
-
test "stat singleton method requires a single argument" do
|
155
|
-
assert_raise(ArgumentError){ Filesystem.stat }
|
156
|
-
assert_raise(ArgumentError){ Filesystem.stat(Dir.pwd, Dir.pwd) }
|
157
|
-
end
|
158
|
-
|
159
|
-
test "stat singleton method raises an error if path is not found" do
|
160
|
-
assert_raise(Errno::ESRCH){ Filesystem.stat("C://Bogus//Dir") }
|
161
|
-
end
|
162
|
-
|
163
|
-
# Filesystem.mounts
|
164
|
-
|
165
|
-
test "mounts singleton method basic functionality" do
|
166
|
-
assert_respond_to(Filesystem, :mounts)
|
167
|
-
assert_nothing_raised{ Filesystem.mounts }
|
168
|
-
assert_nothing_raised{ Filesystem.mounts{} }
|
169
|
-
end
|
170
|
-
|
171
|
-
test "mounts singleton method returns the expected value" do
|
172
|
-
assert_kind_of(Array, Filesystem.mounts)
|
173
|
-
assert_kind_of(Filesystem::Mount, Filesystem.mounts[0])
|
174
|
-
end
|
175
|
-
|
176
|
-
test "mounts singleton method works as expected when a block is provided" do
|
177
|
-
assert_nil(Filesystem.mounts{})
|
178
|
-
assert_nothing_raised{ Filesystem.mounts{ |mt| @array << mt }}
|
179
|
-
assert_kind_of(Filesystem::Mount, @array[0])
|
180
|
-
end
|
181
|
-
|
182
|
-
test "mount name works as expected" do
|
183
|
-
assert_respond_to(@mount, :name)
|
184
|
-
assert_kind_of(String, @mount.name)
|
185
|
-
end
|
186
|
-
|
187
|
-
test "mount time works as expected" do
|
188
|
-
assert_respond_to(@mount, :mount_time)
|
189
|
-
assert_kind_of(Time, @mount.mount_time)
|
190
|
-
end
|
191
|
-
|
192
|
-
test "mount type works as expected" do
|
193
|
-
assert_respond_to(@mount, :mount_type)
|
194
|
-
assert_kind_of(String, @mount.mount_type)
|
195
|
-
end
|
196
|
-
|
197
|
-
test "mount point works as expected" do
|
198
|
-
assert_respond_to(@mount, :mount_point)
|
199
|
-
assert_kind_of(String, @mount.mount_point)
|
200
|
-
end
|
201
|
-
|
202
|
-
test "mount options works as expected" do
|
203
|
-
assert_respond_to(@mount, :options)
|
204
|
-
assert_kind_of(String, @mount.options)
|
205
|
-
end
|
206
|
-
|
207
|
-
test "mount pass_number works as expected" do
|
208
|
-
assert_respond_to(@mount, :pass_number)
|
209
|
-
assert_nil(@mount.pass_number)
|
210
|
-
end
|
211
|
-
|
212
|
-
test "mount frequency works as expected" do
|
213
|
-
assert_respond_to(@mount, :frequency)
|
214
|
-
assert_nil(@mount.frequency)
|
215
|
-
end
|
216
|
-
|
217
|
-
test "mounts singleton method does not accept any arguments" do
|
218
|
-
assert_raise(ArgumentError){ Filesystem.mounts("C:\\") }
|
219
|
-
end
|
220
|
-
|
221
|
-
test "custom Fixnum#to_kb method works as expected" do
|
222
|
-
assert_respond_to(@size, :to_kb)
|
223
|
-
assert_equal(57344, @size.to_kb)
|
224
|
-
end
|
225
|
-
|
226
|
-
test "custom Fixnum#to_mb method works as expected" do
|
227
|
-
assert_respond_to(@size, :to_mb)
|
228
|
-
assert_equal(56, @size.to_mb)
|
229
|
-
end
|
230
|
-
|
231
|
-
test "custom Fixnum#to_gb method works as expected" do
|
232
|
-
assert_respond_to(@size, :to_gb)
|
233
|
-
assert_equal(0, @size.to_gb)
|
234
|
-
end
|
235
|
-
|
236
|
-
# FFI
|
237
|
-
|
238
|
-
test "internal ffi functions are not public" do
|
239
|
-
assert_false(Filesystem.methods.include?(:GetVolumeInformationA))
|
240
|
-
assert_false(Filesystem.instance_methods.include?(:GetVolumeInformationA))
|
241
|
-
end
|
242
|
-
|
243
|
-
def teardown
|
244
|
-
@array = nil
|
245
|
-
@dir = nil
|
246
|
-
@stat = nil
|
247
|
-
@size = nil
|
248
|
-
@mount = nil
|
249
|
-
end
|
250
|
-
end
|