// Path: filesystem-core/src/main/java/onl/area51/filesystem/AbstractFileSystemProvider.java
// public abstract class AbstractFileSystemProvider<F extends AbstractFileSystem<F, P, ?>, P extends AbstractPath<F, P>>
//         extends FileSystemProvider
// {
// 
//     private final Map<URI, F> filesystems = new ConcurrentHashMap<>();
// 
//     @Override
//     public abstract String getScheme();
// 
//     protected final Path uriToPath( URI uri )
//             throws IOException
//     {
//         String scheme = uri.getScheme();
//         if( (scheme == null) || !scheme.equalsIgnoreCase( getScheme() ) ) {
//             throw new IllegalArgumentException( "URI scheme is not '" + getScheme() + "'" );
//         }
// 
//         Path path = FileSystemUtils.getCacheDirectory()
//                 .resolve( getScheme() )
//                 .resolve( uri.getAuthority() )
//                 .toAbsolutePath();
// 
//         Files.createDirectories( path );
// 
//         return path;
//     }
// 
//     protected abstract F createFileSystem( URI uri, Path p, Map<String, Object> env )
//             throws IOException;
// 
//     private F createFileSystem( URI uri, Map<String, Object> env )
//     {
//         try {
//             return createFileSystem( uri, uriToPath( uri ).toRealPath(), env );
//         }
//         catch( IOException ex ) {
//             throw new UncheckedIOException( ex );
//         }
//     }
// 
//     @Override
//     public final FileSystem newFileSystem( URI uri, Map<String, ?> env )
//             throws IOException
//     {
//         return filesystems.computeIfAbsent( FileSystemUtils.getFileSystemURI( uri ),
//                                             fsUri -> createFileSystem(fsUri, (Map<String, Object>) FileSystemUtils.getFileSystemEnv( uri, env )) );
//     }
// 
//     public final void deleteFileSystem( FileSystem fs )
//     {
//         if( fs instanceof AbstractFileSystem ) {
//             filesystems.remove( ((AbstractFileSystem) fs).getUri() );
//         }
//     }
// 
//     @Override
//     public final FileSystem newFileSystem( Path path, Map<String, ?> env )
//             throws IOException
//     {
//         if( path.getFileSystem() != FileSystems.getDefault() ) {
//             throw new UnsupportedOperationException();
//         }
// 
//         Files.createDirectories( path );
//         return createFileSystem(path.toUri(), path, (Map<String, Object>) env);
//     }
// 
//     @Override
//     public final Path getPath( URI uri )
//     {
//         return getFileSystem( uri ).getPath( uri.getPath() );
//     }
// 
//     @Override
//     public final FileSystem getFileSystem( URI uri )
//     {
//         URI fsUri = FileSystemUtils.getFileSystemURI( uri );
//         try {
//             return newFileSystem( uri, new HashMap<>() );
//         }
//         catch( IOException ex ) {
//             throw new FileSystemNotFoundException( fsUri.toString() );
//         }
//     }
// }
// 
// Path: filesystem-core/src/main/java/onl/area51/filesystem/io/Flat.java
// @MetaInfServices(FileSystemIO.class)
// public class Flat
//         extends LocalFileSystemIO
// {
// 
//     public Flat( Path basePath,
//                  Map<String, ?> env )
//     {
//         super( basePath, env );
//     }
// 
//     @Override
//     protected String getPath( char[] path )
//             throws IOException
//     {
//         return String.valueOf( path );
//     }
// 
// }


import java.io.IOException;
import java.net.URI;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.AccessMode;
import java.nio.file.CopyOption;
import java.nio.file.DirectoryStream;
import java.nio.file.FileStore;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.ProviderMismatchException;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.spi.FileSystemProvider;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import onl.area51.filesystem.AbstractFileSystemProvider;
import onl.area51.filesystem.io.Flat;
import org.kohsuke.MetaInfServices;
/*
 * Copyright 2016 peter.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package onl.area51.filesystem.memory;


/**
 *
 * @author peter
 */
@MetaInfServices(FileSystemProvider.class)
public class MemoryFileSystemProvider
// Path: filesystem-core/src/main/java/onl/area51/filesystem/AbstractFileSystemProvider.java
// public abstract class AbstractFileSystemProvider<F extends AbstractFileSystem<F, P, ?>, P extends AbstractPath<F, P>>
//         extends FileSystemProvider
// {
// 
//     private final Map<URI, F> filesystems = new ConcurrentHashMap<>();
// 
//     @Override
//     public abstract String getScheme();
// 
//     protected final Path uriToPath( URI uri )
//             throws IOException
//     {
//         String scheme = uri.getScheme();
//         if( (scheme == null) || !scheme.equalsIgnoreCase( getScheme() ) ) {
//             throw new IllegalArgumentException( "URI scheme is not '" + getScheme() + "'" );
//         }
// 
//         Path path = FileSystemUtils.getCacheDirectory()
//                 .resolve( getScheme() )
//                 .resolve( uri.getAuthority() )
//                 .toAbsolutePath();
// 
//         Files.createDirectories( path );
// 
//         return path;
//     }
// 
//     protected abstract F createFileSystem( URI uri, Path p, Map<String, Object> env )
//             throws IOException;
// 
//     private F createFileSystem( URI uri, Map<String, Object> env )
//     {
//         try {
//             return createFileSystem( uri, uriToPath( uri ).toRealPath(), env );
//         }
//         catch( IOException ex ) {
//             throw new UncheckedIOException( ex );
//         }
//     }
// 
//     @Override
//     public final FileSystem newFileSystem( URI uri, Map<String, ?> env )
//             throws IOException
//     {
//         return filesystems.computeIfAbsent( FileSystemUtils.getFileSystemURI( uri ),
//                                             fsUri -> createFileSystem(fsUri, (Map<String, Object>) FileSystemUtils.getFileSystemEnv( uri, env )) );
//     }
// 
//     public final void deleteFileSystem( FileSystem fs )
//     {
//         if( fs instanceof AbstractFileSystem ) {
//             filesystems.remove( ((AbstractFileSystem) fs).getUri() );
//         }
//     }
// 
//     @Override
//     public final FileSystem newFileSystem( Path path, Map<String, ?> env )
//             throws IOException
//     {
//         if( path.getFileSystem() != FileSystems.getDefault() ) {
//             throw new UnsupportedOperationException();
//         }
// 
//         Files.createDirectories( path );
//         return createFileSystem(path.toUri(), path, (Map<String, Object>) env);
//     }
// 
//     @Override
//     public final Path getPath( URI uri )
//     {
//         return getFileSystem( uri ).getPath( uri.getPath() );
//     }
// 
//     @Override
//     public final FileSystem getFileSystem( URI uri )
//     {
//         URI fsUri = FileSystemUtils.getFileSystemURI( uri );
//         try {
//             return newFileSystem( uri, new HashMap<>() );
//         }
//         catch( IOException ex ) {
//             throw new FileSystemNotFoundException( fsUri.toString() );
//         }
//     }
// }
// 
// Path: filesystem-core/src/main/java/onl/area51/filesystem/io/Flat.java
// @MetaInfServices(FileSystemIO.class)
// public class Flat
//         extends LocalFileSystemIO
// {
// 
//     public Flat( Path basePath,
//                  Map<String, ?> env )
//     {
//         super( basePath, env );
//     }
// 
//     @Override
//     protected String getPath( char[] path )
//             throws IOException
//     {
//         return String.valueOf( path );
//     }
// 
// }


// Path: filesystem-memory/src/main/java/onl/area51/filesystem/memory/MemoryFileSystemProvider.java
import java.io.IOException;
import java.net.URI;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.AccessMode;
import java.nio.file.CopyOption;
import java.nio.file.DirectoryStream;
import java.nio.file.FileStore;
import java.nio.file.LinkOption;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.ProviderMismatchException;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.spi.FileSystemProvider;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import onl.area51.filesystem.AbstractFileSystemProvider;
import onl.area51.filesystem.io.Flat;
import org.kohsuke.MetaInfServices;

/*
 * Copyright 2016 peter.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package onl.area51.filesystem.memory;


/**
 *
 * @author peter
 */
@MetaInfServices(FileSystemProvider.class)
public class MemoryFileSystemProvider
        extends AbstractFileSystemProvider<MemoryFileSystem, MemoryPath>