@@ -52,7 +52,13 @@ public class JRubyFile extends JavaSecuredFile {
52
52
private static final long serialVersionUID = 435364547567567L ;
53
53
54
54
public static JRubyFile create (String cwd , String pathname ) {
55
- return createNoUnicodeConversion (cwd , pathname );
55
+ if (pathname == null || pathname .length () == 0 || Ruby .isSecurityRestricted ()) {
56
+ return JRubyFile .DUMMY ;
57
+ }
58
+ if (pathname .startsWith ("file:" )) {
59
+ pathname = pathname .substring (5 );
60
+ }
61
+ return createNoUnicodeConversion (cwd , pathname , new File (pathname ));
56
62
}
57
63
58
64
public static FileResource createResource (ThreadContext context , String pathname ) {
@@ -109,23 +115,13 @@ private static FileResource createResource(Ruby runtime, String cwd, String path
109
115
}
110
116
111
117
// If any other special resource types fail, count it as a filesystem backed resource.
112
- return new RegularFileResource (runtime != null ? runtime .getPosix () : null , create (cwd , pathname ));
118
+ return new RegularFileResource (runtime != null ? runtime .getPosix () : null , create (cwd , pathname ), pathname );
113
119
}
114
120
115
121
public static String normalizeSeps (String path ) {
116
122
return Platform .IS_WINDOWS ? path .replace (File .separatorChar , '/' ) : path ;
117
123
}
118
124
119
- private static JRubyFile createNoUnicodeConversion (String cwd , String pathname ) {
120
- if (pathname == null || pathname .length () == 0 || Ruby .isSecurityRestricted ()) {
121
- return JRubyFile .DUMMY ;
122
- }
123
- if (pathname .startsWith ("file:" )) {
124
- pathname = pathname .substring (5 );
125
- }
126
- return createNoUnicodeConversion (cwd , pathname , new File (pathname ));
127
- }
128
-
129
125
private static JRubyFile createNoUnicodeConversion (String cwd , String pathname , File path ) {
130
126
// File and company do not seem to recognize bare \ and / on Windows as absolute. Cheat!
131
127
if (path .isAbsolute () || Platform .IS_WINDOWS && (pathname .startsWith ("/" ) || pathname .startsWith ("\\ " ))) {
@@ -184,6 +180,10 @@ public String getPath() {
184
180
return normalizeSeps (super .getPath ());
185
181
}
186
182
183
+ final String getPathDefault () {
184
+ return super .getPath ();
185
+ }
186
+
187
187
@ Override
188
188
public String toString () {
189
189
return normalizeSeps (super .toString ());
0 commit comments