Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
closes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Schrenk committed Apr 28, 2020
1 parent 05f5c91 commit 655eb91
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -193,6 +193,7 @@ private int createDirectory(Path path, CreationDisposition creationDisposition,
}
}


private int createFile(Path path, CreationDisposition creationDisposition, Set<OpenOption> openOptions, int rawFileAttributes, DokanyFileInfo dokanyFileInfo) {
LOG.trace("Try to open {} as File.", path);
final int mask = creationDisposition.getMask();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -964,5 +967,4 @@ private Path getRootedPath(WString rawPath) {
assert root.isAbsolute();
return root.resolve(relativeUnixPath);
}

}

0 comments on commit 655eb91

Please sign in to comment.