/* * 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.attribute.BasicFileAttributeView; import java.nio.file.attribute.FileTime; import java.util.HashMap; import java.util.Map; /** * Implements the DnaNexus file system attributes views * * * @author Paolo Di Tommaso <paolo.ditommaso@gmail.com> */ public class DxFileAttributeView implements BasicFileAttributeView { static String NAME = "basic"; private DxPath path; public DxFileAttributeView(DxPath path) { this.path = path; } @Override public String name() { return NAME; } @Override public DxFileAttributes readAttributes() throws IOException { return path.readAttributes(); } Map<String, Object> readAttributes(String attributes) throws IOException { DxFileAttributes attr = readAttributes(); Map<String,Object> result; // return ALL attributes if ("*".equals(attributes)) { result = attr.asMap(); } // comma separated list of attribute names else { String[] attributesNames = attributes.split(","); result = new HashMap<>(attributesNames.length); for (String name : attributesNames) { result.put(name, attr.get(name)); } } return result; } @Override public void setTimes(FileTime lastModifiedTime, FileTime lastAccessTime, FileTime createTime) throws IOException { throw new UnsupportedOperationException(); } }