public boolean isTooLong() { PathSpec ps = fileSystem.get80().getPathSpec(); if( ps.getPathLength( normalString ) > ps.getMaxPathLength() ) { return true; } return elems.stream().filter( el -> ps.getFilenameLength( el ) > ps.getMaxFilenameLength() ).findAny().isPresent(); }
@Override public int getPathLength( String str ) { return PathSpec.getBytes( str ).length; }
/** * checks for invalid filenames * i.e. illegal char * but not length * @param str * @return */ default Optional<String> filenameIsNotValidBecause( String str ) { return getIllegalCharacters(). filter( pat -> pat.matcher( str ).matches() ). map( p -> "contains an illegal character " + str ); }
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; }
@Override public @Nullable String getSeparator() { return eightyFS.getPathSpec().getSeparator(); }
public GetPathConverter( PathSpec ec, String first, String... more ) { this.ec = ec; deRegexSep = ec.getAllSeparators().toString(); PathSpec.RC p = ec.getRootComponent( first ); rootComponent = p.root; String pfirst = p.path; absolute = !pfirst.isEmpty() && ec.getAllSeparators().matcher( pfirst.substring( 0, 1 ) ).matches(); add( elems, pfirst ); for( String elem : more ) { add( elems, elem ); } }
private void add( List<String> elems, String one ) { for( String sub : one.split( deRegexSep ) ) { ec.filenameIsNotValidBecause( sub ). ifPresent( reason -> { throw u( new InvalidPathException( sub, reason ));} ); // if( !ec.isFilenameValid( sub, reason ) ) { // throw new InvalidPathException( sub, reason.get() ); // } // ec.findIllegalChars( sub ). // ifPresent( ch -> { // throw new InvalidPathException( sub, "contains illegal char <" + ch + ">");}); if( !sub.isEmpty() ) { elems.add( sub ); //trans.apply( sub )); } } }
normalString = fileSystem.get80().getPathSpec().getNormalForm( pathToString );
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()); }
private MemoryFS( Object nameo, Map<String, Object> env ) { this.name = (String) nameo; if( name.isEmpty() ) { throw new IllegalArgumentException( "memory filesystem must have a name, e.g. memory:name" ); } watchable = (Boolean) env.getOrDefault( WATCH_SERVICE, Boolean.TRUE ); closable = (Boolean) env.getOrDefault( CLOSABLE, Boolean.TRUE ); principals = (Principals) env.getOrDefault( "principals", PrincipalsBuilder.linuxUsersAndGroups( "me" ) ); pathSpec = (PathSpec) env.getOrDefault( PATH_SPEC, new PathSpecUnix() ); // MemoryFileStore store = new MemoryFileStore(); // store.setMaxSize( (Long) env.getOrDefault( MAX_SIZE, -1L ) ); // // todo root component for ntfs and which user ? // store.getData().addRoot( pathSpec.getSeparator(), principals ); // // stores.put( "c:", store ); stores = new Stores( (String) env.getOrDefault( PRIMARY_STORE_NAME, "" )); stores.getPrimary().setMaxSize( (Long) env.getOrDefault( MAX_SIZE, -1L ) ); stores.getPrimary().getData().addRoot( pathSpec.getSeparator(), principals ); for ( String rootName : (List<String>)env.getOrDefault( "roots", Collections.emptyList() )) { stores.newStore( rootName ); } symLinkManger = Optional.of( new MemorySymLinkManager( principals, this::getStore ) ); }
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() ); }
@Override public int getFilenameLength( String str ) { return PathSpec.getBytes( str ).length; }
@Override public int getPathLength( String str ) { return PathSpec.getBytes( str ).length; }
@Override public int getFilenameLength( String str ) { return PathSpec.getBytes( str ).length; }
@Override public int getPathLength( String str ) { return PathSpec.getBytes( str ).length; // UTF8 where filename is UTF16 codepoints }