| 75 | } |
| 76 | |
| 77 | bool Player::start(BString directory) { |
| 78 | Player::instance = new Player(); |
| 79 | BString script = BString(directory+"/"+RECORDER_SCRIPT); |
| 80 | instance->directory = directory; |
| 81 | instance->file.open(script); |
| 82 | instance->lastCommandTime = 0; |
| 83 | instance->lastScreenRead = 0; |
| 84 | if (!instance->file.isOpen()) { |
| 85 | klog_fmt("script not found: %s error=%d(%s)", script.c_str(), errno, strerror(errno)); |
| 86 | exit(100); |
| 87 | } else { |
| 88 | klog_fmt("using script: %s", script.c_str()); |
| 89 | } |
| 90 | instance->readCommand(); |
| 91 | instance->version = instance->nextValue; |
| 92 | if (instance->version!="2") { |
| 93 | klog_fmt("script is wrong version, was expecting 2 and instead got %s", instance->version.c_str()); |
| 94 | exit(99); |
| 95 | } |
| 96 | instance->readCommand(); |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | void Player::initCommandLine(BString root, const std::vector<BString>& zips, BString working, const std::vector<BString>& args) { |
| 101 | while (this->nextCommand=="ROOT" || this->nextCommand=="ZIP" || this->nextCommand=="CWD" || this->nextCommand=="ARGC" || this->nextCommand.startsWith("ARG")) { |