torquebox-vfs 1.0.0.CR1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gem_hook.rb +18 -0
- data/lib/jboss-common-core-2.2.17.GA.jar +0 -0
- data/lib/jboss-logging-3.0.0.Beta4.jar +0 -0
- data/lib/jboss-logging-spi-2.2.0.CR1.jar +0 -0
- data/lib/jboss-logmanager-1.2.0.CR9.jar +0 -0
- data/lib/jboss-logmanager-log4j-1.0.0.CR3.jar +0 -0
- data/lib/jboss-vfs-3.0.0.GA.jar +0 -0
- data/lib/log4j-1.2.14.jar +0 -0
- data/lib/org.torquebox.vfs.rb +20 -0
- data/lib/torquebox/vfs/debug_filter.rb +37 -0
- data/lib/torquebox/vfs/dir.rb +78 -0
- data/lib/torquebox/vfs/ext/dir.rb +188 -0
- data/lib/torquebox/vfs/ext/file.rb +278 -0
- data/lib/torquebox/vfs/ext/file_test.rb +48 -0
- data/lib/torquebox/vfs/ext/io.rb +158 -0
- data/lib/torquebox/vfs/ext/jdbc.rb +65 -0
- data/lib/torquebox/vfs/ext/kernel.rb +30 -0
- data/lib/torquebox/vfs/ext/pathname.rb +31 -0
- data/lib/torquebox/vfs/ext/tempfile.rb +31 -0
- data/lib/torquebox/vfs/ext/vfs.rb +24 -0
- data/lib/torquebox/vfs/ext/virtual_file.rb +72 -0
- data/lib/torquebox/vfs/file.rb +188 -0
- data/lib/torquebox/vfs/glob_filter.rb +46 -0
- data/lib/torquebox/vfs/glob_translator.rb +204 -0
- data/lib/torquebox/vfs.rb +100 -0
- data/lib/torquebox-vfs.jar +0 -0
- data/lib/torquebox-vfs.rb +20 -0
- data/lib/vfs.rb +20 -0
- data/licenses/lgpl-2.1.txt +504 -0
- data/spec/dir_spec.rb +259 -0
- data/spec/file_spec.rb +451 -0
- data/spec/file_test_spec.rb +34 -0
- data/spec/io_spec.rb +82 -0
- data/spec/jdbc_spec.rb +68 -0
- data/spec/pathname_spec.rb +20 -0
- data/spec/spec_helper.rb +171 -0
- data/spec/vfs_dir_spec.rb +23 -0
- data/spec/vfs_spec.rb +36 -0
- metadata +121 -0
@@ -0,0 +1,158 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
require 'torquebox/vfs/ext/virtual_file'
|
19
|
+
|
20
|
+
class IO
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
#alias_method :open_without_vfs, :open
|
25
|
+
alias_method :read_without_vfs, :read
|
26
|
+
alias_method :readlines_without_vfs, :readlines
|
27
|
+
|
28
|
+
def vfs_open(fd,mode_str='r', &block)
|
29
|
+
append = false
|
30
|
+
truncate = false
|
31
|
+
write = false
|
32
|
+
read = false
|
33
|
+
create = false
|
34
|
+
case ( mode_str )
|
35
|
+
when /r/
|
36
|
+
read = true
|
37
|
+
write = false
|
38
|
+
append = false
|
39
|
+
create = false
|
40
|
+
when /r\+/
|
41
|
+
read = true
|
42
|
+
write = true
|
43
|
+
create = false
|
44
|
+
append = false
|
45
|
+
when /w/
|
46
|
+
read = false
|
47
|
+
write = true
|
48
|
+
create = true
|
49
|
+
append = false
|
50
|
+
truncate = true
|
51
|
+
when /w\+/
|
52
|
+
read = false
|
53
|
+
write = true
|
54
|
+
create = true
|
55
|
+
append = false
|
56
|
+
truncate = true
|
57
|
+
when /a/
|
58
|
+
read = false
|
59
|
+
write = true
|
60
|
+
create = true
|
61
|
+
append = true
|
62
|
+
when /a\+/
|
63
|
+
read = true
|
64
|
+
write = true
|
65
|
+
create = true
|
66
|
+
when Fixnum
|
67
|
+
if ( mode_str & File::RDONLY != 0 )
|
68
|
+
read = true
|
69
|
+
write = false
|
70
|
+
end
|
71
|
+
if ( mode_str & File::WRONLY != 0 )
|
72
|
+
read = false
|
73
|
+
write = true
|
74
|
+
end
|
75
|
+
if ( mode_str & File::RDWR != 0)
|
76
|
+
read = true
|
77
|
+
write = true
|
78
|
+
end
|
79
|
+
if ( mode_str & File::APPEND != 0)
|
80
|
+
append = true
|
81
|
+
end
|
82
|
+
if ( mode_str & File::TRUNC != 0)
|
83
|
+
append = false
|
84
|
+
truncate = true
|
85
|
+
end
|
86
|
+
if ( mode_str & File::CREAT != 0)
|
87
|
+
create = true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# VFS doesn't correctly handle relative paths when
|
92
|
+
# retrieving the physical file so expand it
|
93
|
+
fd = File.expand_path( fd )
|
94
|
+
virtual_file = org.jboss.vfs.VFS.child( fd )
|
95
|
+
|
96
|
+
if ( ! create && ! virtual_file.exists )
|
97
|
+
raise Errno::ENOENT
|
98
|
+
end
|
99
|
+
|
100
|
+
if ( read && ! write )
|
101
|
+
java_in = virtual_file.open_stream()
|
102
|
+
ruby_io = java_in.to_io
|
103
|
+
elsif ( write && ! read )
|
104
|
+
physical_file = virtual_file.physical_file
|
105
|
+
java_out = java.io::FileOutputStream.new( physical_file, append )
|
106
|
+
ruby_io = java_out.to_io
|
107
|
+
elsif ( read && write )
|
108
|
+
raise Error.new( "Random-access on VFS not supported" )
|
109
|
+
end
|
110
|
+
|
111
|
+
file_io = TorqueBox::VFS::Ext::VirtualFile.new( ruby_io, fd )
|
112
|
+
|
113
|
+
if ( block )
|
114
|
+
begin
|
115
|
+
block.call( file_io )
|
116
|
+
ensure
|
117
|
+
file_io.close
|
118
|
+
end
|
119
|
+
else
|
120
|
+
return file_io
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
# 1.8: IO.read( portname, <length=$/ <,offset>> )
|
127
|
+
# 1.9: IO.read( portname, <length=$/ <,offset>> <,options-for-open> )
|
128
|
+
def read(name, *options)
|
129
|
+
length, offset = options unless options.first.is_a?( Hash ) #1.9
|
130
|
+
|
131
|
+
if ::File.exist_without_vfs?( name )
|
132
|
+
read_without_vfs( name, *options )
|
133
|
+
else
|
134
|
+
# FIXME: we're ignoring the 1.9 options (encoding, mode, open_args)
|
135
|
+
vfs_open( name ) do |f|
|
136
|
+
f.seek( offset ) if offset
|
137
|
+
f.read( length )
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
# 1.8: IO.readlines( portname, separator=$/ )
|
144
|
+
# 1.9: IO.readlines( portname, separator=$/ <, options-for-open> )
|
145
|
+
# IO.readlines( portname, limit <, options-for-open> )
|
146
|
+
# IO.readlines( portname, separator, limit <, options-for-open> )
|
147
|
+
def readlines(name, *options)
|
148
|
+
if ::File.exist_without_vfs?( name )
|
149
|
+
readlines_without_vfs( name, *options )
|
150
|
+
else
|
151
|
+
opts = options.pop if options.last.is_a?( Hash ) #1.9
|
152
|
+
# FIXME: we're ignoring the 1.9 options (encoding, mode, open_args)
|
153
|
+
vfs_open( name ).readlines( *options )
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
class Java::java.sql::DriverManager
|
19
|
+
class << self
|
20
|
+
alias_method :get_connection_without_vfs, :getConnection
|
21
|
+
alias_method :register_driver_without_vfs, :registerDriver
|
22
|
+
|
23
|
+
# Monkey patch getConnection so we can sort out local filesystem url's for
|
24
|
+
# SQLite (we need to remove the 'vfs:' from the url)
|
25
|
+
def getConnection(url, *params)
|
26
|
+
|
27
|
+
# Remove any VFS prefix from the url (for SQLite)
|
28
|
+
url = url.sub(':vfs:', ':')
|
29
|
+
|
30
|
+
# Call the correct version based on the number of arguments
|
31
|
+
raise NotImplementedError.new('Need to hande the single param version of getConnection') if params.count == 0
|
32
|
+
params.count == 1 ? get_connection_with_properties(url, params.first) : get_connection_with_username_password(url, params[0], params[1])
|
33
|
+
end
|
34
|
+
|
35
|
+
def registerDriver(driver)
|
36
|
+
# Should this call the aliased method ??
|
37
|
+
@driver = driver
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
# The 2 param version of getConnection passing in url and a hash of properties
|
43
|
+
def get_connection_with_properties(url, properties)
|
44
|
+
get_connection_without_vfs(url, properties)
|
45
|
+
rescue => e
|
46
|
+
raise e unless @driver
|
47
|
+
# If we did register a driver, try to connection using it directly
|
48
|
+
@driver.connect(url, properties)
|
49
|
+
end
|
50
|
+
|
51
|
+
# The 3 param version of getConnection passing in url, username and pasword
|
52
|
+
def get_connection_with_username_password(url, user, pass)
|
53
|
+
get_connection_without_vfs(url, user, pass)
|
54
|
+
rescue => e
|
55
|
+
# If we didn't register a driver, throw the exception
|
56
|
+
raise e unless @driver
|
57
|
+
# If we did register a driver, try to connection using it directly
|
58
|
+
props = java.util.Properties.new
|
59
|
+
props.setProperty("user", user)
|
60
|
+
props.setProperty("password", pass)
|
61
|
+
@driver.connect(url, props)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
module Kernel
|
19
|
+
|
20
|
+
private
|
21
|
+
alias_method :open_without_vfs, :open
|
22
|
+
|
23
|
+
def open(name, *rest, &block)
|
24
|
+
if ( name =~ /^vfs:/ )
|
25
|
+
return IO.vfs_open( name, *rest, &block )
|
26
|
+
end
|
27
|
+
open_without_vfs( name, *rest, &block )
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
require 'pathname'
|
19
|
+
|
20
|
+
class Pathname
|
21
|
+
|
22
|
+
alias_method :realpath_without_vfs, :realpath
|
23
|
+
|
24
|
+
def realpath
|
25
|
+
vfs_path? ? expand_path : realpath_without_vfs
|
26
|
+
end
|
27
|
+
|
28
|
+
def vfs_path?
|
29
|
+
@path.to_s =~ /^vfs:/
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
require 'tempfile'
|
19
|
+
require 'tmpdir'
|
20
|
+
|
21
|
+
class Tempfile
|
22
|
+
class << self
|
23
|
+
|
24
|
+
alias_method :new_without_vfs, :new
|
25
|
+
|
26
|
+
def new(basename, tmpdir=Dir.tmpdir)
|
27
|
+
new_without_vfs(basename, File.name_without_vfs(tmpdir))
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
class Java::org.jboss.vfs::VFS
|
19
|
+
def self.child(uri_str)
|
20
|
+
uri = java.net.URI.new( uri_str.gsub('%', '%25').gsub(' ', '%20').gsub('#', '%23') )
|
21
|
+
child = self.getChild( uri )
|
22
|
+
child
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
require 'delegate'
|
19
|
+
|
20
|
+
module TorqueBox
|
21
|
+
module VFS
|
22
|
+
module Ext
|
23
|
+
class VirtualFile < SimpleDelegator
|
24
|
+
|
25
|
+
def initialize(io, path=nil)
|
26
|
+
super(io)
|
27
|
+
@path = path
|
28
|
+
end
|
29
|
+
|
30
|
+
def atime()
|
31
|
+
::File.atime( path )
|
32
|
+
end
|
33
|
+
|
34
|
+
def chmod(mode_int)
|
35
|
+
::File.chmod( mode_int, path )
|
36
|
+
end
|
37
|
+
|
38
|
+
def chown(owner_int, group_int)
|
39
|
+
::File.chown( owner_int, group_int, path )
|
40
|
+
end
|
41
|
+
|
42
|
+
def ctime()
|
43
|
+
::File.ctime( path )
|
44
|
+
end
|
45
|
+
|
46
|
+
def flock(locking_constant)
|
47
|
+
# not supported
|
48
|
+
end
|
49
|
+
|
50
|
+
def lstat()
|
51
|
+
::File.stat( path )
|
52
|
+
end
|
53
|
+
|
54
|
+
def mtime()
|
55
|
+
::File.mtime( path )
|
56
|
+
end
|
57
|
+
|
58
|
+
def o_chmod(mode_int)
|
59
|
+
self.chmod(mode_int)
|
60
|
+
end
|
61
|
+
|
62
|
+
def path()
|
63
|
+
@path
|
64
|
+
end
|
65
|
+
|
66
|
+
def truncate(max_len)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
module TorqueBox
|
19
|
+
module VFS
|
20
|
+
module File
|
21
|
+
class Stat
|
22
|
+
def initialize(virtual_file)
|
23
|
+
@virtual_file = virtual_file
|
24
|
+
end
|
25
|
+
|
26
|
+
def cmp(other)
|
27
|
+
@virtual_file.last_modified <=> other.last_modified
|
28
|
+
end
|
29
|
+
|
30
|
+
def atime()
|
31
|
+
Time.at( @virtual_file.last_modified )
|
32
|
+
end
|
33
|
+
|
34
|
+
def blksize
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def blockdev?
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
def blocks
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def chardev?
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def ctime
|
51
|
+
Time.at( @virtual_file.last_modified )
|
52
|
+
end
|
53
|
+
|
54
|
+
def dev
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
|
58
|
+
def dev_major
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
|
62
|
+
def dev_minor
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def directory?
|
67
|
+
@virtual_file.exists && ! @virtual_file.is_leaf
|
68
|
+
end
|
69
|
+
|
70
|
+
def executable?
|
71
|
+
false
|
72
|
+
end
|
73
|
+
|
74
|
+
def executable_real?
|
75
|
+
false
|
76
|
+
end
|
77
|
+
|
78
|
+
def file?
|
79
|
+
true
|
80
|
+
end
|
81
|
+
|
82
|
+
def ftype
|
83
|
+
return 'file' if @virtual_file.is_leaf
|
84
|
+
'directory'
|
85
|
+
end
|
86
|
+
|
87
|
+
def gid
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
91
|
+
def grpowned?
|
92
|
+
false
|
93
|
+
end
|
94
|
+
|
95
|
+
def ino
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
|
99
|
+
def mode
|
100
|
+
0x444
|
101
|
+
end
|
102
|
+
|
103
|
+
def mtime
|
104
|
+
Time.at( @virtual_file.getLastModified() / 1000 )
|
105
|
+
end
|
106
|
+
|
107
|
+
def nlink
|
108
|
+
1
|
109
|
+
end
|
110
|
+
|
111
|
+
def owned?
|
112
|
+
false
|
113
|
+
end
|
114
|
+
|
115
|
+
def pipe?
|
116
|
+
false
|
117
|
+
end
|
118
|
+
|
119
|
+
def rdev
|
120
|
+
nil
|
121
|
+
end
|
122
|
+
|
123
|
+
def rdev_major
|
124
|
+
nil
|
125
|
+
end
|
126
|
+
|
127
|
+
def rdev_minor
|
128
|
+
nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def readable?
|
132
|
+
true
|
133
|
+
end
|
134
|
+
|
135
|
+
def readable_real?
|
136
|
+
true
|
137
|
+
end
|
138
|
+
|
139
|
+
def setgid?
|
140
|
+
false
|
141
|
+
end
|
142
|
+
|
143
|
+
def setuid?
|
144
|
+
false
|
145
|
+
end
|
146
|
+
|
147
|
+
def size
|
148
|
+
@virtual_file.size
|
149
|
+
end
|
150
|
+
|
151
|
+
def socket?
|
152
|
+
false
|
153
|
+
end
|
154
|
+
|
155
|
+
def sticky?
|
156
|
+
false
|
157
|
+
end
|
158
|
+
|
159
|
+
def symlink?
|
160
|
+
false
|
161
|
+
end
|
162
|
+
|
163
|
+
def uid
|
164
|
+
nil
|
165
|
+
end
|
166
|
+
|
167
|
+
def writable?
|
168
|
+
begin
|
169
|
+
physical_file = @virtual_file.physical_file
|
170
|
+
physical_file.canWrite
|
171
|
+
rescue => e
|
172
|
+
false
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def writable_real?
|
177
|
+
writable?
|
178
|
+
end
|
179
|
+
|
180
|
+
def zero?
|
181
|
+
self.size == 0
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Copyright 2008-2011 Red Hat, Inc, and individual contributors.
|
2
|
+
#
|
3
|
+
# This is free software; you can redistribute it and/or modify it
|
4
|
+
# under the terms of the GNU Lesser General Public License as
|
5
|
+
# published by the Free Software Foundation; either version 2.1 of
|
6
|
+
# the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This software is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this software; if not, write to the Free
|
15
|
+
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
16
|
+
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
17
|
+
|
18
|
+
require 'torquebox/vfs/glob_translator'
|
19
|
+
|
20
|
+
|
21
|
+
module TorqueBox
|
22
|
+
module VFS
|
23
|
+
class GlobFilter
|
24
|
+
include Java::org.jboss.vfs.VirtualFileFilter
|
25
|
+
|
26
|
+
def initialize(child_path, glob)
|
27
|
+
regexp_str = GlobTranslator.translate( glob )
|
28
|
+
if ( child_path && child_path != '' )
|
29
|
+
if ( child_path[-1,1] == '/' )
|
30
|
+
regexp_str = "^#{child_path}#{regexp_str}$"
|
31
|
+
else
|
32
|
+
regexp_str = "^#{child_path}/#{regexp_str}$"
|
33
|
+
end
|
34
|
+
else
|
35
|
+
regexp_str = "^#{regexp_str}$"
|
36
|
+
end
|
37
|
+
@regexp = Regexp.new( regexp_str )
|
38
|
+
end
|
39
|
+
|
40
|
+
def accepts(file)
|
41
|
+
!!( file.path_name =~ @regexp )
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|