• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ filesystem::path类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.c_str());
        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:zardoru,项目名称:raindrop,代码行数:29,代码来源:AudioSourceOJM.cpp


示例2: InvalidOperationException

fs::path
HOSTFXR_UTILITY::GetAbsolutePathToHostFxr(
    const fs::path & dotnetPath
)
{
    std::vector<std::wstring> versionFolders;
    const auto hostFxrBase = dotnetPath.parent_path() / "host" / "fxr";

    LOG_INFOF(L"Resolving absolute path to hostfxr.dll from '%ls'", dotnetPath.c_str());

    if (!is_directory(hostFxrBase))
    {
        throw InvalidOperationException(format(L"Unable to find hostfxr directory at %s", hostFxrBase.c_str()));
    }

    FindDotNetFolders(hostFxrBase, versionFolders);

    if (versionFolders.empty())
    {
        throw InvalidOperationException(format(L"Hostfxr directory '%s' doesn't contain any version subdirectories", hostFxrBase.c_str()));
    }

    const auto highestVersion = FindHighestDotNetVersion(versionFolders);
    const auto hostFxrPath = hostFxrBase  / highestVersion / "hostfxr.dll";

    if (!is_regular_file(hostFxrPath))
    {
        throw InvalidOperationException(format(L"hostfxr.dll not found at '%s'", hostFxrPath.c_str()));
    }

    LOG_INFOF(L"hostfxr.dll located at '%ls'", hostFxrPath.c_str());
    return hostFxrPath;
}
开发者ID:akrisiun,项目名称:IISIntegration,代码行数:33,代码来源:hostfxr_utility.cpp


示例3: run_process

      std::system_error run_process(const std::filesystem::path &filename, const std::vector<std::string> &argv,
                                    const std::vector<std::string> &envp)
      {
         cpid = fork();
         if (cpid == -1)
         {
            return std::system_error(std::make_error_code(std::errc(std::errno)));
         }
         if (cpid == 0)
         {
            std::vector<char *> arg;
            arg.push_back(filename.c_str());
            for (const auto &v : argv)
            {
               arg.push_back(v.c_str());
            }
            arg.push_back(nullptr);

            std::vector<char *> env;
            for (auto &e : envp)
            {
               env.push_back(e.c_str());
            }
            env.push_back(nullptr);

            auto exec_error = execve(filename.c_str(), arg.data(), env.data());
            perror("execve");
            exit(EXIT_FAILURE);
         }
         else
         {
            attached = true;
         }
         return std::system_error(std::make_error_code(std::errc(0)));
      }
开发者ID:Surogate,项目名称:xtsslib,代码行数:35,代码来源:linux_process.hpp


示例4: decrypt_file

void decrypt_file(
   fs::path const & sourcefile,
   fs::path const & destfile,
   std::string_view password)
{
   CryptoPP::FileSource source(
      sourcefile.c_str(),
      true,
      new CryptoPP::DefaultDecryptorWithMAC(
      (CryptoPP::byte*)password.data(), password.size(),
         new CryptoPP::FileSink(
            destfile.c_str())
      )
   );
}
开发者ID:keitee,项目名称:kb,代码行数:15,代码来源:main.cpp


示例5: open

			bool open(const std::filesystem::path& jpeg_file) override
			{
				auto fp = ::fopen(to_osmbstr(to_utf8(jpeg_file.native())).c_str(), "rb");
				if(nullptr == fp) return false;

				bool is_opened = false;

				struct ::jpeg_decompress_struct jdstru;
				error_mgr	jerr;

				jdstru.err = ::jpeg_std_error(&jerr.pub);
				jerr.pub.error_exit = _m_error_handler;

				if (!setjmp(jerr.setjmp_buf))
				{
					::jpeg_create_decompress(&jdstru);

					::jpeg_stdio_src(&jdstru, fp);

					_m_read_jpg(jdstru);

					jpeg_finish_decompress(&jdstru);
					is_opened = true;
				}

				::jpeg_destroy_decompress(&jdstru);
				::fclose(fp);
				return is_opened;
			}
开发者ID:cnjinhao,项目名称:nana,代码行数:29,代码来源:image_jpeg.hpp


示例6: float

//------------------------------------------------------------
bool ofOpenALSoundPlayer::mpg123ReadFile(const std::filesystem::path& path,vector<short> & buffer,vector<float> & fftAuxBuffer){
	int err = MPG123_OK;
	mpg123_handle * f = mpg123_new(nullptr,&err);
	if(mpg123_open(f,path.c_str())!=MPG123_OK){
		ofLogError("ofOpenALSoundPlayer") << "mpg123ReadFile(): couldn't read \"" << path << "\"";
		return false;
	}

	mpg123_enc_enum encoding;
	long int rate;
	mpg123_getformat(f,&rate,&channels,(int*)&encoding);
	if(encoding!=MPG123_ENC_SIGNED_16){
		ofLogError("ofOpenALSoundPlayer") << "mpg123ReadFile(): " << getMpg123EncodingString(encoding)
			<< " encoding for \"" << path << "\"" << " unsupported, expecting MPG123_ENC_SIGNED_16";
		return false;
	}
	samplerate = rate;

	size_t done=0;
	size_t buffer_size = mpg123_outblock( f );
	buffer.resize(buffer_size/2);
	while(mpg123_read(f,(unsigned char*)&buffer[buffer.size()-buffer_size/2],buffer_size,&done)!=MPG123_DONE){
		buffer.resize(buffer.size()+buffer_size/2);
	};
	buffer.resize(buffer.size()-(buffer_size/2-done/2));
	mpg123_close(f);
	mpg123_delete(f);

	fftAuxBuffer.resize(buffer.size());
	for(int i=0;i<(int)buffer.size();i++){
		fftAuxBuffer[i] = float(buffer[i])/32565.f;
	}
	duration = float(buffer.size()/channels) / float(samplerate);
	return true;
}
开发者ID:noyanc,项目名称:openFrameworks,代码行数:36,代码来源:ofOpenALSoundPlayer.cpp


示例7: sfStream

//------------------------------------------------------------
bool ofOpenALSoundPlayer::sfStream(const std::filesystem::path& path,vector<short> & buffer,vector<float> & fftAuxBuffer){
	if(!streamf){
		SF_INFO sfInfo;
		streamf = sf_open(path.c_str(),SFM_READ,&sfInfo);
		if(!streamf){
			ofLogError("ofOpenALSoundPlayer") << "sfStream(): couldn't read \"" << path << "\"";
			return false;
		}

		stream_subformat = sfInfo.format & SF_FORMAT_SUBMASK ;
		if (stream_subformat == SF_FORMAT_FLOAT || stream_subformat == SF_FORMAT_DOUBLE){
			sf_command (streamf, SFC_CALC_SIGNAL_MAX, &stream_scale, sizeof (stream_scale)) ;
			if (stream_scale < 1e-10)
				stream_scale = 1.0 ;
			else
				stream_scale = 32700.0 / stream_scale ;
		}
		channels = sfInfo.channels;
		duration = float(sfInfo.frames) / float(sfInfo.samplerate);
		samplerate = sfInfo.samplerate;
		stream_samples_read = 0;
	}

	int curr_buffer_size = BUFFER_STREAM_SIZE*channels;
	if(speed>1) curr_buffer_size *= (int)round(speed);
	buffer.resize(curr_buffer_size);
	fftAuxBuffer.resize(buffer.size());
	if (stream_subformat == SF_FORMAT_FLOAT || stream_subformat == SF_FORMAT_DOUBLE){
		sf_count_t samples_read = sf_read_float (streamf, &fftAuxBuffer[0], fftAuxBuffer.size());
		stream_samples_read += samples_read;
		if(samples_read<(int)fftAuxBuffer.size()){
			fftAuxBuffer.resize(samples_read);
			buffer.resize(samples_read);
			setPosition(0);
			if(!bLoop) stopThread();
			stream_samples_read = 0;
			stream_end = true;
		}
		for (int i = 0 ; i < int(fftAuxBuffer.size()) ; i++){
			fftAuxBuffer[i] *= stream_scale ;
			buffer[i] = 32565.0 * fftAuxBuffer[i];
		}
	}else{
		sf_count_t frames_read = sf_readf_short(streamf,&buffer[0],curr_buffer_size/channels);
		stream_samples_read += frames_read*channels;
		if(frames_read<curr_buffer_size/channels){
			fftAuxBuffer.resize(frames_read*channels);
			buffer.resize(frames_read*channels);
			setPosition(0);
			if(!bLoop) stopThread();
			stream_samples_read = 0;
			stream_end = true;
		}
		for(int i=0;i<(int)buffer.size();i++){
			fftAuxBuffer[i]=float(buffer[i])/32565.0f;
		}
	}

	return true;
}
开发者ID:noyanc,项目名称:openFrameworks,代码行数:61,代码来源:ofOpenALSoundPlayer.cpp


示例8: LoadSong7KFromFilename

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


示例9: FileWatch

FileWatchWin::FileWatchWin(const std::filesystem::path& path, const FileMonitor::t_callbackFunc& callback, DWORD dwNotifyFilter, HANDLE hDirectory) :
  FileWatch(path),
  m_callback(callback),
  m_dwNotifyFilter(dwNotifyFilter),
  m_hDirectory(hDirectory)
{
  std::string filename = path.filename().string();
  m_filename.assign(filename.begin(), filename.end());

  memset(m_pOverlapped.get(), 0, sizeof(*m_pOverlapped));
  m_pOverlapped->hEvent = CreateEvent(nullptr, true, false, nullptr);
}
开发者ID:leapmotion,项目名称:LeapIPC,代码行数:12,代码来源:FileMonitorWin.cpp


示例10: find_last_file_matching_pattern

static std::filesystem::path find_last_file_matching_pattern(const std::filesystem::path& pattern) {
	std::filesystem::path last_match;
	for(const auto& entry : std::filesystem::directory_iterator(u"", pattern.c_str())) {
		if( std::filesystem::is_regular_file(entry.status()) ) {
			const auto match = entry.path();
			if( match > last_match ) {
				last_match = match;
			}
		}
	}
	return last_match;
}
开发者ID:sharebrained,项目名称:portapack-hackrf,代码行数:12,代码来源:file.cpp


示例11: sfReadFile

// ----------------------------------------------------------------------------
bool ofOpenALSoundPlayer::sfReadFile(const std::filesystem::path& path, vector<short> & buffer, vector<float> & fftAuxBuffer){
	SF_INFO sfInfo;
	SNDFILE* f = sf_open(path.c_str(),SFM_READ,&sfInfo);
	if(!f){
		ofLogError("ofOpenALSoundPlayer") << "sfReadFile(): couldn't read \"" << path << "\"";
		return false;
	}

	buffer.resize(sfInfo.frames*sfInfo.channels);
	fftAuxBuffer.resize(sfInfo.frames*sfInfo.channels);

	int subformat = sfInfo.format & SF_FORMAT_SUBMASK ;
	if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE){
		double	scale ;
		sf_command (f, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
		if (scale < 1e-10)
			scale = 1.0 ;
		else
			scale = 32700.0 / scale ;

		sf_count_t samples_read = sf_read_float (f, &fftAuxBuffer[0], fftAuxBuffer.size());
		if(samples_read<(int)fftAuxBuffer.size()){
			ofLogWarning("ofOpenALSoundPlayer") << "sfReadFile(): read " << samples_read << " float samples, expected "
			<< fftAuxBuffer.size() << " for \"" << path << "\"";
		}
		for (int i = 0 ; i < int(fftAuxBuffer.size()) ; i++){
			fftAuxBuffer[i] *= scale ;
			buffer[i] = 32565.0 * fftAuxBuffer[i];
		}
	}else{
		sf_count_t frames_read = sf_readf_short(f,&buffer[0],sfInfo.frames);
		if(frames_read<sfInfo.frames){
			ofLogError("ofOpenALSoundPlayer") << "sfReadFile(): read " << frames_read << " frames from buffer, expected "
			<< sfInfo.frames << " for \"" << path << "\"";
			return false;
		}
		sf_seek(f,0,SEEK_SET);
		frames_read = sf_readf_float(f,&fftAuxBuffer[0],sfInfo.frames);
		if(frames_read<sfInfo.frames){
			ofLogError("ofOpenALSoundPlayer") << "sfReadFile(): read " << frames_read << " frames from fft buffer, expected "
			<< sfInfo.frames << " for \"" << path << "\"";
			return false;
		}
	}
	sf_close(f);

	channels = sfInfo.channels;
	duration = float(sfInfo.frames) / float(sfInfo.samplerate);
	samplerate = sfInfo.samplerate;
	return true;
}
开发者ID:noyanc,项目名称:openFrameworks,代码行数:52,代码来源:ofOpenALSoundPlayer.cpp


示例12: 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


示例13: 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


示例14:

Optional<File::Error> File::open_fatfs(const std::filesystem::path& filename, BYTE mode) {
	auto result = f_open(&f, reinterpret_cast<const TCHAR*>(filename.c_str()), mode);
	if( result == FR_OK ) {
		if( mode & FA_OPEN_ALWAYS ) {
			const auto result = f_lseek(&f, f_size(&f));
			if( result != FR_OK ) {
				f_close(&f);
			}
		}
	}

	if( result == FR_OK ) {
		return { };
	} else {
		return { result };
	}
}
开发者ID:sharebrained,项目名称:portapack-hackrf,代码行数:17,代码来源:file.cpp


示例15: 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


示例16: _parse_query_file

void FileBasedBenchmarkItemRunner::_parse_query_file(
    const std::filesystem::path& query_file_path, const std::optional<std::unordered_set<std::string>>& query_subset) {
  std::ifstream file(query_file_path);

  // The names of queries from, e.g., "queries/TPCH-7.sql" will be prefixed with "TPCH-7."
  const auto item_name_prefix = query_file_path.stem().string();

  std::string content{std::istreambuf_iterator<char>(file), {}};

  /**
   * A file can contain multiple SQL statements, and each statement may cover one or more lines.
   * We use the SQLParser to split up the content of the file into the individual SQL statements.
   */

  hsql::SQLParserResult parse_result;
  hsql::SQLParser::parse(content, &parse_result);
  Assert(parse_result.isValid(), create_sql_parser_error_message(content, parse_result));

  std::vector<Query> queries_in_file{parse_result.size()};

  size_t sql_string_offset{0u};
  for (auto statement_idx = size_t{0}; statement_idx < parse_result.size(); ++statement_idx) {
    const auto item_name = item_name_prefix + '.' + std::to_string(statement_idx);
    const auto statement_string_length = parse_result.getStatement(statement_idx)->stringLength;
    const auto statement_string = boost::trim_copy(content.substr(sql_string_offset, statement_string_length));
    sql_string_offset += statement_string_length;
    queries_in_file[statement_idx] = {item_name, statement_string};
  }

  // Remove ".0" from the end of the query name if there is only one file
  if (queries_in_file.size() == 1) {
    queries_in_file.front().name.erase(queries_in_file.front().name.end() - 2, queries_in_file.front().name.end());
  }

  /**
   * Add queries to _queries and _item_names, if query_subset allows it
   */
  for (const auto& query : queries_in_file) {
    if (!query_subset || query_subset->count(query.name)) {
      _queries.emplace_back(query);
    }
  }
}
开发者ID:hyrise,项目名称:hyrise,代码行数:43,代码来源:file_based_benchmark_item_runner.cpp


示例17: GetSha256ForFile

    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


示例18: 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


示例19: 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


示例20: writePipe

bool writePipe(const std::filesystem::path &pipe, const std::wstring &data, bool wait)
{
    HANDLE hPipe = CreateFile(pipe.wstring().c_str(), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0,
                              nullptr);
    if (hPipe != INVALID_HANDLE_VALUE) {
        DWORD written;
        const DWORD toWrite = static_cast<DWORD>(data.size() * sizeof(wchar_t));
        WriteFile(hPipe, data.c_str(), toWrite, &written, nullptr);
        const bool success = written == toWrite;
        tLog << (success ? L"Wrote: " : L"Failed to write: ") << data << " to " << pipe;
        WriteFile(hPipe, nullptr, sizeof(wchar_t), &written, nullptr);
        CloseHandle(hPipe);
        return success;
    } else if (wait) {
        // wait and retry
        Sleep(20000);
        return writePipe(pipe, data);
    }
    tLog << L"Failed to open pipe: " << pipe << L" data: " << data;
    return false;
}
开发者ID:KDE,项目名称:snoretoast,代码行数:21,代码来源:utils.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ios_base::failure类代码示例发布时间:2022-05-31
下一篇:
C++ experimental::string_view类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap