FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
jruby/src/org/jruby/util/JarFileResource.java at parallel_boot · MSNexploder/jruby · GitHub
MSNexploder
/
jruby
Public
forked from
jruby/jruby
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
jruby
/
src
/
org
/
jruby
/
util
/
JarFileResource.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (44 loc) · 1.22 KB
Breadcrumbs
jruby
/
src
/
org
/
jruby
/
util
/
JarFileResource.java
Copy path
File metadata and controls
56 lines (44 loc) · 1.22 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package
org
.
jruby
.
util
;
import
org
.
jruby
.
RubyFile
;
import
java
.
io
.
IOException
;
import
java
.
util
.
zip
.
ZipEntry
;
/**
* A file resource that is contained within a jar.
*/
public
class
JarFileResource
extends
ZipEntry
implements
FileResource
{
public
static
JarFileResource
load
(
String
path
) {
String
sanitized
=
path
.
startsWith
(
"file:"
) ?
path
.
substring
(
5
) :
path
;
int
bang
=
sanitized
.
indexOf
(
'!'
);
if
(
bang
== -
1
) {
throw
new
IllegalArgumentException
(
"Expecting a jar containing path, but got: "
+
sanitized
);
}
String
jar
=
sanitized
.
substring
(
0
,
bang
);
String
after
=
sanitized
.
substring
(
bang
+
2
);
try
{
return
new
JarFileResource
(
RubyFile
.
getDirOrFileEntry
(
jar
,
after
));
}
catch
(
IOException
ioError
) {
// Failed to get the file, so returning null, similar to like ZipFile#getEntry does
return
null
;
}
}
private
JarFileResource
(
ZipEntry
entry
) {
super
(
entry
);
}
@
Override
public
boolean
exists
() {
// ZipEntry always exists
return
true
;
}
@
Override
public
boolean
isFile
() {
return
!
isDirectory
();
}
@
Override
public
long
length
() {
return
getSize
();
}
@
Override
public
long
lastModified
() {
return
getTime
();
}
}
Back
|
FazBrowse Home
|
New Git URL