/*
* Copyright (c) 2013, the authors.
*
* This file is part of 'DXFS'.
*
* DXFS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DXFS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DXFS. If not, see <http://www.gnu.org/licenses/>.
*/
package nextflow.fs.dx;
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.FileStoreAttributeView;
/**
* DnaNexus {@code FileStore} concrete class. Note: alla methods throw {@code UnsupportedOperationException} since
* required information are not provided by the target API
*
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
*/
public class DxFileStore extends FileStore {
private final DxFileSystem dxfs;
DxFileStore(DxFileSystem dxfs) {
this.dxfs = dxfs;
}
@Override
public String name() {
return dxfs.toString() + "/";
}
@Override
public String type() {
return "dxfs";
}
@Override
public boolean isReadOnly() {
return dxfs.isReadOnly();
}
@Override
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
return (type == BasicFileAttributeView.class );
}
@Override
public boolean supportsFileAttributeView(String name) {
return name.equals("basic") || name.equals("dxfs");
}
@Override
@SuppressWarnings("unchecked")
public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) {
if (type == null)
throw new NullPointerException();
return (V)null;
}
@Override
public long getTotalSpace() throws IOException {
throw new UnsupportedOperationException("TODO");
}
@Override
public long getUsableSpace() throws IOException {
throw new UnsupportedOperationException("TODO");
}
@Override
public long getUnallocatedSpace() throws IOException {
throw new UnsupportedOperationException("TODO");
}
@Override
public Object getAttribute(String attribute) throws IOException {
if (attribute.equals("totalSpace"))
return getTotalSpace();
if (attribute.equals("usableSpace"))
return getUsableSpace();
if (attribute.equals("unallocatedSpace"))
return getUnallocatedSpace();
throw new UnsupportedOperationException("does not support the given attribute");
}
}