Permalink
Browse files

Limit filenames to 255 characters in Mac OS X (see issue #58).

  • Loading branch information...
EtiennePerot committed Nov 1, 2016
1 parent 2589a23 commit eced84f81ad6d2547d47384809a789cf9f4ed3d7
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/main/java/net/fusejna/DirectoryFillerImpl.java
@@ -5,16 +5,18 @@
import java.util.HashSet;
import java.util.Set;
-import net.fusejna.types.TypeOff;
-
import com.sun.jna.Function;
import com.sun.jna.Pointer;
+import net.fusejna.Platform.PlatformEnum;
+import net.fusejna.types.TypeOff;
+
/**
* A class which provides functionality to pass filenames back to FUSE as part of a readdir() call.
*/
public final class DirectoryFillerImpl implements DirectoryFiller
{
+ private static final int maxMacOSXFilenameLength = 255;
private static final String currentDirectory = ".";
private static final String parentDirectory = "..";
private final Pointer buf;
@@ -42,6 +44,10 @@ public final boolean add(final Iterable<String> files)
if (file.contains(File.separator)) {
file = new File(file).getName(); // Keep only the name component
}
+ if ((Platform.platform().equals(PlatformEnum.MAC) || Platform.platform().equals(PlatformEnum.MAC_MACFUSE))
+ && file.length() > maxMacOSXFilenameLength) {
+ return false;
+ }
if (addedFiles.add(file)) {
final Object[] args = { buf, file, null, new TypeOff(0L) };
result = nativeFunction.invokeInt(args);

0 comments on commit eced84f

Please sign in to comment.