-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
562573b
commit 68cf047
Showing
7 changed files
with
86 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...p-common/src/main/java/cn/maxpixel/mcdecompiler/common/app/util/DirectorySpliterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cn.maxpixel.mcdecompiler.common.app.util; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.DirectoryStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Iterator; | ||
import java.util.Spliterator; | ||
import java.util.function.Consumer; | ||
|
||
public class DirectorySpliterator implements Spliterator<Path> {// TODO: implement this later | ||
private final DirectoryStream<Path> stream; | ||
private Iterator<Path> it; | ||
|
||
public DirectorySpliterator(Path dir) throws IOException { | ||
this.stream = Files.newDirectoryStream(dir); | ||
this.it = stream.iterator(); | ||
} | ||
|
||
@Override | ||
public boolean tryAdvance(Consumer<? super Path> action) { | ||
if (it.hasNext()) { | ||
action.accept(it.next()); | ||
return true; | ||
} | ||
try { | ||
stream.close(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void forEachRemaining(Consumer<? super Path> action) { | ||
} | ||
|
||
@Override | ||
public Spliterator<Path> trySplit() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public long estimateSize() { | ||
return Long.MAX_VALUE; | ||
} | ||
|
||
@Override | ||
public int characteristics() { | ||
return DISTINCT | NONNULL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters