コード例 #1
0
ファイル: tools.cpp プロジェクト: mpusz/Condor2Nav
void condor2nav::Download(const std::string &server, const bfs::path &url, const bfs::path &fileName, unsigned timeout /* = 30 */)
{
  DirectoryCreate(fileName.parent_path());
  bfs::ofstream out{fileName, std::ios_base::out | std::ios_base::binary};
  CIStream in{server, url.generic_string(), timeout};
  out << in;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: thuleqaid/boost_study
void item_action(const bfs::path& ipath)
{
	/* use file_status instead of is_xxx */
	bfs::file_status sts=bfs::status(ipath);
	/* status_error, file_not_found, regular_file, directory_file,
	 * symlink_file, block_file, character_file, fifo_file, socket_file,
	 * type_unknown
	 */
	if (sts.type()==bfs::regular_file)
	{
		std::cout<<ipath.generic_string()<<"\t"<<bfs::file_size(ipath)<<std::endl;
	}
	else if (sts.type()==bfs::directory_file)
	{
		std::cout<<ipath.generic_string()<<std::endl;
	}
	else
	{
		std::cout<<ipath.generic_string()<<std::endl;
	}
}
コード例 #3
0
ファイル: find.cpp プロジェクト: noj/CodeDB
void find(const bfs::path& cdb_path, const options& opt)
{
    config cfg = load_config(cdb_path / "config");

    const bfs::path cdb_root = cdb_path.parent_path();
    const bfs::path search_root = bfs::initial_path();

    std::size_t prefix_size = 0;
    std::string file_match;
    if(opt.m_options.count("-a") == 0 && search_root != cdb_root)
    {
        file_match = "^" + escape_regex(
            search_root.generic_string().substr(cdb_root.string().size() + 1) + "/") + ".*";
        prefix_size = search_root.string().size() - cdb_root.string().size();
    }

    file_lock lock(cdb_path / "lock");
    lock.lock_sharable();

    const char* find_regex_options =
        opt.m_options.count("-i") ? "i" : "";
    const char* file_regex_options =
        cfg.get_value("nocase-file-match") == "on" ? "i" : "";

    bool trim = cfg.get_value("find-trim-ws") == "on";
    unsigned thread_count = get_thread_count(cfg);
    unsigned buffer_count = get_buffer_count(thread_count);

    for(unsigned i = 0; i != opt.m_args.size(); ++i)
    {
        database_ptr db = open_database(cdb_path / "db");

        std::string pattern = opt.m_args[i];
        if(opt.m_options.count("-v"))
            pattern = escape_regex(pattern);

        mt_search mts(*db, trim, prefix_size, buffer_count);

        auto worker = [&]
        {
            mts.search_db(compile_regex(pattern, 0, find_regex_options),
                          compile_regex(file_match, 0, file_regex_options));
        };

        boost::thread_group workers;
        for(unsigned i = 0; i != thread_count-1; ++i)
            workers.create_thread(worker);

        worker();

        workers.join_all();
    }
}
コード例 #4
0
ファイル: fileParserINI.cpp プロジェクト: mpusz/Condor2Nav
/**
 * @brief Class constructor.
 *
 * condor2nav::CFileParserINI class constructor.
 *
 * @param server The server from which to download the INI file.
 * @param url The path on the server to the INI file.
 */
condor2nav::CFileParserINI::CFileParserINI(const std::string &server, const bfs::path &url) :
  _filePath{server + url.generic_string()}
{
  CIStream inputStream{server, url.generic_string()};
  Parse(inputStream);
}