Skip to content

Commit 3b302b2

Browse files
committed
Add hidden property to GenericFile
1 parent 680ffaf commit 3b302b2

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

shellfx-storage/src/main/java/com/techsenger/shellfx/storage/AbstractDefaultFileStorage.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ private T createFile(Path path, BasicFileAttributes attrs, URI uri) {
259259
var file = fileFactory.create();
260260
file.setStorage(this);
261261
file.setName(path.getFileName().toString());
262+
file.setHidden(isHidden(path));
262263
file.setUri(uri);
263264
file.setLastModified(attrs.lastModifiedTime().toMillis());
264265
if (attrs.isDirectory()) {
@@ -274,4 +275,12 @@ private T createFile(Path path, BasicFileAttributes attrs, URI uri) {
274275
file.setVirtual(false);
275276
return (T) file;
276277
}
278+
279+
private boolean isHidden(Path path) {
280+
try {
281+
return Files.isHidden(path);
282+
} catch (IOException ex) {
283+
return false;
284+
}
285+
}
277286
}

shellfx-storage/src/main/java/com/techsenger/shellfx/storage/DefaultGenericFile.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class DefaultGenericFile implements GenericFile {
5151

5252
private @Nullable Long lastModified;
5353

54+
private boolean hidden;
55+
5456
private boolean virtual;
5557

5658
/**
@@ -90,6 +92,11 @@ public URI getUri() {
9092
return lastModified;
9193
}
9294

95+
@Override
96+
public boolean isHidden() {
97+
return hidden;
98+
}
99+
93100
@Override
94101
public boolean isVirtual() {
95102
return virtual;
@@ -196,6 +203,15 @@ protected void setLastModified(@Nullable Long lastModified) {
196203
this.lastModified = lastModified;
197204
}
198205

206+
/**
207+
* Sets whether this entry is hidden.
208+
*
209+
* @param hidden {@code true} if this entry is hidden
210+
*/
211+
protected void setHidden(boolean hidden) {
212+
this.hidden = hidden;
213+
}
214+
199215
/**
200216
* Sets whether this entry is virtual.
201217
*

shellfx-storage/src/main/java/com/techsenger/shellfx/storage/GenericFile.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@ public interface GenericFile {
8181
*/
8282
@Nullable Long getLastModified();
8383

84+
/**
85+
* Returns {@code true} if this entry is hidden, and {@code false} otherwise.
86+
*/
87+
boolean isHidden();
88+
8489
/**
8590
* Returns {@code true} if this entry is virtual, i.e. it was constructed programmatically without a corresponding
86-
* real entry on the underlying storage.
91+
* real entry on the underlying storage. As a result, virtual entries generally do not have all metadata
92+
* (such as size, hidden status, etc.).
8793
*
8894
* <p>Virtual entries are used as placeholders — for example, a parent directory inferred from a child's URI, or a
8995
* root entry that does not physically exist on the backend.

0 commit comments

Comments
 (0)