sys-filesystem 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +5 -0
- data/MANIFEST +6 -0
- data/lib/unix/sys/filesystem.rb +15 -211
- data/lib/unix/sys/filesystem/constants.rb +41 -0
- data/lib/unix/sys/filesystem/functions.rb +42 -0
- data/lib/unix/sys/filesystem/structs.rb +146 -0
- data/lib/windows/sys/filesystem.rb +4 -8
- data/sys-filesystem.gemspec +1 -1
- data/test/test_sys_filesystem_unix.rb +1 -1
- data/test/test_sys_filesystem_windows.rb +1 -1
- metadata +14 -12
- data/lib/windows/sys/filesystem/structs.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f327fef3cb85ed846772a5711f8bc872f873a570
|
4
|
+
data.tar.gz: 82f7d83b2c34a93792ccb13f1ee474d7d7662f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b61b3a47d2b1f9f09993e2225cdcff38946b68af20f3bfacd0f8ae55bf62a1d35a8fb2b890268774e9e32b0adbcc0634d048265ca607b3a67ec7a05a6b101cc
|
7
|
+
data.tar.gz: 8fdc0582a2ff279c6c2844ed9523f4df5ceb436f864d06f1ab5cf0eeddede7947d08229ebfe51382bc2098e87a01d7788b8d71cfc694bfc99dbd35904177bccf
|
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 1.1.4 - 15-Mar-2015
|
2
|
+
* The File.mounts method no longer raises an error if a mount point
|
3
|
+
is not accessible. Thanks go to Michael Pope for the patch.
|
4
|
+
* Some internal code reorganization.
|
5
|
+
|
1
6
|
== 1.1.3 - 1-Oct-2014
|
2
7
|
* Now ignores EPERM errors when trying to find the mount point for a path.
|
3
8
|
Thanks go to petersen for the patch.
|
data/MANIFEST
CHANGED
@@ -6,7 +6,13 @@
|
|
6
6
|
* examples/example_stat.rb
|
7
7
|
* lib/sys/filesystem.rb
|
8
8
|
* lib/unix/sys/filesystem.rb
|
9
|
+
* lib/unix/sys/filesystem/constants.rb
|
10
|
+
* lib/unix/sys/filesystem/functions.rb
|
11
|
+
* lib/unix/sys/filesystem/structs.rb
|
9
12
|
* lib/windows/sys/filesystem.rb
|
13
|
+
* lib/windows/sys/filesystem/constants.rb
|
14
|
+
* lib/windows/sys/filesystem/functions.rb
|
15
|
+
* lib/windows/sys/filesystem/helper.rb
|
10
16
|
* test/test_sys_filesystem.rb
|
11
17
|
* test/test_sys_filesystem_unix
|
12
18
|
* test/test_sys_filesystem_windows
|
data/lib/unix/sys/filesystem.rb
CHANGED
@@ -1,84 +1,22 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative 'filesystem/constants'
|
2
|
+
require_relative 'filesystem/structs'
|
3
|
+
require_relative 'filesystem/functions'
|
3
4
|
|
4
5
|
# The Sys module serves as a namespace only.
|
5
6
|
module Sys
|
6
7
|
# The Filesystem class serves as an abstract base class. Its methods
|
7
8
|
# return objects of other types. Do not instantiate.
|
8
9
|
class Filesystem
|
9
|
-
|
10
|
-
|
10
|
+
include Sys::Filesystem::Constants
|
11
|
+
include Sys::Filesystem::Structs
|
12
|
+
extend Sys::Filesystem::Functions
|
11
13
|
|
12
14
|
# The version of the sys-filesystem library.
|
13
|
-
VERSION = '1.1.
|
15
|
+
VERSION = '1.1.4'
|
14
16
|
|
15
17
|
private
|
16
18
|
|
17
|
-
|
18
|
-
attach_function(:statvfs, :statvfs64, [:string, :pointer], :int)
|
19
|
-
else
|
20
|
-
attach_function(:statvfs, [:string, :pointer], :int)
|
21
|
-
end
|
22
|
-
|
23
|
-
attach_function(:strerror, [:int], :string)
|
24
|
-
|
25
|
-
private_class_method :statvfs, :strerror
|
26
|
-
|
27
|
-
begin
|
28
|
-
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
29
|
-
attach_function(:fopen, [:string, :string], :pointer)
|
30
|
-
attach_function(:fclose, [:pointer], :int)
|
31
|
-
attach_function(:getmntent, [:pointer, :pointer], :int)
|
32
|
-
private_class_method :fopen, :fclose, :getmntent
|
33
|
-
else
|
34
|
-
attach_function(:getmntent, [:pointer], :pointer)
|
35
|
-
attach_function(:setmntent, [:string, :string], :pointer)
|
36
|
-
attach_function(:endmntent, [:pointer], :int)
|
37
|
-
private_class_method :getmntent, :setmntent, :endmntent
|
38
|
-
end
|
39
|
-
rescue FFI::NotFoundError
|
40
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
41
|
-
attach_function(:getmntinfo, :getmntinfo64, [:pointer, :int], :int)
|
42
|
-
else
|
43
|
-
attach_function(:getmntinfo, [:pointer, :int], :int)
|
44
|
-
end
|
45
|
-
private_class_method :getmntinfo
|
46
|
-
end
|
47
|
-
|
48
|
-
MNT_RDONLY = 0x00000001 # read only filesystem
|
49
|
-
MNT_SYNCHRONOUS = 0x00000002 # file system written synchronously
|
50
|
-
MNT_NOEXEC = 0x00000004 # can't exec from filesystem
|
51
|
-
MNT_NOSUID = 0x00000008 # don't honor setuid bits on fs
|
52
|
-
MNT_NODEV = 0x00000010 # don't interpret special files
|
53
|
-
MNT_UNION = 0x00000020 # union with underlying filesystem
|
54
|
-
MNT_ASYNC = 0x00000040 # file system written asynchronously
|
55
|
-
MNT_CPROTECT = 0x00000080 # file system supports content protection
|
56
|
-
MNT_EXPORTED = 0x00000100 # file system is exported
|
57
|
-
MNT_QUARANTINE = 0x00000400 # file system is quarantined
|
58
|
-
MNT_LOCAL = 0x00001000 # filesystem is stored locally
|
59
|
-
MNT_QUOTA = 0x00002000 # quotas are enabled on filesystem
|
60
|
-
MNT_ROOTFS = 0x00004000 # identifies the root filesystem
|
61
|
-
MNT_DOVOLFS = 0x00008000 # FS supports volfs (deprecated)
|
62
|
-
MNT_DONTBROWSE = 0x00100000 # FS is not appropriate path to user data
|
63
|
-
MNT_IGNORE_OWNERSHIP = 0x00200000 # VFS will ignore ownership info on FS objects
|
64
|
-
MNT_AUTOMOUNTED = 0x00400000 # filesystem was mounted by automounter
|
65
|
-
MNT_JOURNALED = 0x00800000 # filesystem is journaled
|
66
|
-
MNT_NOUSERXATTR = 0x01000000 # Don't allow user extended attributes
|
67
|
-
MNT_DEFWRITE = 0x02000000 # filesystem should defer writes
|
68
|
-
MNT_MULTILABEL = 0x04000000 # MAC support for individual labels
|
69
|
-
MNT_NOATIME = 0x10000000 # disable update of file access time
|
70
|
-
|
71
|
-
MNT_VISFLAGMASK = (
|
72
|
-
MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC |
|
73
|
-
MNT_NOSUID | MNT_NODEV | MNT_UNION |
|
74
|
-
MNT_ASYNC | MNT_EXPORTED | MNT_QUARANTINE |
|
75
|
-
MNT_LOCAL | MNT_QUOTA |
|
76
|
-
MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE |
|
77
|
-
MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED |
|
78
|
-
MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL |
|
79
|
-
MNT_NOATIME | MNT_CPROTECT
|
80
|
-
)
|
81
|
-
|
19
|
+
# Readable versions of constant names
|
82
20
|
@@opt_names = {
|
83
21
|
MNT_RDONLY => 'read-only',
|
84
22
|
MNT_SYNCHRONOUS => 'synchronous',
|
@@ -111,144 +49,6 @@ module Sys
|
|
111
49
|
MOUNT_FILE = 'getmntinfo'
|
112
50
|
end
|
113
51
|
|
114
|
-
class Statfs < FFI::Struct
|
115
|
-
if RbConfig::CONFIG['host_os'] =~ /bsd/i
|
116
|
-
layout(
|
117
|
-
:f_version, :uint32,
|
118
|
-
:f_type, :uint32,
|
119
|
-
:f_flags, :uint64,
|
120
|
-
:f_bsize, :uint64,
|
121
|
-
:f_iosize, :int64,
|
122
|
-
:f_blocks, :uint64,
|
123
|
-
:f_bfree, :uint64,
|
124
|
-
:f_bavail, :int64,
|
125
|
-
:f_files, :uint64,
|
126
|
-
:f_ffree, :uint64,
|
127
|
-
:f_syncwrites, :uint64,
|
128
|
-
:f_asyncwrites, :uint64,
|
129
|
-
:f_syncreads, :uint64,
|
130
|
-
:f_asyncreads, :uint64,
|
131
|
-
:f_spare, [:uint64, 10],
|
132
|
-
:f_namemax, :uint32,
|
133
|
-
:f_owner, :int32,
|
134
|
-
:f_fsid, [:int32, 2],
|
135
|
-
:f_charspare, [:char, 80],
|
136
|
-
:f_fstypename, [:char, 16],
|
137
|
-
:f_mntfromname, [:char, 88],
|
138
|
-
:f_mntonname, [:char, 88]
|
139
|
-
)
|
140
|
-
else
|
141
|
-
layout(
|
142
|
-
:f_bsize, :uint32,
|
143
|
-
:f_iosize, :int32,
|
144
|
-
:f_blocks, :uint64,
|
145
|
-
:f_bfree, :uint64,
|
146
|
-
:f_bavail, :uint64,
|
147
|
-
:f_files, :uint64,
|
148
|
-
:f_ffree, :uint64,
|
149
|
-
:f_fsid, [:int32, 2],
|
150
|
-
:f_owner, :int32,
|
151
|
-
:f_type, :uint32,
|
152
|
-
:f_flags, :uint32,
|
153
|
-
:f_fssubtype, :uint32,
|
154
|
-
:f_fstypename, [:char, 16],
|
155
|
-
:f_mntonname, [:char, 1024],
|
156
|
-
:f_mntfromname, [:char, 1024],
|
157
|
-
:f_reserved, [:uint32, 8]
|
158
|
-
)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
# The Statvfs struct represents struct statvfs from sys/statvfs.h.
|
163
|
-
class Statvfs < FFI::Struct
|
164
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
165
|
-
layout(
|
166
|
-
:f_bsize, :ulong,
|
167
|
-
:f_frsize, :ulong,
|
168
|
-
:f_blocks, :uint,
|
169
|
-
:f_bfree, :uint,
|
170
|
-
:f_bavail, :uint,
|
171
|
-
:f_files, :uint,
|
172
|
-
:f_ffree, :uint,
|
173
|
-
:f_favail, :uint,
|
174
|
-
:f_fsid, :ulong,
|
175
|
-
:f_flag, :ulong,
|
176
|
-
:f_namemax, :ulong
|
177
|
-
)
|
178
|
-
elsif RbConfig::CONFIG['host'] =~ /bsd/i
|
179
|
-
layout(
|
180
|
-
:f_bavail, :uint64,
|
181
|
-
:f_bfree, :uint64,
|
182
|
-
:f_blocks, :uint64,
|
183
|
-
:f_favail, :uint64,
|
184
|
-
:f_ffree, :uint64,
|
185
|
-
:f_files, :uint64,
|
186
|
-
:f_bsize, :ulong,
|
187
|
-
:f_flag, :ulong,
|
188
|
-
:f_frsize, :ulong,
|
189
|
-
:f_fsid, :ulong,
|
190
|
-
:f_namemax, :ulong
|
191
|
-
)
|
192
|
-
elsif RbConfig::CONFIG['host'] =~ /sunos|solaris/i
|
193
|
-
layout(
|
194
|
-
:f_bsize, :ulong,
|
195
|
-
:f_frsize, :ulong,
|
196
|
-
:f_blocks, :uint64_t,
|
197
|
-
:f_bfree, :uint64_t,
|
198
|
-
:f_bavail, :uint64_t,
|
199
|
-
:f_files, :uint64_t,
|
200
|
-
:f_ffree, :uint64_t,
|
201
|
-
:f_favail, :uint64_t,
|
202
|
-
:f_fsid, :ulong,
|
203
|
-
:f_basetype, [:char, 16],
|
204
|
-
:f_flag, :ulong,
|
205
|
-
:f_namemax, :ulong,
|
206
|
-
:f_fstr, [:char, 32],
|
207
|
-
:f_filler, [:ulong, 16]
|
208
|
-
)
|
209
|
-
else
|
210
|
-
layout(
|
211
|
-
:f_bsize, :ulong,
|
212
|
-
:f_frsize, :ulong,
|
213
|
-
:f_blocks, :ulong,
|
214
|
-
:f_bfree, :ulong,
|
215
|
-
:f_bavail, :ulong,
|
216
|
-
:f_files, :ulong,
|
217
|
-
:f_ffree, :ulong,
|
218
|
-
:f_favail, :ulong,
|
219
|
-
:f_fsid, :ulong,
|
220
|
-
:f_flag, :ulong,
|
221
|
-
:f_namemax, :ulong,
|
222
|
-
:f_ftype, :ulong,
|
223
|
-
:f_basetype, [:char, 16],
|
224
|
-
:f_str, [:char, 16]
|
225
|
-
)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
# The Mnttab struct represents struct mnnttab from sys/mnttab.h on Solaris.
|
230
|
-
class Mnttab < FFI::Struct
|
231
|
-
layout(
|
232
|
-
:mnt_special, :string,
|
233
|
-
:mnt_mountp, :string,
|
234
|
-
:mnt_fstype, :string,
|
235
|
-
:mnt_mntopts, :string,
|
236
|
-
:mnt_time, :string
|
237
|
-
)
|
238
|
-
end
|
239
|
-
|
240
|
-
# The Mntent struct represents struct mntent from sys/mount.h on Unix.
|
241
|
-
class Mntent < FFI::Struct
|
242
|
-
layout(
|
243
|
-
:mnt_fsname, :string,
|
244
|
-
:mnt_dir, :string,
|
245
|
-
:mnt_type, :string,
|
246
|
-
:mnt_opts, :string,
|
247
|
-
:mnt_freq, :int,
|
248
|
-
:mnt_passno, :int
|
249
|
-
)
|
250
|
-
end
|
251
|
-
|
252
52
|
public
|
253
53
|
|
254
54
|
# The error raised if any of the Filesystem methods fail.
|
@@ -557,9 +357,13 @@ module Sys
|
|
557
357
|
|
558
358
|
self.mounts.each{ |mnt|
|
559
359
|
mp = mnt.mount_point
|
560
|
-
|
561
|
-
|
562
|
-
|
360
|
+
begin
|
361
|
+
if File.stat(mp).dev == dev
|
362
|
+
val = mp
|
363
|
+
break
|
364
|
+
end
|
365
|
+
rescue Errno::EACCES
|
366
|
+
next
|
563
367
|
end
|
564
368
|
}
|
565
369
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Sys
|
2
|
+
class Filesystem
|
3
|
+
module Constants
|
4
|
+
private
|
5
|
+
|
6
|
+
MNT_RDONLY = 0x00000001 # read only filesystem
|
7
|
+
MNT_SYNCHRONOUS = 0x00000002 # file system written synchronously
|
8
|
+
MNT_NOEXEC = 0x00000004 # can't exec from filesystem
|
9
|
+
MNT_NOSUID = 0x00000008 # don't honor setuid bits on fs
|
10
|
+
MNT_NODEV = 0x00000010 # don't interpret special files
|
11
|
+
MNT_UNION = 0x00000020 # union with underlying filesystem
|
12
|
+
MNT_ASYNC = 0x00000040 # file system written asynchronously
|
13
|
+
MNT_CPROTECT = 0x00000080 # file system supports content protection
|
14
|
+
MNT_EXPORTED = 0x00000100 # file system is exported
|
15
|
+
MNT_QUARANTINE = 0x00000400 # file system is quarantined
|
16
|
+
MNT_LOCAL = 0x00001000 # filesystem is stored locally
|
17
|
+
MNT_QUOTA = 0x00002000 # quotas are enabled on filesystem
|
18
|
+
MNT_ROOTFS = 0x00004000 # identifies the root filesystem
|
19
|
+
MNT_DOVOLFS = 0x00008000 # FS supports volfs (deprecated)
|
20
|
+
MNT_DONTBROWSE = 0x00100000 # FS is not appropriate path to user data
|
21
|
+
MNT_IGNORE_OWNERSHIP = 0x00200000 # VFS will ignore ownership info on FS objects
|
22
|
+
MNT_AUTOMOUNTED = 0x00400000 # filesystem was mounted by automounter
|
23
|
+
MNT_JOURNALED = 0x00800000 # filesystem is journaled
|
24
|
+
MNT_NOUSERXATTR = 0x01000000 # Don't allow user extended attributes
|
25
|
+
MNT_DEFWRITE = 0x02000000 # filesystem should defer writes
|
26
|
+
MNT_MULTILABEL = 0x04000000 # MAC support for individual labels
|
27
|
+
MNT_NOATIME = 0x10000000 # disable update of file access time
|
28
|
+
|
29
|
+
MNT_VISFLAGMASK = (
|
30
|
+
MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC |
|
31
|
+
MNT_NOSUID | MNT_NODEV | MNT_UNION |
|
32
|
+
MNT_ASYNC | MNT_EXPORTED | MNT_QUARANTINE |
|
33
|
+
MNT_LOCAL | MNT_QUOTA |
|
34
|
+
MNT_ROOTFS | MNT_DOVOLFS | MNT_DONTBROWSE |
|
35
|
+
MNT_IGNORE_OWNERSHIP | MNT_AUTOMOUNTED | MNT_JOURNALED |
|
36
|
+
MNT_NOUSERXATTR | MNT_DEFWRITE | MNT_MULTILABEL |
|
37
|
+
MNT_NOATIME | MNT_CPROTECT
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module Sys
|
4
|
+
class Filesystem
|
5
|
+
module Functions
|
6
|
+
extend FFI::Library
|
7
|
+
|
8
|
+
ffi_lib FFI::Library::LIBC
|
9
|
+
|
10
|
+
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
11
|
+
attach_function(:statvfs, :statvfs64, [:string, :pointer], :int)
|
12
|
+
else
|
13
|
+
attach_function(:statvfs, [:string, :pointer], :int)
|
14
|
+
end
|
15
|
+
|
16
|
+
attach_function(:strerror, [:int], :string)
|
17
|
+
|
18
|
+
private_class_method :statvfs, :strerror
|
19
|
+
|
20
|
+
begin
|
21
|
+
if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
|
22
|
+
attach_function(:fopen, [:string, :string], :pointer)
|
23
|
+
attach_function(:fclose, [:pointer], :int)
|
24
|
+
attach_function(:getmntent, [:pointer, :pointer], :int)
|
25
|
+
private_class_method :fopen, :fclose, :getmntent
|
26
|
+
else
|
27
|
+
attach_function(:getmntent, [:pointer], :pointer)
|
28
|
+
attach_function(:setmntent, [:string, :string], :pointer)
|
29
|
+
attach_function(:endmntent, [:pointer], :int)
|
30
|
+
private_class_method :getmntent, :setmntent, :endmntent
|
31
|
+
end
|
32
|
+
rescue FFI::NotFoundError
|
33
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
34
|
+
attach_function(:getmntinfo, :getmntinfo64, [:pointer, :int], :int)
|
35
|
+
else
|
36
|
+
attach_function(:getmntinfo, [:pointer, :int], :int)
|
37
|
+
end
|
38
|
+
private_class_method :getmntinfo
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
module Sys
|
5
|
+
class Filesystem
|
6
|
+
module Structs
|
7
|
+
class Statfs < FFI::Struct
|
8
|
+
if RbConfig::CONFIG['host_os'] =~ /bsd/i
|
9
|
+
layout(
|
10
|
+
:f_version, :uint32,
|
11
|
+
:f_type, :uint32,
|
12
|
+
:f_flags, :uint64,
|
13
|
+
:f_bsize, :uint64,
|
14
|
+
:f_iosize, :int64,
|
15
|
+
:f_blocks, :uint64,
|
16
|
+
:f_bfree, :uint64,
|
17
|
+
:f_bavail, :int64,
|
18
|
+
:f_files, :uint64,
|
19
|
+
:f_ffree, :uint64,
|
20
|
+
:f_syncwrites, :uint64,
|
21
|
+
:f_asyncwrites, :uint64,
|
22
|
+
:f_syncreads, :uint64,
|
23
|
+
:f_asyncreads, :uint64,
|
24
|
+
:f_spare, [:uint64, 10],
|
25
|
+
:f_namemax, :uint32,
|
26
|
+
:f_owner, :int32,
|
27
|
+
:f_fsid, [:int32, 2],
|
28
|
+
:f_charspare, [:char, 80],
|
29
|
+
:f_fstypename, [:char, 16],
|
30
|
+
:f_mntfromname, [:char, 88],
|
31
|
+
:f_mntonname, [:char, 88]
|
32
|
+
)
|
33
|
+
else
|
34
|
+
layout(
|
35
|
+
:f_bsize, :uint32,
|
36
|
+
:f_iosize, :int32,
|
37
|
+
:f_blocks, :uint64,
|
38
|
+
:f_bfree, :uint64,
|
39
|
+
:f_bavail, :uint64,
|
40
|
+
:f_files, :uint64,
|
41
|
+
:f_ffree, :uint64,
|
42
|
+
:f_fsid, [:int32, 2],
|
43
|
+
:f_owner, :int32,
|
44
|
+
:f_type, :uint32,
|
45
|
+
:f_flags, :uint32,
|
46
|
+
:f_fssubtype, :uint32,
|
47
|
+
:f_fstypename, [:char, 16],
|
48
|
+
:f_mntonname, [:char, 1024],
|
49
|
+
:f_mntfromname, [:char, 1024],
|
50
|
+
:f_reserved, [:uint32, 8]
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# The Statvfs struct represents struct statvfs from sys/statvfs.h.
|
56
|
+
class Statvfs < FFI::Struct
|
57
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
|
58
|
+
layout(
|
59
|
+
:f_bsize, :ulong,
|
60
|
+
:f_frsize, :ulong,
|
61
|
+
:f_blocks, :uint,
|
62
|
+
:f_bfree, :uint,
|
63
|
+
:f_bavail, :uint,
|
64
|
+
:f_files, :uint,
|
65
|
+
:f_ffree, :uint,
|
66
|
+
:f_favail, :uint,
|
67
|
+
:f_fsid, :ulong,
|
68
|
+
:f_flag, :ulong,
|
69
|
+
:f_namemax, :ulong
|
70
|
+
)
|
71
|
+
elsif RbConfig::CONFIG['host'] =~ /bsd/i
|
72
|
+
layout(
|
73
|
+
:f_bavail, :uint64,
|
74
|
+
:f_bfree, :uint64,
|
75
|
+
:f_blocks, :uint64,
|
76
|
+
:f_favail, :uint64,
|
77
|
+
:f_ffree, :uint64,
|
78
|
+
:f_files, :uint64,
|
79
|
+
:f_bsize, :ulong,
|
80
|
+
:f_flag, :ulong,
|
81
|
+
:f_frsize, :ulong,
|
82
|
+
:f_fsid, :ulong,
|
83
|
+
:f_namemax, :ulong
|
84
|
+
)
|
85
|
+
elsif RbConfig::CONFIG['host'] =~ /sunos|solaris/i
|
86
|
+
layout(
|
87
|
+
:f_bsize, :ulong,
|
88
|
+
:f_frsize, :ulong,
|
89
|
+
:f_blocks, :uint64_t,
|
90
|
+
:f_bfree, :uint64_t,
|
91
|
+
:f_bavail, :uint64_t,
|
92
|
+
:f_files, :uint64_t,
|
93
|
+
:f_ffree, :uint64_t,
|
94
|
+
:f_favail, :uint64_t,
|
95
|
+
:f_fsid, :ulong,
|
96
|
+
:f_basetype, [:char, 16],
|
97
|
+
:f_flag, :ulong,
|
98
|
+
:f_namemax, :ulong,
|
99
|
+
:f_fstr, [:char, 32],
|
100
|
+
:f_filler, [:ulong, 16]
|
101
|
+
)
|
102
|
+
else
|
103
|
+
layout(
|
104
|
+
:f_bsize, :ulong,
|
105
|
+
:f_frsize, :ulong,
|
106
|
+
:f_blocks, :ulong,
|
107
|
+
:f_bfree, :ulong,
|
108
|
+
:f_bavail, :ulong,
|
109
|
+
:f_files, :ulong,
|
110
|
+
:f_ffree, :ulong,
|
111
|
+
:f_favail, :ulong,
|
112
|
+
:f_fsid, :ulong,
|
113
|
+
:f_flag, :ulong,
|
114
|
+
:f_namemax, :ulong,
|
115
|
+
:f_ftype, :ulong,
|
116
|
+
:f_basetype, [:char, 16],
|
117
|
+
:f_str, [:char, 16]
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# The Mnttab struct represents struct mnnttab from sys/mnttab.h on Solaris.
|
123
|
+
class Mnttab < FFI::Struct
|
124
|
+
layout(
|
125
|
+
:mnt_special, :string,
|
126
|
+
:mnt_mountp, :string,
|
127
|
+
:mnt_fstype, :string,
|
128
|
+
:mnt_mntopts, :string,
|
129
|
+
:mnt_time, :string
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
# The Mntent struct represents struct mntent from sys/mount.h on Unix.
|
134
|
+
class Mntent < FFI::Struct
|
135
|
+
layout(
|
136
|
+
:mnt_fsname, :string,
|
137
|
+
:mnt_dir, :string,
|
138
|
+
:mnt_type, :string,
|
139
|
+
:mnt_opts, :string,
|
140
|
+
:mnt_freq, :int,
|
141
|
+
:mnt_passno, :int
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative 'filesystem/constants'
|
2
|
+
require_relative 'filesystem/functions'
|
3
|
+
require_relative 'filesystem/helper'
|
4
4
|
|
5
5
|
require 'socket'
|
6
6
|
require 'win32ole'
|
@@ -19,7 +19,7 @@ module Sys
|
|
19
19
|
class Error < StandardError; end
|
20
20
|
|
21
21
|
# The version of the sys-filesystem library.
|
22
|
-
VERSION = '1.1.
|
22
|
+
VERSION = '1.1.4'
|
23
23
|
|
24
24
|
class Mount
|
25
25
|
# The name of the volume. This is the device mapping.
|
@@ -429,7 +429,3 @@ class Numeric
|
|
429
429
|
self / 1099511627776
|
430
430
|
end
|
431
431
|
end
|
432
|
-
|
433
|
-
if $0 == __FILE__
|
434
|
-
p Sys::Filesystem.stat("C:/Users/djberge")
|
435
|
-
end
|
data/sys-filesystem.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'sys-filesystem'
|
5
|
-
spec.version = '1.1.
|
5
|
+
spec.version = '1.1.4'
|
6
6
|
spec.author = 'Daniel J. Berger'
|
7
7
|
spec.email = 'djberg96@gmail.com'
|
8
8
|
spec.homepage = 'https://github.com/djberg96/sys-filesystem'
|
@@ -19,7 +19,7 @@ class TC_Sys_Filesystem_Windows < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
test "version number is set to the expected value" do
|
22
|
-
assert_equal('1.1.
|
22
|
+
assert_equal('1.1.4', Filesystem::VERSION)
|
23
23
|
end
|
24
24
|
|
25
25
|
test "stat path works as expected" do
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-filesystem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: test-unit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.5.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: |2
|
@@ -70,11 +70,13 @@ files:
|
|
70
70
|
- examples/example_stat.rb
|
71
71
|
- lib/sys/filesystem.rb
|
72
72
|
- lib/unix/sys/filesystem.rb
|
73
|
+
- lib/unix/sys/filesystem/constants.rb
|
74
|
+
- lib/unix/sys/filesystem/functions.rb
|
75
|
+
- lib/unix/sys/filesystem/structs.rb
|
73
76
|
- lib/windows/sys/filesystem.rb
|
74
77
|
- lib/windows/sys/filesystem/constants.rb
|
75
78
|
- lib/windows/sys/filesystem/functions.rb
|
76
79
|
- lib/windows/sys/filesystem/helper.rb
|
77
|
-
- lib/windows/sys/filesystem/structs.rb
|
78
80
|
- sys-filesystem.gemspec
|
79
81
|
- test/test_sys_filesystem.rb
|
80
82
|
- test/test_sys_filesystem_unix.rb
|
@@ -89,17 +91,17 @@ require_paths:
|
|
89
91
|
- lib
|
90
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
93
|
requirements:
|
92
|
-
- -
|
94
|
+
- - ">="
|
93
95
|
- !ruby/object:Gem::Version
|
94
96
|
version: '0'
|
95
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
98
|
requirements:
|
97
|
-
- -
|
99
|
+
- - ">="
|
98
100
|
- !ruby/object:Gem::Version
|
99
101
|
version: '0'
|
100
102
|
requirements: []
|
101
103
|
rubyforge_project: sysutils
|
102
|
-
rubygems_version: 2.4.
|
104
|
+
rubygems_version: 2.4.5
|
103
105
|
signing_key:
|
104
106
|
specification_version: 4
|
105
107
|
summary: A Ruby interface for getting file system information.
|
File without changes
|