diff options
| author | tim <tim@eclectronics.org> | 2017-05-22 21:31:33 +0100 |
|---|---|---|
| committer | tim <tim@eclectronics.org> | 2017-05-22 21:31:33 +0100 |
| commit | 6ae491eea38055ebe3ba1154f0e916d7bbf95040 (patch) | |
| tree | 793783c9f82f0a30fcf78507c3c88d6cec6c6639 /testDir/src/dirscanner.cpp | |
| parent | c31d38915cb6643013223a4ed9b4021b3499d71d (diff) | |
directory reader in test case
Diffstat (limited to 'testDir/src/dirscanner.cpp')
| -rw-r--r-- | testDir/src/dirscanner.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/testDir/src/dirscanner.cpp b/testDir/src/dirscanner.cpp new file mode 100644 index 0000000..feb29c1 --- /dev/null +++ b/testDir/src/dirscanner.cpp @@ -0,0 +1,71 @@ +#include "dirscanner.h" + +void playItem::play(){ + +} +void playItem::draw(){ + +} +bool playItem::isFinished(){ + +} + +void dirScanner::scan(){ + /* + parse directories and create structure + showing which folder to check at which time + */ + slots.clear(); + + ofDirectory dir(rootdir); + + dir.allowExt(""); //get directories + + dir.listDir(); + for(int i = 0; i < dir.size(); i++){ + string d=dir.getName(i); + int start = ofToInt(d.substr(0,4)); + int end = ofToInt(d.substr(5,4)); + + if (start&&end){ + slots.push_back(timeSlot(dir.getPath(i),start,end)); + ofLogNotice() << "item "<<i<<": "<<start<<" - "<<end<<" "<<dir.getPath(i); + + } + } +} + +int dirScanner::getSlotForTime(){ + /* + read vector of slots + return index of current time + naive approach? assuming that the list is valid + */ + int railwaytime=(ofGetHours()*100)+ofGetMinutes(); + + for(int i = 0; i < slots.size(); i++){ + if (slots[i].start<=railwaytime&&slots[i].end>=railwaytime){ + return i; + } + } + return -1; +} + +void dirPlayer::load(){ + +} + +void dirPlayer::draw(){ + int slot=scanner->getSlotForTime(); + if (slot!=currentslot){ + if (slot>-1){ + ofLogNotice() << "entering slot "<<slot<<": "<<scanner->slots[slot].path; + } + else { + ofLogNotice() << "leaving slots"; + } + currentslot=slot; + } + + +}
\ No newline at end of file |
