forked from nextflow-io/nextflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatasetFileSystem.java
More file actions
123 lines (104 loc) · 3.28 KB
/
DatasetFileSystem.java
File metadata and controls
123 lines (104 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Copyright 2013-2024, Seqera Labs
*
* 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 io.seqera.tower.plugin.dataset;
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.WatchService;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.spi.FileSystemProvider;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
/**
* Minimal read-only FileSystem for the {@code dataset://} scheme.
* <p>
* Datasets are single files resolved via the Seqera Platform API,
* so most filesystem operations (roots, stores, path matching)
* are either trivial or unsupported.
*
* @author Edmund Miller
*/
public class DatasetFileSystem extends FileSystem {
static final String PATH_SEPARATOR = "/";
private final DatasetFileSystemProvider provider;
private final Map<String, ?> env;
private volatile boolean open = true;
DatasetFileSystem(DatasetFileSystemProvider provider, Map<String, ?> env) {
this.provider = provider;
this.env = env != null ? env : Collections.emptyMap();
}
@Override
public FileSystemProvider provider() {
return provider;
}
@Override
public void close() throws IOException {
open = false;
}
@Override
public boolean isOpen() {
return open;
}
@Override
public boolean isReadOnly() {
return true;
}
@Override
public String getSeparator() {
return PATH_SEPARATOR;
}
@Override
public Iterable<Path> getRootDirectories() {
return Collections.emptyList();
}
@Override
public Iterable<FileStore> getFileStores() {
return Collections.emptyList();
}
@Override
public Set<String> supportedFileAttributeViews() {
return Set.of("basic");
}
@Override
public Path getPath(String first, String... more) {
// Build a dataset path from string components
StringBuilder sb = new StringBuilder(first);
for (String part : more) {
if (!part.isEmpty()) {
sb.append(PATH_SEPARATOR).append(part);
}
}
return new DatasetPath(this, sb.toString());
}
@Override
public PathMatcher getPathMatcher(String syntaxAndPattern) {
throw new UnsupportedOperationException("Dataset filesystem does not support path matching");
}
@Override
public UserPrincipalLookupService getUserPrincipalLookupService() {
throw new UnsupportedOperationException();
}
@Override
public WatchService newWatchService() throws IOException {
throw new UnsupportedOperationException();
}
Map<String, ?> getEnv() {
return env;
}
}