void extractZip(std::string zipname, std::string target) { ziputils::unzipper zipFile; zipFile.open(zipname.c_str()); for (std::string filename : zipFile.getFilenames()) { fs::path cDir(target + ((fs::path(filename).parent_path().string() == "") ? "" : "/") + fs::path(filename).parent_path().string()); fs::path cFile(target + "/" + filename); fs::path fillPath; for (fs::path pathPart : cDir) { fillPath /= pathPart; if (!exists(fillPath)) { create_directory(fillPath); } } std::cout << "Opening file : " << filename << std::endl; zipFile.openEntry(filename.c_str()); std::ofstream wFile; wFile.open(cFile.string(), std::ios_base::binary | std::ios_base::out); std::string dumped = zipFile.dump(); wFile.write(dumped.c_str(), dumped.size()); wFile.close(); } }
static int BuzzGoTo(buzzvm_t vm) { /* Push the vector components */ buzzvm_lload(vm, 1); buzzvm_lload(vm, 2); /* Create a new vector with that */ CVector2 cDir(buzzvm_stack_at(vm, 2)->f.value, buzzvm_stack_at(vm, 1)->f.value); /* Get pointer to the controller */ buzzvm_pushs(vm, buzzvm_string_register(vm, "controller", 1)); buzzvm_gload(vm); /* Call function */ reinterpret_cast<CBuzzControllerEFootBot*>(buzzvm_stack_at(vm, 1)->u.value)->SetWheelSpeedsFromVector(cDir); return buzzvm_ret0(vm); }
task main() { bDisplayDiagnostics=false; while(true){ int ldst=statRead(UltraLeft, 10); int rdst=statRead(UltraRight, 10); displayTextLine(2, "L: %d R: %d", ldst, rdst); bool lbl = ldst<40; bool rbl = rdst<40; if(lbl&&rbl){ displayCenteredTextLine(3,"OK"); cDir(0,0,0,0); }else if(lbl){ displayCenteredTextLine(3,"<-"); cDir(-speed,-speed,speed,speed); }else if(rbl){ displayCenteredTextLine(3,"->"); cDir(speed,speed,-speed,-speed); }else{ displayCenteredTextLine(3,"BAD"); } wait1Msec(10); } }
static int BuzzGoToP(buzzvm_t vm) { /* Push the vector components */ buzzvm_lload(vm, 1); buzzvm_lload(vm, 2); /* Create a new vector with that */ buzzobj_t tLinSpeed = buzzvm_stack_at(vm, 2); buzzobj_t tAngSpeed = buzzvm_stack_at(vm, 1); Real fLinSpeed = 0.0, fAngSpeed = 0.0; if(tLinSpeed->o.type == BUZZTYPE_INT) fLinSpeed = tLinSpeed->i.value; else if(tLinSpeed->o.type == BUZZTYPE_FLOAT) fLinSpeed = tLinSpeed->f.value; else { buzzvm_seterror(vm, BUZZVM_ERROR_TYPE, "gotop(linspeed,angspeed): expected %s, got %s in first argument", buzztype_desc[BUZZTYPE_FLOAT], buzztype_desc[tLinSpeed->o.type] ); return vm->state; } if(tAngSpeed->o.type == BUZZTYPE_INT) fAngSpeed = tAngSpeed->i.value; else if(tAngSpeed->o.type == BUZZTYPE_FLOAT) fAngSpeed = tAngSpeed->f.value; else { buzzvm_seterror(vm, BUZZVM_ERROR_TYPE, "gotop(linspeed,angspeed): expected %s, got %s in second argument", buzztype_desc[BUZZTYPE_FLOAT], buzztype_desc[tAngSpeed->o.type] ); return vm->state; } CVector2 cDir(fLinSpeed, CRadians(fAngSpeed)); /* Get pointer to the controller */ buzzvm_pushs(vm, buzzvm_string_register(vm, "controller", 1)); buzzvm_gload(vm); /* Call function */ reinterpret_cast<CBuzzControllerFootBot*>(buzzvm_stack_at(vm, 1)->u.value)->SetWheelSpeedsFromVector(cDir); return buzzvm_ret0(vm); }