int TokyoCreator::batchProcess (const std::string &colorPath, const std::string &spacePath, const std::string &destPath) { fs::path colorpath(colorPath); fs::path spacepath(spacePath); fs::path destpath(destPath); if( !fs::exists(spacepath) ) { throw std::runtime_error("Path " + spacepath.string() + " does not exst"); } else if ( !fs::is_directory(spacepath) ) { throw std::runtime_error("Path " + spacepath.string() + " is not a directory"); } if( !fs::exists(colorpath) ) { throw std::runtime_error("Path " + colorpath.string() + " does not exst"); } else if ( !fs::is_directory(colorpath) ) { throw std::runtime_error("Path " + colorpath.string() + " is not a directory"); } if( !fs::exists(destPath) ) { fs::create_directory(destPath); std::cout << "Created " << destPath << std::endl; } fs::directory_iterator endItr; cv::Mat mat(width, height, CV_16UC1); fs::directory_iterator coloritr(colorpath); fs::directory_iterator spaceitr(spacepath); for(; coloritr != endItr && spaceitr != endItr; ++coloritr, ++spaceitr) { fs::path filename = coloritr->path().filename().replace_extension(extension); std::cout << "Processing: " << filename.string() << std::endl; fs::path dest = destpath / filename; ColorCloud::Ptr cloud = createPointCloud(coloritr->path().string(), spaceitr->path().string()); savePcdToFile(cloud, dest.string()); } }
bool GetTremulousPk3s(const char* destdir, const char* basegame) { std::string baseuri = "https://github.com/wtfbbqhax/tremulous-data/raw/master/"; std::vector<std::string> files = { "data-gpp1.pk3", "data-1.1.0.pk3", "map-arachnid2-1.1.0.pk3", "map-atcs-1.1.0.pk3", "map-karith-1.1.0.pk3", "map-nexus6-1.1.0.pk3", "map-niveus-1.1.0.pk3", "map-transit-1.1.0.pk3", "map-tremor-1.1.0.pk3", "map-uncreation-1.1.0.pk3" }; RestClient::init(); MakeDir(destdir, basegame); if (!PromptDownloadPk3s(basegame, files)) return false; for (auto f : files ) { std::string destpath(destdir); destpath += "/"; destpath += basegame; destpath += "/"; destpath += f; if ( is_good(destpath) ) { return false; } std::cout << "Downloading " << baseuri << f << std::endl; std::ofstream dl(destpath); //dl.open(destpath); if ( dl.fail() ) { std::cerr << "Error " << strerror(errno) << "\n"; continue; } RestClient::Response resp = RestClient::get(baseuri + f); dl << resp.body; dl.close(); } return true; }
bool MakeDir(std::string destdir, std::string basegame) { std::string destpath(destdir); if ( basegame != "" ) { destpath += '/'; destpath += basegame; } if ( *destpath.rbegin() != '/' ) destpath += '/'; // XXX FS_CreatePath requires a trailing slash. // Maybe the assumption is that a file listing might be included? FS_CreatePath(destpath.c_str()); return true; }
void ProjectWindow::ImportFile(entry_ref ref) { BString command; DPath srcpath(ref); DPath destpath(fProject->GetPath().GetFolder()); command << "copyattr --data '" << srcpath.GetFullPath() << "' '" << destpath.GetFullPath() << "'"; system(command.String()); BString ext(srcpath.GetExtension()); if ((ext.ICompare("h") == 0) || (ext.ICompare("hxx") == 0) || (ext.ICompare("hpp") == 0) || (ext.ICompare("h++") == 0)) return; DPath destfile(destpath); destfile << ref.name; BEntry destEntry(destfile.GetFullPath()); entry_ref destref; destEntry.GetRef(&destref); AddFile(destref,NULL); }