Implemented stdin input (issue #5).

This commit is contained in:
didfet
2015-04-04 23:35:05 +02:00
parent 1db93560b3
commit 69d181dfd0
4 changed files with 30 additions and 9 deletions

View File

@@ -44,6 +44,8 @@ public class FileWatcher {
private FileState[] savedStates;
private int maxSignatureLength;
private boolean tail = false;
private Event stdinFields;
private boolean stdinConfigured = false;
public FileWatcher() {
try {
@@ -103,6 +105,17 @@ public class FileWatcher {
return numberOfLinesRead;
}
public int readStdin(InputReader reader) throws AdapterException, IOException {
if(stdinConfigured) {
logger.debug("Reading stdin");
reader.setFields(stdinFields);
int numberOfLinesRead = reader.readInput();
return numberOfLinesRead;
} else {
return 0;
}
}
private void processModifications() throws IOException {
for(File file : newWatchMap.keySet()) {
@@ -224,7 +237,9 @@ public class FileWatcher {
}
private void addStdIn(Event fields) {
logger.error("Watching stdin : not implemented yet");
logger.error("Watching stdin");
stdinFields = fields;
stdinConfigured = true;
}
private void initializeWatchMap(File directory, IOFileFilter fileFilter, Event fields) throws Exception {