@Test @Category( { Unix.class, NotOSX.class, MaxFilename.class, Writable.class } ) public void testFilenameTooLongBecauseUnicode() throws IOException { String str = new String( Character.toChars( 0x10400 ) ); PathLimits limits = new PathLimits( OS.UNIX ); String fname = longFileName( limits.getMaxPathLength() - str.length(), str ); assertThat( fname.length() ).isLessThan( limits.filenameCount( fname ) ); assertThatThrownBy( () -> Files.write( absT().resolve( fname ), CONTENT ) ).isInstanceOf( FileSystemException.class ); }
public UnixBuilder<T> hfsPlus() { PathLimits pathLimits = new PathLimits( OS.OSX ); PathSpec pathSpec = new PathSpecOSX(); descr.props.put( Tests10PathWithContent.ONE_CHAR_COUNT, pathLimits.getBigChar() ); descr.props.put( Tests10PathWithContent.MAX_FILENAME_LENGTH, pathSpec.getMaxFilenameLength() ); descr.props.put( Tests10PathWithContent.MAX_PATH_LENGTH, pathSpec.getMaxPathLength() ); descr.props.put( Tests10PathWithContent.GET_FILENAME_LENGTH, (Function<String,Integer>)pathSpec::getFilenameLength ); descr.props.put( Tests10PathWithContent.GET_PATH_LENGTH, (Function<String,Integer>)pathSpec::getPathLength ); descr.addTopic( CaseInsensitive.class ); descr.removeTopic( NotOSX.class ); // todo : is seperator (in a way) return this; }
public int filenameCount( String fname ) { if( os.isOSX() ) { return fname.length(); } if( os.isUnix() ) { return getBytes( fname ).length; } if( os.isWindows() ) { return fname.codePointCount( 0, fname.length() ); } throw new UnsupportedOperationException( "unsupported os " + os ); }
public UnixBuilder( FSDescription descr, T t ) { super( descr, t ); PathLimits pathLimits = new PathLimits( OS.UNIX ); PathSpec pathSpec = new PathSpecUnix(); descr.props.put( Tests10PathWithContent.ONE_CHAR_COUNT, pathLimits.getBigChar() ); descr.props.put( Tests10PathWithContent.MAX_FILENAME_LENGTH, pathSpec.getMaxFilenameLength() ); descr.props.put( Tests10PathWithContent.MAX_PATH_LENGTH, pathSpec.getMaxPathLength() ); descr.props.put( Tests10PathWithContent.GET_FILENAME_LENGTH, (Function<String,Integer>)pathSpec::getFilenameLength ); descr.props.put( Tests10PathWithContent.GET_PATH_LENGTH, (Function<String,Integer>)pathSpec::getPathLength ); // descr.removeTopic( LimitedPath.class ); theory but linux c limits descr.removeTopic( Windows.class ); descr.removeTopic( DosAttributesT.class ); descr.removeTopic( CaseInsensitive.class ); descr.removeTopic( NonCasePreserving.class ); descr.attributeDescriptions.put( "posix", attributeBuilding( Posix.class, "posix", PosixFileAttributeView.class, PosixFileAttributes.class ). addAttribute( "owner", PosixFileAttributes::owner ). addAttribute( "permissions", PosixFileAttributes::permissions ). addAttribute( "group", PosixFileAttributes::group ). build()); }
public WindowsBuilder( FSDescription descr, T t ) { super( descr, t ); descr.removeTopic( Unix.class ); PathLimits pathLimits = new PathLimits( OS.WINDOWS ); PathSpec pathSpec = new PathSpecWindows(); descr.props.put( Tests10PathWithContent.ONE_CHAR_COUNT, pathLimits.getBigChar() ); descr.props.put( Tests10PathWithContent.MAX_FILENAME_LENGTH, pathSpec.getMaxFilenameLength() ); descr.props.put( Tests10PathWithContent.MAX_PATH_LENGTH, pathSpec.getMaxPathLength() ); descr.props.put( Tests10PathWithContent.GET_FILENAME_LENGTH, (Function<String,Integer>)pathSpec::getFilenameLength ); descr.props.put( Tests10PathWithContent.GET_PATH_LENGTH, (Function<String,Integer>)pathSpec::getPathLength ); descr.removeTopic( Posix.class ); descr.removeTopic( MoveWhile.class ); descr.removeTopic( NonCasePreserving.class ); descr.removeTopic( FileKeyT.class ); descr.props.put( "illegalCharacters", Arrays.asList( ':', '?', '<', '>', '*', '|', '"' )); descr.attributeDescriptions.put( "dos", attributeBuilding( DosAttributesT.class, "dos", DosFileAttributeView.class, DosFileAttributes.class ). addAttribute( "hidden", DosFileAttributes::isHidden ). addAttribute( "archive", DosFileAttributes::isArchive ). addAttribute( "system", DosFileAttributes::isSystem ). addAttribute( "readonly", DosFileAttributes::isReadOnly ). build() ); }