-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errno::ENOENT: No such file or directory - \\server creating a directory in a UNC path #1727
Comments
We are building downlowdable application and some of our customer are getting the same error. I got the same issue on my test windows. I used jruby 1.7.22 and tested on Windows7 (Microsoft Windows [Version 6.1.7601]) We tracked it down to jnr.posix.WindowsPOSIX.mkdir function and jnr.posixWindowsLibC._wmkdir funcion. Before creating directroy path is changed to UTF-16 and prepended with
This method allways returns -1. Then we tried create directory without prepending
this returned 0 and directory was created. |
At first one fix for the irb script (to get the m = wlibc.java_class.declared_instance_methods.detect{|m| m.name=="_wmkdir"} Found out in https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath that for UNC path m.invoke(wlibc, c.new_instance("//?/UNC/JWIN7/jira_h/tmp")) |
This is fixed in jnr-posix and I will be updating JRuby 1.7 and master to use the new version soon (just release jnr-ffi and Maven takes hours for new artifacts to show up on central). |
http://repo1.maven.org/maven2/com/github/jnr/jnr-ffi/2.0.4/ @enebo nowadays it is just minutes :) |
There is one more issue with For rest of the cases, path is split to folders using Right now it is returning only host name if called for share: File.dirname("//host/share") # => "//host" however File.directory("//host") # => false
File.directory("//host/share" # => true If File.dirname behaviour will be changed to: File.dirname("//host/share") # => "//host/share" then |
We have customers waiting to install our product on Windows with UNC file paths so I created simple if (startsWithDriveLetterOnWindows && index == 2) {
// Include additional path separator
// (so that dirname of "C:\file.txt" is "C:\", not "C:")
index++;
}
// PATCH: don't remove //host/share from windows UNC paths "//host/share"
// but sill remove last path element if path is longer
if ( name.startsWith("//")) {
index = name.length();
String[] splitted = name.split(Pattern.quote("/"));
if (splitted.length > 4) {
index = name.lastIndexOf("/");
}
}
// if (jfilename.startsWith("\\\\")) {
// index = jfilename.length();
// String[] splitted = jfilename.split(Pattern.quote("\\"));
// int last = splitted.length-1;
// if (splitted[last].contains(".")) {
// index = jfilename.lastIndexOf("\\");
// }
// }
result = jfilename.substring(0, index); I also created simple patch for public static byte[] toWPath(String path) {
boolean absolute = new File(path).isAbsolute();
// PATCH: commented out windows long path prefix. It is not working with UNC paths (//host/share)
// if (absolute) {
// path = "//?/" + path;
// }
return toWString(path);
} |
When I call
FileUtils.mkdir_p("//Server/share/my_new_directory")
it raise the Errno::ENOENT: No such file or directory - \Server
This code worked perfectly in MRI.
Otherwise loving JRuby...
additional info:
jruby 1.7.12 (1.9.3p392) 2014-04-15 643e292 on Java HotSpot(TM) 64-Bit Server VM 1.8.0-b132 +indy [Windows 7-amd64]
The text was updated successfully, but these errors were encountered: