diff --git a/src/main/java/org/cryptomator/frontend/dokany/ReadWriteAdapter.java b/src/main/java/org/cryptomator/frontend/dokany/ReadWriteAdapter.java index ff099ac..86ec2a4 100644 --- a/src/main/java/org/cryptomator/frontend/dokany/ReadWriteAdapter.java +++ b/src/main/java/org/cryptomator/frontend/dokany/ReadWriteAdapter.java @@ -15,7 +15,6 @@ import com.dokany.java.structure.FullFileInfo; import com.dokany.java.structure.VolumeInformation; import com.google.common.base.CharMatcher; -import com.google.common.base.Strings; import com.sun.jna.Pointer; import com.sun.jna.WString; import com.sun.jna.platform.win32.WinBase; @@ -153,7 +152,8 @@ private int createDirectory(Path path, CreationDisposition creationDisposition, return Win32ErrorCode.ERROR_ALREADY_EXISTS.getMask(); } } catch (FileSystemException e) { - if (Strings.nullToEmpty(e.getReason()).contains("path too long")) { + final String reason = e.getReason().toLowerCase(); + if (reason.contains("path too long") || reason.contains("extension too long") || reason.contains("path too long")) { LOG.warn("zwCreateFile(): Creation of {} failed, file name too long.", path); return Win32ErrorCode.ERROR_FILENAME_EXCED_RANGE.getMask(); } else { @@ -193,6 +193,7 @@ private int createDirectory(Path path, CreationDisposition creationDisposition, } } + private int createFile(Path path, CreationDisposition creationDisposition, Set openOptions, int rawFileAttributes, DokanyFileInfo dokanyFileInfo) { LOG.trace("Try to open {} as File.", path); final int mask = creationDisposition.getMask(); @@ -252,11 +253,12 @@ else if ((attr != null && attr.isReadOnly() || ((rawFileAttributes & FileAttribu LOG.trace("Cause:", e); return Win32ErrorCode.ERROR_ACCESS_DENIED.getMask(); } catch (FileSystemException e) { - if (Strings.nullToEmpty(e.getReason()).contains("path too long")) { + final String reason = e.getReason().toLowerCase(); + if (reason.contains("path too long") || reason.contains("extension too long") || reason.contains("path too long")) { LOG.warn("zwCreateFile(): Creation of {} failed, file name too long.", path); return Win32ErrorCode.ERROR_FILENAME_EXCED_RANGE.getMask(); } else { - LOG.debug("zwCreateFile(): IO error occured while opening handle to {}.", path); + LOG.debug("zwCreateFile(): IO error occured during the creation of {}.", path); LOG.debug("zwCreateFile(): ", e); return Win32ErrorCode.ERROR_CANNOT_MAKE.getMask(); } @@ -798,7 +800,8 @@ public int moveFile(WString rawPath, WString rawNewFileName, boolean rawReplaceI LOG.trace("({}) Target directory {} is not emtpy.", dokanyFileInfo.Context, path); return Win32ErrorCode.ERROR_DIR_NOT_EMPTY.getMask(); } catch (FileSystemException e) { - if (Strings.nullToEmpty(e.getReason()).contains("path too long")) { + final String reason = e.getReason().toLowerCase(); + if (reason.contains("path too long") || reason.contains("extension too long") || reason.contains("path too long")) { LOG.warn("({}) Moving resource {} failed, file name too long.", dokanyFileInfo.Context, path); return Win32ErrorCode.ERROR_FILENAME_EXCED_RANGE.getMask(); } else { @@ -964,5 +967,4 @@ private Path getRootedPath(WString rawPath) { assert root.isAbsolute(); return root.resolve(relativeUnixPath); } - }