public static <T extends Path> T namedGetFilename( T path) { @Nullable T name = (T) path.getFileName(); if ( name == null ) { if ( isRoot( path )) { throw new IllegalArgumentException( "root has no filename" ); } throw new IllegalArgumentException( "default path has no filename" ); } return name; }
public static Path get( URI uri, Map<String, ?> env ) { try { // first try to get it the nice way, because getOrCreate might not work even if the FS is already there return Paths.get( uri ); } catch( FileSystemNotFoundException e ) { getOrCreate( uri, env ); // create the filesystem if necessary and possible return Paths.get( uri ); } }
public static Path getPath( String str, Map<String, ?> env ) { URI uri = URI.create( str ); if( uri.getScheme() == null ) { throw new IllegalArgumentException( "not a uri with scheme " + uri ); } return Pathss.get( uri, env ); }
/** * Moves the content of source to path * This method works in mostly the manner * specified by the {@link java.nio.file.Files#move} method. * but: * source and target are absolute paths of the same filesystem * source path is sym link free * target does not exist * target parent does exist * * @param source * @param target */ default void move( EightyPath source, EightyPath target ) { FileTime lastModi = Filess.getLastModifiedTime( source ); Pathss.copyRecursive( source, target ); Pathss.deleteRecursive( source ); Filess.setLastModifiedTime( target, lastModi ); }
public static String fsFriendlyName( Instant inst ) { return getDateTimeString( inst );//dtf.format(inst); }
public static Path getTmpDir( String prefix ) { return FileSystems.getDefault().getPath( _nn(System.getProperty( "java.io.tmpdir" )), prefix + "-" + fsFriendlyName( Clock.systemUTC().instant() ) ); }
private void normalizeParentCase( RealIt it ) { if( !isRoot( it.path ) ) { it.path = childGetParent( it.path ); } } }
public Path getPath( URI uri ) { checkURI( uri ); FileSystem fs = Pathss.getOrCreate( uri, Collections.<String, Object> emptyMap() ); return fs.getPath( deUri( fs, uriMapper.getPathPart( uri ) ) ); }
public FSElsewhere( Path root, UUID uuid ) { if ( !root.isAbsolute()) { throw new IllegalArgumentException( "fselwhere root must be absolute " + root ); } if ( !isRoot( root ) && Files.exists( childGetParent( root))) { Filess.createDirectories( root ); } this.root = root; this.uuid = uuid; }
default FileSystem getOrCreateFS( Object id, Map<String, Object> env ) { return Pathss.getOrCreate( toURI( toString( id)), env); }
@Test @Category( Unix.class ) public void testGetPathOfSeparatorCreatesRoot() throws Exception { Path proot = FS.getPath( FS.getSeparator() ); assertThat( isRoot( proot ) ).isEqualTo( true ); }