void QED2KHandle::move_storage(const QString& new_path) const { if (QDir(save_path()) == QDir(new_path)) return; TorrentPersistentData::setPreviousSavePath(hash(), save_path()); // Create destination directory if necessary // or move_storage() will fail... QDir().mkpath(new_path); // Actually move the storage m_delegate.move_storage(new_path.toUtf8().constData()); }
NodePath* Dijkstra::calculate_path(Node* start, Node* dest) { /** * This is the dijkstra algorithm that searches through the node graph for * the most efficiant way from start node to destination node. */ //Initialize; set cost to startnode to zero and rest to inf. Node* current_node = start; NodeVector graph = grid->get_nodes(); for (NodeVector::iterator it = graph.begin(); it != graph.end(); it++) { (*it)->set_cost_from_start(max_cost); } start->set_cost_from_start(0); prio_queue.push(current_node); //Core loop while (!prio_queue.empty()) { current_node = prio_queue.top(); prio_queue.pop(); if (current_node == dest) { save_path(start, dest); while (!prio_queue.empty()) { prio_queue.pop(); } return create_path_copy(saved_paths[NodePair(start, dest)]); } NodeVector neighbors = current_node->get_neighbors(); for (NodeVector::iterator neighbor = neighbors.begin(); neighbor != neighbors.end(); neighbor++) { if (*neighbor == current_node) continue; if (!(*neighbor)->is_allowed()) continue; int new_cost = current_node->get_cost_from_start(); new_cost++; int neighbor_cost = (*neighbor)->get_cost_from_start(); if (new_cost < neighbor_cost) { (*neighbor)->set_cost_from_start(new_cost); (*neighbor)->set_parent(current_node); prio_queue.push((*neighbor)); } } } save_path(start, dest); return create_path_copy(saved_paths[NodePair(start, dest)]); }
int find_monitor_file_type(monitor_dirs *md, const char *path) { int type = 0, found = NFOUND; string save_path(path, strlen(path)); monitor_dir dirobj; vector<string> vAllParents; memset(&dirobj, 0, sizeof(dirobj)); vAllParents.clear(); if ((NULL == md) || (NULL == path) || (0 == strlen(path))) { debug_sys(LOG_ERR, "illegal parameter!\n"); return 0; } get_all_parent_dir((char *)save_path.c_str(), vAllParents); for (vector<string>::iterator it = vAllParents.begin(); it != vAllParents.end(); it++) { if (find_monitor_dir(md, (char *)it->c_str(), &dirobj) == FOUND) { debug_sys(LOG_DEBUG, "path:%s, parent path with type:%s\n", save_path.c_str(), (char *)it->c_str()); type = dirobj.is_counter_size; found = FOUND; break; } } if (found == NFOUND) { debug_sys(LOG_ERR, "Failed to find the parent for %s!, use the default value 0\n", path); } return type; }
int main(){ int i; pt debut = 0; pt fin = _largeur/2 +1; double* mesh = init_tab_mesh(); obstacle(mesh); //double bottom_left[2] = { 10, 10 }; //double top_right[2] = { 15, 15 }; //generate_rectangle(bottom_left, top_right, mesh); double* dist = tab_distance(mesh, debut, fin); printf("\n"); for(i=0; i<_largeur*_largeur;i++){ if(i%_largeur == 0) printf("\n"); printf("%d\t", (int)dist[i]); } printf("\n"); save_dist(dist, "distance.vtk"); pt* chemin = court_chemin_bis(dist, fin); save_path(dist, fin, chemin, "path.vtk"); printf("\n"); for(i=0; i< dist[fin]; i++) printf("%d \t %d \n", chemin[i]/_largeur, chemin[i]%_largeur); free(mesh); free(dist); return 0; }
page_snap::wk_params page_snap::page_data::to_wk_pdf_params() const { page_snap::wk_params params; params.push_back(std::make_pair(page_snap::setting_pdf_object_in, url())); params.push_back(std::make_pair(page_snap::setting_pdf_global_out, save_path() + "/" + save_name())); return params; }
int TracerouteParse( BWLContext ctx, BWLToolDefinition tool, const char *key, const char *val ) { if(!strncasecmp(key,"traceroute_cmd",strlen(key))){ return save_path(ctx,key,val); } if(!strncasecmp(key,"traceroute6_cmd",strlen(key))){ return save_path(ctx,key,val); } return _BWLToolGenericParse(ctx, tool, key, val); }
page_snap::wk_params page_snap::page_data::to_wk_image_params() const { page_snap::wk_params params; params.push_back(std::make_pair(page_snap::setting_img_in, url())); params.push_back(std::make_pair(page_snap::setting_img_out, save_path() + "/" + save_name())); params.push_back(std::make_pair(page_snap::setting_img_fmt, img_fmt())); return params; }
void qsave_path(void) { char *path; char buf[50]; if ((path = vset_get_filename(stack_string("save_path",buf), ".PLY",save_str,OPTPATH_PATH,NULL,TRUE)) != NULL) { if (overwrite_old(path)) { save_path(path); } } }
lt::add_torrent_params create_torrent(int const idx, bool const seed , int const num_pieces) { // TODO: if we want non-seeding torrents, that could be a bit cheaper to // create lt::add_torrent_params params; int swarm_id = test_counter(); char name[200]; std::snprintf(name, sizeof(name), "temp-%02d", swarm_id); std::string path = save_path(idx); lt::error_code ec; lt::create_directory(path, ec); if (ec) std::fprintf(stderr, "failed to create directory: \"%s\": %s\n" , path.c_str(), ec.message().c_str()); std::ofstream file(lt::combine_path(path, name).c_str()); params.ti = ::create_torrent(&file, name, 0x4000, num_pieces + idx, false); file.close(); // by setting the save path to a dummy path, it won't be seeding params.save_path = seed ? path : "dummy"; return params; }
static struct netboot_info * netboot_info_init(struct in_addr iaddr) { boolean_t have_root_path = FALSE; struct netboot_info * info = NULL; char * root_path = NULL; info = (struct netboot_info *)kalloc(sizeof(*info)); bzero(info, sizeof(*info)); info->client_ip = iaddr; info->image_type = kNetBootImageTypeUnknown; /* check for a booter-specified path then a NetBoot path */ MALLOC_ZONE(root_path, caddr_t, MAXPATHLEN, M_NAMEI, M_WAITOK); if (root_path == NULL) panic("netboot_info_init: M_NAMEI zone exhausted"); if (PE_parse_boot_argn("rp0", root_path, MAXPATHLEN) == TRUE || PE_parse_boot_argn("rp", root_path, MAXPATHLEN) == TRUE || PE_parse_boot_argn("rootpath", root_path, MAXPATHLEN) == TRUE) { if (imageboot_format_is_valid(root_path)) { printf("netboot_info_init: rp0='%s' isn't a network path," " ignoring\n", root_path); } else { have_root_path = TRUE; } } if (have_root_path == FALSE) { have_root_path = get_root_path(root_path); } if (have_root_path) { const char * server_name = NULL; char * mount_point = NULL; char * image_path = NULL; struct in_addr server_ip; if (parse_image_path(root_path, &server_ip, &server_name, &mount_point, &image_path)) { info->image_type = kNetBootImageTypeNFS; info->server_ip = server_ip; info->server_name_length = strlen(server_name) + 1; info->server_name = (char *)kalloc(info->server_name_length); info->mount_point_length = strlen(mount_point) + 1; info->mount_point = (char *)kalloc(info->mount_point_length); strlcpy(info->server_name, server_name, info->server_name_length); strlcpy(info->mount_point, mount_point, info->mount_point_length); printf("netboot: NFS Server %s Mount %s", server_name, info->mount_point); if (image_path != NULL) { boolean_t needs_slash = FALSE; info->image_path_length = strlen(image_path) + 1; if (image_path[0] != '/') { needs_slash = TRUE; info->image_path_length++; } info->image_path = (char *)kalloc(info->image_path_length); if (needs_slash) { info->image_path[0] = '/'; strlcpy(info->image_path + 1, image_path, info->image_path_length - 1); } else { strlcpy(info->image_path, image_path, info->image_path_length); } printf(" Image %s", info->image_path); } printf("\n"); } else if (strncmp(root_path, kNetBootRootPathPrefixHTTP, strlen(kNetBootRootPathPrefixHTTP)) == 0) { info->image_type = kNetBootImageTypeHTTP; save_path(&info->image_path, &info->image_path_length, root_path); printf("netboot: HTTP URL %s\n", info->image_path); } else { printf("netboot: root path uses unrecognized format\n"); } /* check for image-within-image */ if (info->image_path != NULL) { if (PE_parse_boot_argn(IMAGEBOOT_ROOT_ARG, root_path, MAXPATHLEN) || PE_parse_boot_argn("rp1", root_path, MAXPATHLEN)) { /* rp1/root-dmg is the second-level image */ save_path(&info->second_image_path, &info->second_image_path_length, root_path); } } if (info->second_image_path != NULL) { printf("netboot: nested image %s\n", info->second_image_path); } } FREE_ZONE(root_path, MAXPATHLEN, M_NAMEI); return (info); }
void HumanClientApp::Autosave() { // autosave only on appropriate turn numbers, and when enabled for current // game type (single vs. multiplayer) int autosave_turns = GetOptionsDB().Get<int>("autosave.turns"); if (autosave_turns < 1) return; // avoid divide by zero if (CurrentTurn() % autosave_turns != 0 && CurrentTurn() != 1) return; // turns divisible by autosave_turns, and first turn, have autosaves done if (m_single_player_game && !GetOptionsDB().Get<bool>("autosave.single-player")) return; if (!m_single_player_game && !GetOptionsDB().Get<bool>("autosave.multiplayer")) return; const char* legal_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-"; // get empire name, filtered for filename acceptability int client_empire_id = EmpireID(); const Empire* empire = GetEmpire(client_empire_id); std::string empire_name; if (empire) empire_name = empire->Name(); else empire_name = UserString("OBSERVER"); std::string::size_type first_good_empire_char = empire_name.find_first_of(legal_chars); if (first_good_empire_char == std::string::npos) { empire_name.clear(); } else { std::string::size_type first_bad_empire_char = empire_name.find_first_not_of(legal_chars, first_good_empire_char); empire_name = empire_name.substr(first_good_empire_char, first_bad_empire_char - first_good_empire_char); } // get player name, also filtered std::string player_name; if (empire) player_name = empire->PlayerName(); std::string::size_type first_good_player_char = player_name.find_first_of(legal_chars); if (first_good_player_char == std::string::npos) { player_name.clear(); } else { std::string::size_type first_bad_player_char = player_name.find_first_not_of(legal_chars, first_good_player_char); player_name = player_name.substr(first_good_player_char, first_bad_player_char - first_good_player_char); } // select filename extension std::string extension; if (m_single_player_game) extension = SP_SAVE_FILE_EXTENSION; else extension = MP_SAVE_FILE_EXTENSION; // Add timestamp to autosave generated files std::string datetime_str = FilenameTimestamp(); boost::filesystem::path autosave_dir_path(GetSaveDir() / "auto"); std::string save_filename = boost::io::str(boost::format("FreeOrion_%s_%s_%04d_%s%s") % player_name % empire_name % CurrentTurn() % datetime_str % extension); boost::filesystem::path save_path(autosave_dir_path / save_filename); std::string path_string = PathString(save_path); try { // ensure autosave directory exists if (!exists(autosave_dir_path)) boost::filesystem::create_directories(autosave_dir_path); } catch (const std::exception& e) { ErrorLogger() << "Autosave unable to check / create autosave directory: " << e.what(); std::cerr << "Autosave unable to check / create autosave directory: " << e.what() << std::endl; } // check for and remove excess oldest autosaves int max_autosaves = GetOptionsDB().Get<int>("autosave.limit"); RemoveOldestFiles(max_autosaves, autosave_dir_path); // create new save DebugLogger() << "Autosaving to: " << path_string; try { SaveGame(path_string); } catch (const std::exception& e) { ErrorLogger() << "Autosave failed: " << e.what(); std::cerr << "Autosave failed: " << e.what() << std::endl; } }
fs::path torrent_handle::save_path() const { INVARIANT_CHECK; TORRENT_FORWARD_RETURN(save_path(), fs::path()); }
int main(int argc, char *argv []) { const char *progname, *infilename0, *infilename1; const char *smooth_filename, *path_filename, *trans_filename; const char *midi_filename, *beat_filename, *image_filename; //just transcribe if trasncribe == 1 int transcribe = 0; // Default for the user definable parameters path_filename = "path.data"; smooth_filename = "smooth.data"; trans_filename = "transcription.txt"; midi_filename = "midi.mid"; beat_filename = "beatmap.txt"; image_filename = "distance.pnm"; progname = strrchr(argv [0], '/'); progname = progname ? progname + 1 : argv[0] ; // If no arguments, return usage if (argc < 2) { print_usage(progname); return 1; } /*******PARSING CODE BEGINS*********/ int i = 1; while (i < argc) { //expected flagged argument if (argv[i][0] == '-') { char flag = argv[i][1]; if (flag == 'h') { sa.frame_period = atof(argv[i+1]); } else if (flag == 'w') { sa.window_size = atof(argv[i+1]); } else if (flag == 'r') { path_filename = argv[i+1]; } else if (flag == 's') { smooth_filename = argv[i+1]; } else if (flag == 't') { trans_filename = argv[i+1]; } else if (flag == 'm') { midi_filename = argv[i+1]; } else if (flag == 'i') { image_filename = argv[i+1]; } else if (flag == 'b') { beat_filename = argv[i+1]; } else if (flag == 'o') { sa.smooth_time = atof(argv[i+1]); } else if (flag == 'p') { sa.presmooth_time = atof(argv[i+1]); } else if (flag == 'x') { sa.line_time = atof(argv[i+1]); } else if (flag == 'd') { sa.silence_threshold = atof(argv[i+1]); } i++; } // When aligning audio to midi we must force file0 to be midi else { // file 1 is midi if (transcribe == 0) { infilename0 = argv[i]; transcribe++; } // file 2 is audio or a second midi else { infilename1 = argv[i]; transcribe++; } } i++; } /**********END PARSING ***********/ if (sa.presmooth_time > 0 && sa.line_time > 0) { printf("WARNING: both -p and -x options selected.\n"); } if (transcribe == 1) { // if only one midi file, just write transcription and exit, // no alignment save_transcription(infilename0, "", false, trans_filename,NULL, NULL, NULL); printf("Wrote %s\n", trans_filename); goto finish; } // if midi only in infilename1, make it infilename0 if (is_midi_file(infilename1) && !is_midi_file(infilename0)) { const char *temp; temp = infilename0; infilename0 = infilename1; infilename1 = temp; } if (!align_files(infilename0, infilename1, sa, true /* verbose */)) { printf("An error occurred, not saving path and transcription data\n"); goto finish; } if (sa.file0_frames <= 2 || sa.file1_frames <= 2) { printf("Error: file frame counts are low: %d (for input 1) and %d " "for input 2)\n...not saving path and transcription data\n", sa.file0_frames, sa.file1_frames); goto finish; } // save path save_path(path_filename, sa.pathlen, sa.pathx, sa.pathy, sa.actual_frame_period_0, sa.actual_frame_period_1); // save image of distance matrix save_image(image_filename, sa); // save smooth, midi, transcription save_transcription(infilename0, infilename1, true, trans_filename, smooth_filename, midi_filename, beat_filename); // print what the chroma matrix looks like /* printf("file0 chroma table: \n"); print_chroma_table(chrom_energy0,file0_frames); printf("\nfile1 chroma table: \n"); print_chroma_table(chrom_energy1, file1_frames); */ // only path and smooth are written when aligning two audio files if (is_midi_file(infilename0) || is_midi_file(infilename1)) printf("Wrote %s, %s, %s, and %s.\n", path_filename, smooth_filename, trans_filename, beat_filename); else printf("Wrote %s and %s.", path_filename, smooth_filename); finish: #ifdef WIN32 printf("Type RETURN to exit\n"); getchar(); #endif return 0 ; } /* main */
QString QED2KHandle::firstFileSavePath() const { return save_path(); }