@Override public int compareTo( String a, String b ) { return getNormalForm( a ).compareTo( getNormalForm( b ) ); }
public static MemoryFSBuilder windows() { return new MemoryFSBuilder(). pathSpec( new PathSpecWindows() ). primaryStoreName( "c:"). attributeView( DosFileAttributeView.class ); }
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() ); }
static PathSpec byOS( OS os ) { if ( os.isWindows() ) { return new PathSpecWindows(); } if ( os.isOSX() ) { return new PathSpecOSX(); } if ( os.isUnix() ) { return new PathSpecUnix(); } return new PathSpecDefault(); }
@Override public RC getRootComponent( String str ) { if( drives.matcher( str ).matches() ) { return new RC( Optional.of( getNormalForm( str.substring( 0, 2 ) ) ), str.substring( 2 ) ); } if ( !doubleSlashStart.matcher( str ).matches() ) { return new RC( Optional.empty(), str ); // relative path or single slash } Matcher matcher = unc.matcher( str ); if( !matcher.matches() ) { throw new InvalidPathException( str, "illegal path (not unc)" ); } String path = Optional.ofNullable( matcher.group( UNCPATH )).orElseThrow( () -> new IllegalStateException( "bad group name" )); String server = getNormalForm( Optional.ofNullable( matcher.group( UNCSERVER )).orElseThrow( () -> new IllegalStateException( "bad group name" ))); String share = getNormalForm( Optional.ofNullable( matcher.group( UNCSHARE )).orElseThrow( () -> new IllegalStateException( "bad group name" ))); return new RC( Optional.of( "\\\\" + server + "\\" + share ), path.isEmpty() ? "\\" : path ); }