static void tini_download(flytec_t *flytec, set_t *indexes, const char *manufacturer, igc_filename_format_t igc_filename_format) { int count = 0; track_t **ptrack; for (ptrack = flytec_pbrtl(flytec, manufacturer, igc_filename_format); *ptrack; ++ptrack) { track_t *track = *ptrack; if (indexes && !set_include(indexes, track->index + 1)) continue; if (!overwrite) { struct stat buf; if (stat(track->igc_filename, &buf) == 0) continue; if (errno != ENOENT) DIE("stat", errno); } if (!quiet) fprintf(stderr, "%s: downloading %s ", program_name, track->igc_filename); download_data_t download_data; memset(&download_data, 0, sizeof download_data); download_data.track = track; download_data.file = fopen(track->igc_filename, "w"); if (!download_data.file) error("fopen: %s: %s", track->igc_filename, strerror(errno)); download_data._sc_clk_tck = sysconf(_SC_CLK_TCK); if (download_data._sc_clk_tck == -1) DIE("sysconf", errno); struct tms tms; download_data.clock = times(&tms); if (download_data.clock == (clock_t) -1) DIE("times", errno); if (!quiet) fprintf(stderr, " 0%% "); flytec_pbrtr(flytec, track, download_callback, &download_data); if (fclose(download_data.file) == EOF) DIE("fclose", errno); if (!quiet) { struct tms tms; clock_t clock = times(&tms); if (clock == (clock_t) -1) DIE("times", errno); int sec = (clock - download_data.clock + download_data._sc_clk_tck / 2) / download_data._sc_clk_tck; if (sec > 99 * 60 + 59) sec = 99 * 60 + 59; fprintf(stderr, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b100%% %02d:%02d \n", sec / 60, sec % 60); } ++count; } if (!quiet) { if (count) fprintf(stderr, "%s: %d tracklog%s downloaded\n", program_name, count, count == 1 ? "" : "s"); else if (*flytec_pbrtl(flytec, manufacturer, igc_filename_format) == 0) fprintf(stderr, "%s: no tracklogs to download\n", program_name); else fprintf(stderr, "%s: no new tracklogs to download\n", program_name); } }
void GenerateStdAfxMaker::generate_StdAfx() { if ( ! m_project ) { return; } path std_afx_h = m_project->m_current_path / "src\\StdAfx.h"; path std_afx_cpp = m_project->m_current_path / "src\\StdAfx.cpp"; // 1. check existing if ( boost::filesystem::exists( std_afx_h ) || boost::filesystem::exists( std_afx_cpp ) ) { return; } // 2. collece includes std::set<path> project_includes; collect_includes( project_includes ); // 3. mark standared includes for ( std::set<path>::iterator it = project_includes.begin(); it != project_includes.end(); ++it ) { //std::cout << it->filename().string() << std::endl; set_include( boost::trim_copy( it->filename().string() ) ); } // 4 generate StdAfx std::stringstream strm; // 4.1 strm << "#pragma once" << std::endl; // 4.2 generate standared includes for ( size_t i = 0; i < m_includes.size(); ++i ) { if ( true == m_includes[i].second ) { strm << "#include <" << m_includes[i].first.string() << ">" << std::endl; } } // 4.3 generate transactive includes // 4.3.1 remove files of this own project const std::vector<path>& headers = m_project->m_files_helper->get_paths(); for ( size_t i = 0; i < headers.size(); ++i ) { // TODO: ignore case project_includes.erase( headers[i] ); } // 4.3.2 add transactive includes in order of app-bus-core. // TODO: add cots const char* folders[] = { "\\app\\", "\\bus", "\\core\\" }; size_t size = sizeof(folders) / sizeof(char*); for ( size_t i = 0; i < size; ++i ) { for ( std::set<path>::iterator it = project_includes.begin(); it != project_includes.end(); ++it ) { std::string s = it->string(); size_t pos = s.find( folders[i] ); if ( pos != std::string::npos ) { strm << "#include \"" << s.substr( pos + 1 ) << "\"" << std::endl; } } } //std::cout << strm.rdbuf() << std::endl; // 5. generate StdAfs.h, StdAfx.cpp Utility::write_string_to_file( strm.str(), std_afx_h ); std::cout << "\t" << "+ " << std_afx_h.string() << std::endl; strm.str( "#include \"StdAfx.h\"\n" ); Utility::write_string_to_file( strm.str(), std_afx_cpp ); std::cout << "\t" << "+ " << std_afx_cpp.string() << std::endl; // 6. add StdAfx.h, StdAfx.cpp to .vcproj add_StdAfx_files_to_vcproj(); }