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


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

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


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

示例1: Open

bool AudioSourceOJM::Open(std::filesystem::path f)
{
    char sig[4];

    ifile = std::make_shared<std::ifstream>(f.string(), std::ios::binary);

    if (!ifile->is_open())
    {
        Log::Printf("AudioSourceOJM: unable to load %s.\n", f);
        return false;
    }

    ifile->read(sig, 4);

    switch (GetContainerKind(sig))
    {
    case M30:
        parseM30();
        break;
    case OMC:
        parseOMC();
        break;
    default:
        return false;
    }

    ifile->close();
    return true;
}
开发者ID:TomoAlien,项目名称:raindrop,代码行数:29,代码来源:AudioSourceOJM.cpp

示例2: catch

std::shared_ptr<VSRG::Song> LoadSong7KFromFilename(std::filesystem::path Filename, std::filesystem::path Prefix, VSRG::Song *Sng)
{
	auto prefix = Prefix.string();

    bool AllocSong = false;
    if (!Sng)
    {
        AllocSong = true;
        Sng = new VSRG::Song();
    }

    std::wstring Ext = Utility::Widen(Filename.extension().string());

    // no extension
    if (!Filename.has_extension() || !VSRGValidExtension(Ext))
    {
        if (AllocSong) delete Sng;
        return nullptr;
    }

    Sng->SongDirectory = Prefix.string();
	auto fn = Prefix / Filename;
	auto fnu8 = Utility::Narrow(fn.wstring());

    for (int i = 0; i < sizeof(LoadersVSRG) / sizeof(loaderVSRGEntry_t); i++)
    {
        if (Ext == LoadersVSRG[i].Ext)
        {
            Log::LogPrintf("Load %s from disk...", fnu8.c_str());
            try
            {
                LoadersVSRG[i].LoadFunc(fn, Sng);
                Log::LogPrintf(" ok\n");
            }
            catch (std::exception &e)
            {
                Log::LogPrintf("Failure loading: %s\n", e.what());
            }
            break;
        }
    }

    if (AllocSong)
        return std::shared_ptr<VSRG::Song>(Sng);
    return nullptr;
}
开发者ID:ingcoliptis,项目名称:raindrop,代码行数:46,代码来源:SongLoader.cpp

示例3: loadFontFace

//-----------------------------------------------------------
static bool loadFontFace(const std::filesystem::path& _fontname, FT_Face & face, std::filesystem::path & filename){
	std::filesystem::path fontname = _fontname;
	filename = ofToDataPath(_fontname,true);
	ofFile fontFile(filename,ofFile::Reference);
	int fontID = 0;
	if(!fontFile.exists()){
#ifdef TARGET_LINUX
        filename = linuxFontPathByName(fontname.string());
#elif defined(TARGET_OSX)
		if(fontname==OF_TTF_SANS){
			fontname = "Helvetica Neue";
			#if MAC_OS_X_VERSION_10_13 && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13
				fontID = 0;
			#else
				fontID = 4;
			#endif
		}else if(fontname==OF_TTF_SERIF){
			fontname = "Times New Roman";
		}else if(fontname==OF_TTF_MONO){
			fontname = "Menlo Regular";
		}
        filename = osxFontPathByName(fontname.string());
#elif defined(TARGET_WIN32)
		if(fontname==OF_TTF_SANS){
			fontname = "Arial";
		}else if(fontname==OF_TTF_SERIF){
			fontname = "Times New Roman";
		}else if(fontname==OF_TTF_MONO){
			fontname = "Courier New";
		}
        filename = winFontPathByName(fontname.string());
#endif
		if(filename == "" ){
			ofLogError("ofTrueTypeFont") << "loadFontFace(): couldn't find font \"" << fontname << "\"";
			return false;
		}
		ofLogVerbose("ofTrueTypeFont") << "loadFontFace(): \"" << fontname << "\" not a file in data loading system font from \"" << filename << "\"";
	}
	FT_Error err;
    err = FT_New_Face( library, filename.string().c_str(), fontID, &face );
	if (err) {
		// simple error table in lieu of full table (see fterrors.h)
		string errorString = "unknown freetype";
		if(err == 1) errorString = "INVALID FILENAME";
		ofLogError("ofTrueTypeFont") << "loadFontFace(): couldn't create new face for \"" << fontname << "\": FT_Error " << err << " " << errorString;
		return false;
	}

	return true;
}
开发者ID:ayafuji,项目名称:openFrameworks,代码行数:51,代码来源:ofTrueTypeFont.cpp

示例4: print_pdf

void print_pdf(
   fs::path const & pdfpath,
   fs::path const & dirpath)
{
   const int height = 842;
   const int width = 595;
   const int margin = 20;

   auto image_paths = get_images(dirpath);

   PDFWriter pdf;
   pdf.StartPDF(pdfpath.string(), ePDFVersion13);

   PDFPage* page = nullptr;
   PageContentContext* context = nullptr;

   auto top = height - margin;
   for (size_t i = 0; i < image_paths.size(); ++i)
   {
      auto dims = pdf.GetImageDimensions(image_paths[i]);

      if (i == 0 || top - dims.second < margin)
      {
         if (page != nullptr)
         {
            pdf.EndPageContentContext(context);
            pdf.WritePageAndRelease(page);
         }

         page = new PDFPage();
         page->SetMediaBox(PDFRectangle(0, 0, width, height));
         context = pdf.StartPageContentContext(page);

         top = height - margin;
      }

      context->DrawImage(margin, top - dims.second, image_paths[i]);

      top -= dims.second + margin;
   }

   if (page != nullptr)
   {
      pdf.EndPageContentContext(context);
      pdf.WritePageAndRelease(page);
   }

   pdf.EndPDF();
}
开发者ID:keitee,项目名称:kb,代码行数:49,代码来源:main.cpp

示例5: ConvertToSMTiming

void ConvertToSMTiming(VSRG::Song *Sng, std::filesystem::path PathOut)
{
    TimingData BPS, VSpeeds, Warps;
    VSRG::Difficulty* Diff = Sng->Difficulties[0].get();
    Diff->GetPlayableData(nullptr, BPS, VSpeeds, Warps);

    std::ofstream out(PathOut.string());
    // Technically, stepmania's #OFFSET is actually #GAP, not #OFFSET.
    out << "#OFFSET:" << -Diff->Offset << ";\n";

    out << "#BPMS:";

    for (auto i = Diff->Timing.begin();
    i != Diff->Timing.end();
        ++i)
    {
        double Time = 0;
        double Value = 0;
        switch (Diff->BPMType)
        {
        case VSRG::Difficulty::BT_BEAT:
            Time = i->Time;
            Value = i->Value;
            break;
        case VSRG::Difficulty::BT_BEATSPACE:
            Time = i->Time;
            Value = 60000 / i->Value;
            break;
        case VSRG::Difficulty::BT_MS:
            Time = i->Time / 1000.0;
            Value = i->Value;
            break;
        }

        double Beat = QuantizeBeat(IntegrateToTime(BPS, Time + Diff->Offset, 0));

        out << Beat << "=" << Value;

        if ((i + 1) != Diff->Timing.end()) // Only output comma if there's still stuff to output.
            out << "\n,";
    }

    out << ";";
}
开发者ID:TomoAlien,项目名称:raindrop,代码行数:44,代码来源:Convert.cpp

示例6: SaveCache

bool TTFCache::SaveCache(std::filesystem::path cachepath)
{
	std::ofstream out(cachepath.string(), std::ios::binary);
	if (!out.is_open()) return false;

	auto size = mCharBuffer.size();
	BinWrite(out, size);

	for (const auto &it : mCharBuffer) {
		BinWrite(out, it.first);
		
		auto csize = it.second.size();
		BinWrite(out, csize);

		out.write((char*)it.second.data(), it.second.size());
	}

	return true;
}
开发者ID:zardoru,项目名称:raindrop,代码行数:19,代码来源:TTFCache.cpp

示例7: InStream

    std::string GetSha256ForFile(std::filesystem::path Filename)
    {
        SHA256 SHA;
        std::ifstream InStream(Filename.string());
        unsigned char tmpbuf[256];

        if (!InStream.is_open())
            return "";

        while (!InStream.eof())
        {
            InStream.read((char*)tmpbuf, 256);
            size_t cnt = InStream.gcount();

            SHA.add(tmpbuf, cnt);
        }

        return std::string(SHA.getHash());
    }
开发者ID:TomoAlien,项目名称:raindrop,代码行数:19,代码来源:Utility.cpp

示例8: load

//------------------------------------------------------------
bool ofFmodSoundPlayer::load(std::filesystem::path fileName, bool stream){

	fileName = ofToDataPath(fileName);

	// fmod uses IO posix internally, might have trouble
	// with unicode paths...
	// says this code:
	// http://66.102.9.104/search?q=cache:LM47mq8hytwJ:www.cleeker.com/doxygen/audioengine__fmod_8cpp-source.html+FSOUND_Sample_Load+cpp&hl=en&ct=clnk&cd=18&client=firefox-a
	// for now we use FMODs way, but we could switch if
	// there are problems:

	bMultiPlay = false;

	// [1] init fmod, if necessary

	initializeFmod();

	// [2] try to unload any previously loaded sounds
	// & prevent user-created memory leaks
	// if they call "loadSound" repeatedly, for example

	unload();

	// [3] load sound

	//choose if we want streaming
	int fmodFlags =  FMOD_SOFTWARE;
	if(stream)fmodFlags =  FMOD_SOFTWARE | FMOD_CREATESTREAM;

    result = FMOD_System_CreateSound(sys, fileName.string().c_str(),  fmodFlags, nullptr, &sound);

	if (result != FMOD_OK){
		bLoadedOk = false;
		ofLogError("ofFmodSoundPlayer") << "loadSound(): could not load \"" << fileName << "\"";
	} else {
		bLoadedOk = true;
		FMOD_Sound_GetLength(sound, &length, FMOD_TIMEUNIT_PCM);
		isStreaming = stream;
	}

	return bLoadedOk;
}
开发者ID:Nemquae,项目名称:openFrameworks,代码行数:43,代码来源:ofFmodSoundPlayer.cpp

示例9: run_process

      std::system_error run_process(const std::filesystem::path& filename, const std::vector<std::string>& argv,
                                    const std::vector<std::string>& envp)
      {
         std::memset(&si, 0, sizeof(si));
         std::memset(&pi, 0, sizeof(pi));

         command_line = filename.string();
         for (const auto& s : argv)
         {
            command_line += " " + quote_this(s);
         }
         std::vector<char> env_block;
         env_block.reserve(env.size() * 128);
         for (const auto& keys : envp)
         {
            env_block.insert(env_block.end(), keys.begin(), keys.end());
            env_block.push_back('\0');
         }
         env_block.push_back('\0');

#ifdef _DEBUG
         std::cout << command_line << std::endl;
#endif

		 char* env_block_data = nullptr;
         if(envp.size())
            env_block_data = env_block.data();

         auto result = ::CreateProcessA(NULL, command_line.data(), NULL, NULL,
             TRUE, NULL, env_block_data, running_dir.data(), &si, &pi);
         if (result > 0)
         {
            attached = true;
         }
         else
         {
            return std::system_error(std::error_code(GetLastError(), std::system_category()));
         }
         return std::system_error(std::make_error_code(std::errc(0)));
      }
开发者ID:Surogate,项目名称:xtsslib,代码行数:40,代码来源:windows_process.hpp

示例10: LoadCache

bool TTFCache::LoadCache(std::filesystem::path cachepath)
{
	std::ifstream in(cachepath.string(), std::ios::binary);
	if (!in.is_open()) return false;

	mCharBuffer.clear();
	int size;

	BinRead(in, size);
	while (!in.eof() && size > 0) {
		size_t chsize;
		int id;
		BinRead(in, id);
		BinRead(in, chsize);

		std::vector<uint8_t> buf(chsize);
		in.read((char*)buf.data(), chsize);

		mCharBuffer[id] = std::move(buf);
		size--;
	}

	return true;
}
开发者ID:zardoru,项目名称:raindrop,代码行数:24,代码来源:TTFCache.cpp

示例11: saveAsync

int ofURLFileLoaderImpl::saveAsync(const string& url, const std::filesystem::path& path){
	ofHttpRequest request(url,path.string(),true);
	requests.send(request);
	start();
	return request.getId();
}
开发者ID:Catchoom,项目名称:openFrameworks,代码行数:6,代码来源:ofURLFileLoader.cpp

示例12: saveTo

ofHttpResponse ofURLFileLoaderImpl::saveTo(const string& url, const std::filesystem::path& path){
	ofHttpRequest request(url,path.string(),true);
	return handleRequest(request);
}
开发者ID:Catchoom,项目名称:openFrameworks,代码行数:4,代码来源:ofURLFileLoader.cpp

示例13: loadImage

static bool loadImage(ofPixels_<PixelType> & pix, const std::filesystem::path& _fileName, const ofImageLoadSettings& settings){
	ofInitFreeImage();

	auto uriStr = _fileName.string();
	UriUriA uri;
	UriParserStateA state;
	state.uri = &uri;

	if(uriParseUriA(&state, uriStr.c_str())!=URI_SUCCESS){
		const int bytesNeeded = 8 + 3 * strlen(uriStr.c_str()) + 1;
		std::vector<char> absUri(bytesNeeded);
	#ifdef TARGET_WIN32
		uriWindowsFilenameToUriStringA(uriStr.c_str(), absUri.data());
	#else
		uriUnixFilenameToUriStringA(uriStr.c_str(), absUri.data());
	#endif
		if(uriParseUriA(&state, absUri.data())!=URI_SUCCESS){
			ofLogError("ofImage") << "loadImage(): malformed uri when loading image from uri " << _fileName;
			uriFreeUriMembersA(&uri);
			return false;
		}
	}
	std::string scheme(uri.scheme.first, uri.scheme.afterLast);
	uriFreeUriMembersA(&uri);

	if(scheme == "http" || scheme == "https"){
		return ofLoadImage(pix, ofLoadURL(_fileName.string()).data);
	}

	std::string fileName = ofToDataPath(_fileName, true);
	bool bLoaded = false;
	FIBITMAP * bmp = nullptr;

	FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
	fif = FreeImage_GetFileType(fileName.c_str(), 0);
	if(fif == FIF_UNKNOWN) {
		// or guess via filename
		fif = FreeImage_GetFIFFromFilename(fileName.c_str());
	}
	if((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
		if(fif == FIF_JPEG) {
			int option = getJpegOptionFromImageLoadSetting(settings);
			bmp = FreeImage_Load(fif, fileName.c_str(), option);
		} else {
			bmp = FreeImage_Load(fif, fileName.c_str(), 0);
		}

		if (bmp != nullptr){
			bLoaded = true;
		}
	}

	//-----------------------------

	if ( bLoaded ){
		putBmpIntoPixels(bmp,pix);
	}

	if (bmp != nullptr){
		FreeImage_Unload(bmp);
	}

	return bLoaded;
}
开发者ID:2bbb,项目名称:openFrameworks,代码行数:64,代码来源:ofImage.cpp


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