-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write and read snapshot file from C++ instead of JS
- Loading branch information
1 parent
653f2a0
commit 0b99729
Showing
4 changed files
with
42 additions
and
34 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
#include <string> | ||
#include <sstream> | ||
#include <fstream> | ||
#include "../DirTree.hh" | ||
#include "../Event.hh" | ||
|
||
DirTree *getDirTree(std::string *dir); | ||
|
||
std::string getCurrentTokenImpl(std::string *dir) { | ||
void writeSnapshotImpl(std::string *dir, std::string *snapshotPath) { | ||
auto tree = getDirTree(dir); | ||
std::ostringstream os; | ||
tree->write(os); | ||
return os.str(); | ||
std::ofstream ofs(*snapshotPath); | ||
tree->write(ofs); | ||
} | ||
|
||
EventList *getEventsSinceImpl(std::string *dir, std::string *token) { | ||
std::istringstream is(*token); | ||
auto snapshot = new DirTree(is); | ||
EventList *getEventsSinceImpl(std::string *dir, std::string *snapshotPath) { | ||
std::ifstream ifs(*snapshotPath); | ||
if (ifs.fail()) { | ||
return new EventList(); | ||
} | ||
|
||
auto snapshot = new DirTree(ifs); | ||
auto now = getDirTree(dir); | ||
return now->getChanges(snapshot); | ||
} |