Skip to content

Commit

Permalink
fix build error in Ubuntu by remove system specific checking
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaminac committed Dec 11, 2024
1 parent 680bfdd commit 0bfea90
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private static void load(VirtualFileSystem<String, byte[]> tree, File root) thro
final File[] files = root.listFiles();
if (files != null) {
for (File file : files) {
if (!file.isHidden()) {
if (!isHidden(file)) {
if (file.isDirectory()) {
VirtualFileSystem<String, byte[]> subtree = new VirtualFileSystem<>(file.getName(), null);
load(subtree, file);
Expand All @@ -38,6 +38,10 @@ private static void load(VirtualFileSystem<String, byte[]> tree, File root) thro
}
}

private static boolean isHidden(final File file) {
return file.getName().startsWith(".");
}

public static VirtualFileSystem<String, byte[]> loadFromFileSystem(File root) throws IOException {
if (root == null || !root.exists() || !root.isDirectory())
throw new RuntimeException("The directory does not exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public void loadFromFileSystem() {
"/b/c/c.ext\n" +
"/b/d\n" +
"/b/d/f\n" +
"/b/d/f/e.ext\n" +
"/b/d/.e\n" +
"/b/d/.e/d.ext\n";
"/b/d/f/e.ext\n";
assertEquals(expected, this.vfs.toString());
}

Expand All @@ -56,9 +54,7 @@ public void remove() {
"/b/c\n" +
"/b/c/c.ext\n" +
"/b/d\n" +
"/b/d/f\n" +
"/b/d/.e\n" +
"/b/d/.e/d.ext\n";
"/b/d/f\n";
assertEquals(expected, this.vfs.toString());
}

Expand All @@ -78,28 +74,26 @@ public void root() {

@Test
public void parent() {
assertEquals(VirtualFileSystem.find(this.vfs, "/b/d/.e/"), VirtualFileSystem.find(this.vfs, "/b/d/.e/d.ext").parent());
assertEquals(VirtualFileSystem.find(this.vfs, "/b/d/.e"), VirtualFileSystem.find(this.vfs, "/b/d/.e/d.ext").parent());
assertEquals(VirtualFileSystem.find(this.vfs, "/b/d/f/"), VirtualFileSystem.find(this.vfs, "/b/d/f/e.ext").parent());
assertEquals(VirtualFileSystem.find(this.vfs, "/b/d/f"), VirtualFileSystem.find(this.vfs, "/b/d/f/e.ext").parent());
}

@Test
public void add() {
VirtualFileSystem.find(this.vfs, "/b/d/.e").addChild(new VirtualFileSystem<>("o.ext", "Hola Mundo".getBytes(StandardCharsets.UTF_8)));
VirtualFileSystem.find(this.vfs, "/b/c").addChild(new VirtualFileSystem<>("o.ext", "Hola Mundo".getBytes(StandardCharsets.UTF_8)));
VirtualFileSystem.find(this.vfs, "/b/d/f").addChild(new VirtualFileSystem<>("o.ext", "Hola Mundo".getBytes(StandardCharsets.UTF_8)));
String expected = "\n" +
"/a\n" +
"/a/a.ext\n" +
"/a/b.ext\n" +
"/b\n" +
"/b/c\n" +
"/b/c/o.ext\n" +
"/b/c/c.ext\n" +
"/b/d\n" +
"/b/d/f\n" +
"/b/d/f/o.ext\n" +
"/b/d/f/e.ext\n" +
"/b/d/.e\n" +
"/b/d/.e/d.ext\n" +
"/b/d/.e/o.ext\n";
"/b/d/f/e.ext\n";
assertEquals(expected, this.vfs.toString());
}
}

0 comments on commit 0bfea90

Please sign in to comment.