当前位置: 首页>>代码示例>>C++>>正文


C++ path::generic_string方法代码示例

本文整理汇总了C++中boost::filesystem::path::generic_string方法的典型用法代码示例。如果您正苦于以下问题:C++ path::generic_string方法的具体用法?C++ path::generic_string怎么用?C++ path::generic_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::filesystem::path的用法示例。


在下文中一共展示了path::generic_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write

void Image::write(const boost::filesystem::path &pfname)
{
  if(data::filename_is_png(pfname))
  {
    if(image_png_supports_bpp(m_b))
    {
      image_png_save(pfname.generic_string(), m_w, m_h, m_b, m_data);
    }
    else
    {
      std::ostringstream str;
      str << '\'' << pfname << "': bit depth " << m_b << " not supported in PNG";
      BOOST_THROW_EXCEPTION(std::runtime_error(str.str()));
    }
  }
  else if(data::filename_is_jpeg(pfname))
  {
    if(image_jpeg_supports_bpp(m_b))
    {
      image_jpeg_save(pfname.generic_string(), m_w, m_h, m_b, m_data);
    }
    else
    {
      std::ostringstream str;
      str << '\'' << pfname << "': bit depth " << m_b << " not supported in JPEG";
      BOOST_THROW_EXCEPTION(std::runtime_error(str.str()));
    }
  }
  else
  {
    std::ostringstream str;
    str << "unknown image type: " << pfname;
    BOOST_THROW_EXCEPTION(std::runtime_error(str.str()));
  }
}
开发者ID:dtbinh,项目名称:faemiyah-demoscene_2010-08_gamedev_orbital_bombardment,代码行数:35,代码来源:image.cpp

示例2: path

EditorColorScheme::EditorColorScheme(fs::path path) : path(path)
{
	try {
		boost::property_tree::read_json(path.generic_string(), pt);
		_name = QString::fromStdString(pt.get<std::string>("name"));
		_index = pt.get<int>("index");
	} catch (const std::exception & e) {
		PRINTB("Error reading color scheme file '%s': %s", path.generic_string() % e.what());
		_name = "";
		_index = 0;
	}
}
开发者ID:ThunderPower,项目名称:openscad,代码行数:12,代码来源:scintillaeditor.cpp

示例3: open

Status FTDCFileWriter::open(const boost::filesystem::path& file) {
    if (_archiveStream.is_open()) {
        return {ErrorCodes::FileAlreadyOpen, "FTDCFileWriter is already open."};
    }

    _archiveFile = file;

    // Ideally, we create a file from scratch via O_CREAT but there is not portable way via C++
    // iostreams to do this.
    _archiveStream.open(_archiveFile.c_str(),
                        std::ios_base::out | std::ios_base::binary | std::ios_base::app);

    if (!_archiveStream.is_open()) {
        return Status(ErrorCodes::FileNotOpen,
                      "Failed to open archive file " + file.generic_string());
    }

    // Set internal size tracking to reflect the current file size
    _size = boost::filesystem::file_size(file);

    _sizeInterim = 0;

    _interimFile = FTDCUtil::getInterimFile(file);
    _interimTempFile = FTDCUtil::getInterimTempFile(file);

    _compressor.reset();

    return Status::OK();
}
开发者ID:Machyne,项目名称:mongo,代码行数:29,代码来源:file_writer.cpp

示例4: file

GTEST_TEST_F(ReadFile, write) {
	ASSERT_FALSE(kFilePath.empty());

	static const byte data[5] = { 0x12, 0x34, 0x56, 0x78, 0x90 };

	// Create the input file

	boost::filesystem::ofstream testFile(kFilePath, std::ofstream::binary);

	testFile.write(reinterpret_cast<const char *>(data), ARRAYSIZE(data));
	testFile.flush();
	ASSERT_FALSE(testFile.fail());

	testFile.close();

	// Read the file with our ReadFile class

	Common::ReadFile file(kFilePath.generic_string());
	ASSERT_TRUE(file.isOpen());

	EXPECT_EQ(file.size(), ARRAYSIZE(data));

	byte readData[ARRAYSIZE(data)];
	const size_t readCount = file.read(readData, sizeof(readData));
	EXPECT_EQ(readCount, ARRAYSIZE(readData));

	file.close();
	ASSERT_FALSE(file.isOpen());

	// Compare

	for (size_t i = 0; i < ARRAYSIZE(data); i++)
		EXPECT_EQ(readData[i], data[i]) << "At index " << i;
}
开发者ID:farmboy0,项目名称:phaethon,代码行数:34,代码来源:readfile.cpp

示例5: save

inline void save(Archive& ar,
    const boost::filesystem::path& p,
    const unsigned int /*version*/) {
    std::string s;
    s = p.generic_string();
    ar & boost::serialization::make_nvp("path", s);
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例6: runtime_error

std::shared_ptr<rett> createAny(const boost::filesystem::path & libpath, const std::string & methodName)
{
#ifdef VCMI_ANDROID
	// android currently doesn't support loading libs dynamically, so the access to the known libraries
	// is possible only via specializations of this template
	throw std::runtime_error("Could not resolve ai library " + libpath.generic_string());
#else
	typedef void(* TGetAIFun)(std::shared_ptr<rett> &);
	typedef void(* TGetNameFun)(char *);

	char temp[150];

	TGetAIFun getAI = nullptr;
	TGetNameFun getName = nullptr;

#ifdef VCMI_WINDOWS
	HMODULE dll = LoadLibraryW(libpath.c_str());
	if (dll)
	{
		getName = (TGetNameFun)GetProcAddress(dll, "GetAiName");
		getAI = (TGetAIFun)GetProcAddress(dll, methodName.c_str());
	}
#else // !VCMI_WINDOWS
	void *dll = dlopen(libpath.string().c_str(), RTLD_LOCAL | RTLD_LAZY);
	if (dll)
	{
		getName = (TGetNameFun)dlsym(dll, "GetAiName");
		getAI = (TGetAIFun)dlsym(dll, methodName.c_str());
	}
#endif // VCMI_WINDOWS

	if (!dll)
	{
		logGlobal->error("Cannot open dynamic library (%s). Throwing...", libpath.string());
		throw std::runtime_error("Cannot open dynamic library");
	}
	else if(!getName || !getAI)
	{
		logGlobal->error("%s does not export method %s", libpath.string(), methodName);
#ifdef VCMI_WINDOWS
		FreeLibrary(dll);
#else
		dlclose(dll);
#endif
		throw std::runtime_error("Cannot find method " + methodName);
	}

	getName(temp);
	logGlobal->info("Loaded %s", temp);

	std::shared_ptr<rett> ret;
	getAI(ret);
	if(!ret)
		logGlobal->error("Cannot get AI!");

	return ret;
#endif //!VCMI_ANDROID
}
开发者ID:vcmi,项目名称:vcmi,代码行数:58,代码来源:CGameInterface.cpp

示例7: is_it_done

bool is_it_done( 
    const bfs::path& filepath, 
    size_map_t&      sizes ) {
    bs::error_code ec;
    if ( bfs::is_regular_file( filepath, ec ) &&
            ec == err::success &&
            ( sizes.count( filepath.generic_string() ) == 0 ||
              sizes[filepath.generic_string()] != bfs::file_size( filepath ) ) ) {
        return false;
    }
    else if ( bfs::is_directory( filepath, ec ) && ec == err::success ) {
        for ( bfs::directory_iterator iter( filepath ), end_iter; iter != end_iter; iter++ ) {
            if ( !is_it_done( iter->path(), sizes ) ) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:AAFC-MBB,项目名称:irods-contrib,代码行数:19,代码来源:libmsiget_filepaths_from_glob.cpp

示例8: beginParsing

	void IParser::beginParsing(boost::filesystem::path path){
		std::ifstream open(path.generic_string(),std::ios_base::binary);
		m_size = boost::filesystem::file_size(path);
		m_readPosition = 0;
		m_buffer = new char[m_size];
		open.read(m_buffer,m_size);
		open.close();

		m_document = DataDocumentPtr(new DataDocument);
	}
开发者ID:KarlJansson,项目名称:GPU_tree-ensembles,代码行数:10,代码来源:IParser.cpp

示例9: target

        void
        writeNode(xercesc::DOMNode&              node,
                  const boost::filesystem::path& file,
                  const WriteParameters&         params)
        {
          Platform xmlplat;

          xercesc::LocalFileFormatTarget target(String(file.generic_string()));

          write_target(node, target, params);
        }
开发者ID:dgault,项目名称:bioformats,代码行数:11,代码来源:Document.cpp

示例10: AddFolder

		void ZipArchiveImpl::AddFolder(const bfs::path& path, const bfs::path& archive_path)
		{
			++m_Info.folderCount;

			zip_fileinfo fileinfo;
			fileinfo.internal_fa = 0;
#ifdef _WIN32
			fileinfo.external_fa = ::GetFileAttributesW(path.native().c_str());
#else
			{
				struct stat path_stat;
				if (::stat(path.native().c_str(), &path_stat) == 0)
				{
					fileinfo.external_fa = path_stat.st_mode;
				}
			}
#endif
			fileinfo.dosDate = 0;
			// Read the time from the filesystem and convert it
			auto fsTime = bfs::last_write_time(path);
			auto posixTime = boost::posix_time::from_time_t(fsTime);
			auto tm = boost::posix_time::to_tm(posixTime);

			/* TODO: this is how to get the time for a physfs file
			boost::posix_time::ptime posixTime;
			auto milisPastEpoc = PHYSFS_getLastModTime(path.generic_string().c_str());
			if (milisPastEpoc >= 0)
			time = boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1), boost::posix_time::milliseconds(milisPastEpoc));
			else
			time = boost::posix_time::second_clock::local_time();
			*/

			fileinfo.tmz_date.tm_hour = tm.tm_hour;
			fileinfo.tmz_date.tm_min = tm.tm_min;
			fileinfo.tmz_date.tm_sec = tm.tm_sec;
			fileinfo.tmz_date.tm_year = tm.tm_year;
			fileinfo.tmz_date.tm_mon = tm.tm_mon;
			fileinfo.tmz_date.tm_mday = tm.tm_mday;

			auto r = zipOpenNewFileInZip(m_File, (archive_path.generic_string() + "/").c_str(),
				&fileinfo,
				nullptr, 0,
				nullptr, 0,
				nullptr,
				Z_DEFLATED,
				Z_BEST_SPEED);

			zipCloseFileInZip(m_File);

			for (bfs::directory_iterator it(path), end = bfs::directory_iterator(); it != end; ++it)
			{
				AddPath(it->path(), archive_path / it->path().filename());
			}
		}
开发者ID:Kezeali,项目名称:Fusion,代码行数:54,代码来源:FusionZipArchive.cpp

示例11: setLink

void Attribute::setLink(const boost::filesystem::path &l)
{  
  _link = l.generic_string();
  
  assert(name != _link);
  
  data = NULL;
  _m = Mat();
  dims = 0;
  size.resize(0);
}
开发者ID:g-manfredi,项目名称:clif,代码行数:11,代码来源:attribute.cpp

示例12: png_read_and_convert_image

inline void png_read_and_convert_image(const boost::filesystem::path& path,Image& im) {
#if defined (_WIN32)
    boost::filesystem::path::string_type path_native = path.native();
    FILE* file = _wfopen(path_native.c_str(), L"rb");
    gil::png_read_and_convert_image(file,im);
    fclose(file);
#else
    std::string filename = path.generic_string();
    png_read_and_convert_image(filename.c_str(),im);
#endif
}
开发者ID:MatGB,项目名称:freeorion,代码行数:11,代码来源:png_io.hpp

示例13: hashFile

void hashFile(const boost::filesystem::path& path, Hash& algorithm)
{
    std::ifstream fileStream(path.generic_string(), std::ios::binary);
    if(fileStream.is_open()) {
        while(!fileStream.eof()) {
            char buffer[4096];
            fileStream.read(buffer, 4096);
            int bytesRead = fileStream.gcount();
            algorithm.add(buffer, bytesRead);
        }
    }
}
开发者ID:peejaybee,项目名称:EmulationStation,代码行数:12,代码来源:Util.cpp

示例14: open

Status FTDCFileReader::open(const boost::filesystem::path& file) {
    _stream.open(file.c_str(), std::ios_base::in | std::ios_base::binary);
    if (!_stream.is_open()) {
        return Status(ErrorCodes::FileStreamFailed, "Failed to open file " + file.generic_string());
    }

    _fileSize = boost::filesystem::file_size(file);

    _file = file;

    return Status::OK();
}
开发者ID:AshishSanju,项目名称:mongo,代码行数:12,代码来源:file_reader.cpp

示例15: handle

boost::optional<ModuleTemplate> ModuleTemplateInstance::CreateFromPath(boost::filesystem::path const& path)
{
    #ifdef _WIN32
        HMODULE syshandle = LoadLibrary(path.generic_string().c_str());
    #else // Posix
        void* syshandle = dlopen(path.generic_string().c_str(), RTLD_LAZY);
    #endif

    if (!syshandle)
        return boost::none;

    InternalHandleType handle(syshandle, [](void* handle)
    {
        #ifdef _WIN32
            FreeLibrary((HMODULE)handle);
        #else // Posix
            dlclose(handle);
        #endif
    });

    #ifdef _WIN32
        unwrap_function<ModuleCreateFunction>::function_ptr const function =
            (unwrap_function<ModuleCreateFunction>::function_ptr)GetProcAddress(syshandle, CREATE_MODULE_FUNCTION_NAME);

    #else // Posix

        // Silences "warning: dereferencing type-punned pointer will break strict-aliasing rules" warnings according to:
        // http://en.wikipedia.org/wiki/Dynamic_loading
        union { unwrap_function<ModuleCreateFunction>::function_ptr function; void* raw; } alias;
        alias.raw = dlsym(syshandle, CREATE_MODULE_FUNCTION_NAME);
        unwrap_function<ModuleCreateFunction>::function_ptr function = alias.function;
    #endif

    if (!function)
        return boost::none;

    return boost::make_optional(ModuleTemplate(
        new ModuleTemplateInstance(std::move(handle), function)));
}
开发者ID:flippy84,项目名称:HotSwap,代码行数:39,代码来源:Module.cpp


注:本文中的boost::filesystem::path::generic_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。