Module: TorqueBox::VFS
- Defined in:
- lib/torquebox/vfs.rb,
lib/torquebox/vfs.rb,
lib/torquebox/vfs/dir.rb,
lib/torquebox/vfs/file.rb,
lib/torquebox/vfs/glob_filter.rb,
lib/torquebox/vfs/debug_filter.rb,
lib/torquebox/vfs/glob_translator.rb,
lib/torquebox/vfs/ext/virtual_file.rb
Defined Under Namespace
Modules: Ext, File
Classes: DebugFilter, Dir, GlobFilter, GlobTranslator
Class Method Summary
collapse
Class Method Details
.resolve_path_url(path) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/torquebox/vfs.rb', line 60
def self.resolve_path_url(path)
prefix = case
when path =~ /^\// "vfs:"
when path =~ /^[[:alpha:]]:/ "vfs:/"
else
"#{resolve_path_url( ::Dir.pwd )}/"
end
"#{prefix}#{path}"
end
|
.resolve_within_archive(path) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/torquebox/vfs.rb', line 40
def self.resolve_within_archive(path)
path = path.to_s
return path if ( path =~ %r(^vfs:) )
cur = path
trim_size = cur.length
while ( cur != '.' && cur != '/' )
if ( ::File.exist_without_vfs?( cur ) )
child_path = path[trim_size..-1]
if ( cur[-1,1] == '/' )
cur = cur[0..-2]
end
return TorqueBox::VFS.resolve_path_url( cur ), child_path
end
cur = ::File.dirname( cur )
trim_size = cur.length
cur << '/' unless cur[-1,1] == '/'
end
nil
end
|
.virtual_file(filename) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/torquebox/vfs.rb', line 72
def self.virtual_file(filename)
vfs_url, child_path = TorqueBox::VFS.resolve_within_archive( filename )
return nil unless vfs_url
begin
virtual_file = Java::org.jboss.vfs.VFS.child( vfs_url )
virtual_file = virtual_file.get_child( child_path ) if child_path
virtual_file
rescue Java::JavaIo::IOException => e
nil
end
end
|
.writable_path_or_error(path, e) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/torquebox/vfs.rb', line 85
def self.writable_path_or_error(path, e)
virtual_file = TorqueBox::VFS.virtual_file( path )
raise e if virtual_file.nil?
mount = Java::org.jboss.vfs::VFS.get_mount(virtual_file)
virtual_file.physical_file.path
end
|