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


C++ FilePath::c_str方法代码示例

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


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

示例1: loadScript

bool Shader::loadScript( const FilePath& path, std::string& outStr ) const
{
   Filesystem& fs = TSingleton< Filesystem >::getInstance();
   File* file = fs.open( path, std::ios_base::in | std::ios_base::binary );
   if ( file == NULL )
   {
      LOG( "Shader::loadScript - can't open the file '%s'", path.c_str() );
      return false;
   }

   StreamBuffer<char> fileContentsBuf( *file );
   outStr = fileContentsBuf.getBuffer();
   delete file;

   return true;
}
开发者ID:dabroz,项目名称:Tamy,代码行数:16,代码来源:Shader.cpp

示例2: runtime_error

Viewer::Settings::Settings(const std::string& applicationName, const FilePath& filepath):
    m_FilePath(filepath) {

    if(tinyxml2::XML_NO_ERROR != m_Document.LoadFile(filepath.c_str())) {
        throw std::runtime_error("Unable to load viewer settings file");
    }

    if(nullptr == (m_pRoot = m_Document.RootElement())) {
        throw std::runtime_error("Invalid viewer settings file format (no root element)");
    }

    auto pWindow = m_pRoot->FirstChildElement("Window");
    if(!pWindow) {
        throw std::runtime_error("Invalid viewer settings file format (no Window element)");
    }

    if(!getAttribute(*pWindow, "width", m_WindowSize.x) ||
            !getAttribute(*pWindow, "height", m_WindowSize.y)) {
        throw std::runtime_error("Invalid viewer settings file format (no width/height params)");
    }

    auto pViewController = m_pRoot->FirstChildElement("ViewController");
    if(pViewController) {
        if(!getAttribute(*pViewController, "speedFarRatio", m_fSpeedFarRatio)) {
            throw std::runtime_error("Invalid viewer settings file format (no speedFarRatio params in ViewController)");
        }
    }

    auto pFramebuffer = m_pRoot->FirstChildElement("Framebuffer");
    if(!getAttribute(*pFramebuffer, "width", m_FramebufferSize.x) ||
            !getAttribute(*pFramebuffer, "height", m_FramebufferSize.y)) {
        throw std::runtime_error("Invalid viewer settings file format (no width/height params for the framebuffer)");
    }
    m_fFramebufferRatio = float(m_FramebufferSize.x) / m_FramebufferSize.y;

    auto cacheDirectory = filepath.directory() + "cache";
    createDirectory(cacheDirectory);
    m_CacheFilePath = cacheDirectory + (applicationName + ".cache.bnz.xml");
    if(tinyxml2::XML_NO_ERROR != m_CacheDocument.LoadFile(m_CacheFilePath.c_str())) {
        auto pRoot = m_CacheDocument.NewElement("Cache");
        m_CacheDocument.InsertFirstChild(pRoot);
    }
    m_pCacheRoot = m_CacheDocument.RootElement();
}
开发者ID:Celeborn2BeAlive,项目名称:pg2015-code,代码行数:44,代码来源:Viewer.cpp

示例3: wcslen

	bool Win32FileGroupDirectory::removeDirectory( const FilePath & _path )
	{
		WChar filePath[MENGINE_MAX_PATH];
		if( WINDOWSLAYER_SERVICE(m_serviceProvider)
			->concatenateFilePath( m_path, _path, filePath, MENGINE_MAX_PATH ) == false )
		{
			LOGGER_ERROR(m_serviceProvider)("Win32FileSystem::deleteFolder invlalid concatenate filePath '%s':'%s'"
				, m_path.c_str()
				, _path.c_str()
				);

			return false;
		}

		//Double Zero!
		size_t fp_len = wcslen(filePath);
		filePath[fp_len] = L'\0';
		filePath[fp_len + 1] = L'\0';

		SHFILEOPSTRUCT fileop;
		ZeroMemory(&fileop, sizeof(SHFILEOPSTRUCT));
		fileop.hwnd = NULL;
		fileop.wFunc = FO_DELETE;
		fileop.pFrom = filePath;
		fileop.pTo = NULL;		
		fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
		fileop.fAnyOperationsAborted = FALSE;
		fileop.lpszProgressTitle = NULL;
		fileop.hNameMappings = NULL;

		int err = ::SHFileOperation( &fileop );

		if( err != 0 )
		{
			LOGGER_ERROR(m_serviceProvider)("Win32FileSystem::deleteFolder %ls error %d"
				, filePath
				, err
				);

			return false;
		}

		return true;
	}
开发者ID:irov,项目名称:Mengine,代码行数:44,代码来源:Win32FileGroupDirectory.cpp

示例4:

	bool Win32FileGroupDirectory::existFile( const FilePath & _fileName ) const
	{
		WChar filePath[MENGINE_MAX_PATH];
		if( WINDOWSLAYER_SERVICE(m_serviceProvider)
			->concatenateFilePath( m_path, _fileName, filePath, MENGINE_MAX_PATH ) == false )
		{
			LOGGER_ERROR(m_serviceProvider)("Win32FileSystem::existFile invlalid concatenate filePath '%s':'%s'"
				, m_path.c_str()
				, _fileName.c_str()
				);

			return false;
		}

		bool result = WINDOWSLAYER_SERVICE(m_serviceProvider)
			->fileExists( filePath );

        return result;
	}
开发者ID:irov,项目名称:Mengine,代码行数:19,代码来源:Win32FileGroupDirectory.cpp

示例5: path

TEST(Foundation, FilePath)
{
    {
        String tempString;
        FilePath pathCopy;
        FilePath path( TXT( "C:/Users/Test/File.notext.ext" ) );
        HELIUM_TRACE( TraceLevels::Info, TXT( "path: %s\n" ), path.c_str() );

        pathCopy = path;
        tempString = pathCopy.Directory().c_str();
        pathCopy.Set( pathCopy.Directory() );
        HELIUM_ASSERT( tempString == pathCopy.c_str() );
        HELIUM_TRACE( TraceLevels::Info, TXT( "directory name: %s\n" ), *tempString );

        pathCopy = path;
        tempString = pathCopy.Filename().c_str();
        pathCopy.Set( pathCopy.Filename() );
        HELIUM_ASSERT( tempString == pathCopy.c_str() );
        HELIUM_TRACE( TraceLevels::Info, TXT( "filename: %s\n" ), *tempString );

        pathCopy = path;
        tempString = pathCopy.Basename().c_str();
        pathCopy.Set( pathCopy.Basename() );
        HELIUM_ASSERT( tempString == pathCopy.c_str() );
        HELIUM_TRACE( TraceLevels::Info, TXT( "base name: %s\n" ), *tempString );

        pathCopy = path;
        tempString = pathCopy.Extension().c_str();
        pathCopy.Set( pathCopy.Extension() );
        HELIUM_ASSERT( tempString == pathCopy.c_str() );
        HELIUM_TRACE( TraceLevels::Info, TXT( "extension: %s\n" ), *tempString );
    }

    {
        FilePath dataDirectory;
        HELIUM_VERIFY( FileLocations::GetDataDirectory( dataDirectory ) );
        HELIUM_TRACE( TraceLevels::Debug, TXT( "Data directory: %s\n" ), dataDirectory.c_str() );
        HELIUM_UNREF( dataDirectory );

        FilePath userDataDirectory;
        HELIUM_VERIFY( FileLocations::GetUserDataDirectory( userDataDirectory ) );
        HELIUM_TRACE( TraceLevels::Debug, TXT( "User data directory: %s\n" ), userDataDirectory.c_str() );
        HELIUM_UNREF( userDataDirectory );
    }

}
开发者ID:KETMGaming,项目名称:Helium,代码行数:46,代码来源:GTest_Misc.cpp

示例6: createResourceEditor

ResourceEditor* TamyEditor::createResourceEditor( Resource* resource, const QIcon& icon )
{
   // no editor can be created without an active project
   if ( m_activeProject == NULL )
   {
      return NULL;
   }

   // and even if there's an active project, the edited resource must be a part of it
   FilePath resourcePath = resource->getFilePath();
   if ( m_activeProject->isMember( resourcePath ) == false )
   {
      return NULL;
   }

   // if we got this far, it means that we need a new editor to edit this resource
   ResourceEditor* editor = GenericFactory< Resource, ResourceEditor >::create( *resource );
   if ( editor )
   {
      editor->initialize( resourcePath.c_str(), icon );
   }
   return editor;
}
开发者ID:chenwenbin928,项目名称:tamy,代码行数:23,代码来源:tamyeditor.cpp

示例7: createSoundBufferFromFile

	SoundBufferInterfacePtr SoundEngine::createSoundBufferFromFile( const ConstString& _pakName, const FilePath & _fileName, const ConstString & _codecType, bool _streamable )
	{
		if( m_supportStream == false && _streamable == true )
		{
			LOGGER_WARNING(m_serviceProvider)("SoundEngine::createSoundBufferFromFile: unsupport stream sound %s:%s"
				, _pakName.c_str()
				, _fileName.c_str() 
				);

			_streamable = false;
		}

		SoundDecoderInterfacePtr soundDecoder;
		if( _streamable == false )
		{		
			if( PREFETCHER_SERVICE(m_serviceProvider)
				->getSoundDecoder( _pakName, _fileName, soundDecoder ) == false )
			{
				soundDecoder = this->createSoundDecoder_( _pakName, _fileName, _codecType, false );
			}
			else
			{
				if( soundDecoder->rewind() == false )
				{
					LOGGER_ERROR(m_serviceProvider)("RenderTextureManager::loadTexture invalid rewind decoder '%s':'%s'"
						, _pakName.c_str()
						, _fileName.c_str()
						);

					return nullptr;
				}
			}
		}
		else
		{
			soundDecoder = this->createSoundDecoder_( _pakName, _fileName, _codecType, true );
		}

		if( soundDecoder == nullptr )
		{
			LOGGER_ERROR(m_serviceProvider)("SoundEngine::createSoundBufferFromFile invalid create decoder '%s':'%s' type %s"
				, _pakName.c_str()
				, _fileName.c_str()
				, _codecType.c_str()
				);

			return nullptr;
		}

		SoundBufferInterfacePtr buffer = SOUND_SYSTEM(m_serviceProvider)
            ->createSoundBuffer( soundDecoder, _streamable );

        if( buffer == nullptr )
        {
            LOGGER_ERROR(m_serviceProvider)("SoundEngine::createSoundBufferFromFile: Can't create sound buffer for file %s:%s"
                , _pakName.c_str()
                , _fileName.c_str() 
                );

            return nullptr;
        }

		return buffer;
	}
开发者ID:irov,项目名称:Mengine,代码行数:64,代码来源:SoundEngine.cpp

示例8: AppMain

int AppMain()
{
	int argc;
	LPCWSTR lpCmdLine = GetCommandLineW();
	LPWSTR *ppArgv = CommandLineToArgvW(lpCmdLine, &argc);
	LPCWSTR lpDiskPath = NULL;
	bool ShowSettingsDialog = false, ForceMountOptions = false, AdminModeOnNetworkShare = false;
	bool bDisableUAC = false;
	char DriveLetterToRemount = 0;
	BazisLib::String tmpString;

	for (int i = 1; i < argc; i++)
	{
		if (ppArgv[i][0] != '/')
		{
			if (!lpDiskPath)
				lpDiskPath = ppArgv[i];
		}
		else
		{
			if (!_wcsicmp(ppArgv[i], L"/settings"))
				ShowSettingsDialog = true;
			else if (!_wcsicmp(ppArgv[i], L"/ltrselect"))
				ForceMountOptions = true;
			else if (!_wcsicmp(ppArgv[i], L"/uac_on_network_share"))
				AdminModeOnNetworkShare = true;
			else if (!_wcsicmp(ppArgv[i], L"/uacdisable"))
				bDisableUAC = true;
			else if (!_wcsicmp(ppArgv[i], L"/createiso") || !_wcsicmp(ppArgv[i], L"/isofromfolder"))
			{
				if (argc < (i + 2))
				{
					MessageBox(HWND_DESKTOP, _TR(IDS_BADCMDLINE, "Invalid command line!"), NULL, MB_ICONERROR);
					return 1;
				}
				ActionStatus st;
				if (!_wcsicmp(ppArgv[i], L"/isofromfolder"))
				{
					wchar_t *pwszFolder = ppArgv[i + 1];
					if (pwszFolder[0] && pwszFolder[wcslen(pwszFolder) - 1] == '\"')
						pwszFolder[wcslen(pwszFolder) - 1] = '\\';

					st = BuildISOFromFolder(pwszFolder);
				}
				else
					st = CreateISOFile(ppArgv[i + 1]);

				if (!st.Successful() && st.GetErrorCode() != OperationAborted)
					MessageBox(HWND_DESKTOP, st.GetMostInformativeText().c_str(), NULL, MB_ICONERROR);
				return !st.Successful();
			}
			else if (!_wcsnicmp(ppArgv[i], L"/remount:", 9))
				DriveLetterToRemount = (char)ppArgv[i][9];
		}
	}

	if (bDisableUAC)
	{
		RegistryKey driverParametersKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\BazisVirtualCDBus\\Parameters"));
		int prevVal = driverParametersKey[_T("GrantAccessToEveryone")];
		int newVal = 1;
		driverParametersKey[_T("GrantAccessToEveryone")] = newVal;

		if (prevVal != newVal)
			VirtualCDClient::RestartDriver();

		return 0;
	}

	if (GetKeyState(VK_SHIFT) & (1 << 31))
		ForceMountOptions = true;

	if (!lpDiskPath && DriveLetterToRemount)
	{
		const TCHAR *pwszFilter = _TR(IDS_ISOFILTER, "ISO images (*.iso)|*.iso|All files (*.*)|*.*");
		TCHAR tszFilter[128] = { 0, };
		_tcsncpy(tszFilter, pwszFilter, _countof(tszFilter) - 1);
		for (size_t i = 0; i < _countof(tszFilter); i++)
		if (tszFilter[i] == '|')
			tszFilter[i] = '\0';

		CFileDialog dlg(true, _T("iso"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, tszFilter);
		dlg.m_ofn.lpstrTitle = _TR(IDS_MOUNTIMAGE, "Mount a disc image");

		if (dlg.DoModal() != IDOK)
			return 1;

		tmpString.assign(dlg.m_szFileName);
		lpDiskPath = tmpString.c_str();
	}

	if ((argc < 2) || !ppArgv || !lpDiskPath || ShowSettingsDialog)
	{
		return ::ShowSettingsDialog();
	}

	MMCProfile detectedProfile = mpInvalid;
	bool bFileOnNetworkShare = false;

	{
//.........这里部分代码省略.........
开发者ID:ChuckNorrison,项目名称:WinCDEmu,代码行数:101,代码来源:vmnt.cpp

示例9: unloadResources

	bool ResourceManager::unloadResources( const ConstString & _locale, const ConstString & _pakName, const FilePath & _path )
	{
		Metacode::Meta_DataBlock datablock;

		bool exist = false;
		if( LOADER_SERVICE( m_serviceProvider )->load( _pakName, _path, &datablock, exist ) == false )
		{
			if( exist == false )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: resource '%s:%s' not found"
					, _pakName.c_str()
					, _path.c_str()
					);
			}
			else
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: Invalid parse resource '%s:%s'"
					, _pakName.c_str()
					, _path.c_str()
					);
			}

			return false;
		}

		ConstString groupName;
		datablock.swap_Name( groupName );

		const Metacode::Meta_DataBlock::TVectorMeta_Include & includes_include = datablock.get_IncludesInclude();

		for( Metacode::Meta_DataBlock::TVectorMeta_Include::const_iterator
			it = includes_include.begin(),
			it_end = includes_include.end();
		it != it_end;
		++it )
		{
			const Metacode::Meta_DataBlock::Meta_Include & meta_include = *it;

			const FilePath & path = meta_include.get_Path();

			if( this->unloadResources( _locale, _pakName, path ) == false )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource load %s:%s resource invalid load include %s"
					, _pakName.c_str()
					, _path.c_str()
					, path.c_str()
					);

				return false;
			}
		}

		const Metacode::Meta_DataBlock::TVectorMeta_Resource & includes_resource = datablock.get_IncludesResource();

		for( Metacode::Meta_DataBlock::TVectorMeta_Resource::const_iterator
			it = includes_resource.begin(),
			it_end = includes_resource.end();
		it != it_end;
		++it )
		{
			const Metacode::Meta_DataBlock::Meta_Resource * meta_resource = *it;

			const ConstString & name = meta_resource->get_Name();
			const ConstString & type = meta_resource->get_Type();

			ResourceReferencePtr has_resource = nullptr;
			if( this->hasResource( name, &has_resource ) == false )
			{
				const ConstString & resource_category = has_resource->getCategory();

				LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: path %s not found resource name '%s' in group '%s' category '%s' ('%s')\nhas resource category '%s' group '%s' name '%s'"
					, _path.c_str()
					, name.c_str()
					, groupName.c_str()
					, _pakName.c_str()
					, resource_category.c_str()
					, has_resource->getCategory().c_str()
					, has_resource->getGroup().c_str()
					, has_resource->getName().c_str()
					);

				return nullptr;
			}

			if( this->removeResource( has_resource ) == false )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: '%s' invalid remove resource '%s:%s' name %s type %s"
					, _path.c_str()
					, _pakName.c_str()
					, groupName.c_str()
					, name.c_str()
					, type.c_str()
					);

				return false;
			}
		}

		return true;
	}
开发者ID:irov,项目名称:Mengine,代码行数:100,代码来源:ResourceManager.cpp

示例10: load

	bool LoaderEngine::load( const ConstString & _pak, const FilePath & _path, Metabuf::Metadata * _metadata, bool & _exist ) const
	{
        LOGGER_INFO(m_serviceProvider)( "LoaderEngine::load pak '%s:%s'"
            , _pak.c_str()
            , _path.c_str()
            );

		if( _path.empty() == true )
		{
			LOGGER_ERROR(m_serviceProvider)("LoaderEngine::import invalid open bin '%s' path is empty"
				, _pak.c_str()
				);

			return false;
		}

		InputStreamInterfacePtr file_bin;
		if( this->openBin_( _pak, _path, file_bin, _exist ) == false )
		{
            LOGGER_ERROR(m_serviceProvider)("LoaderEngine::import invalid open bin '%s':'%s'"
                , _pak.c_str()
                , _path.c_str()
                );

			return false;
		}

		if( file_bin == nullptr )
		{
			return true;
		}

		bool reimport = false;
		bool done = this->importBin_( file_bin, _metadata, &reimport );

#	ifndef MENGINE_MASTER_RELEASE
		if( reimport == true )
		{
            file_bin = nullptr;
			
			PathString cache_path_xml;			
			cache_path_xml += _path;			
			cache_path_xml.replace_last( "xml" );
            			
            ConstString c_cache_path_xml = Helper::stringizeString( m_serviceProvider, cache_path_xml );

			if( this->makeBin_( _pak, c_cache_path_xml, _path ) == false )
			{
                LOGGER_ERROR(m_serviceProvider)("LoaderEngine::import invlid rebild bin %s from xml %s"
                    , _path.c_str()
                    , c_cache_path_xml.c_str()
                    );

				return false;
			}

			file_bin = FILE_SERVICE(m_serviceProvider)
                ->openInputFile( _pak, _path, false );

			done = this->importBin_( file_bin, _metadata, nullptr );
		}
#	endif

		return done;
	}
开发者ID:irov,项目名称:Mengine,代码行数:65,代码来源:LoaderEngine.cpp

示例11: makeBin_

	bool LoaderEngine::makeBin_( const ConstString & _pak, const FilePath & _pathXml, const FilePath & _pathBin ) const
	{
		XmlDecoderInterfacePtr decoder = CODEC_SERVICE(m_serviceProvider)
            ->createDecoderT<XmlDecoderInterfacePtr>( STRINGIZE_STRING_LOCAL(m_serviceProvider, "xml2bin") );

		if( decoder == nullptr )
		{
			LOGGER_ERROR(m_serviceProvider)("LoaderEngine::makeBin_ invalid create decoder xml2bin for %s:%s"
				, _pak.c_str()
				, _pathXml.c_str()
				);

			return false;
		}

		if( decoder->prepareData( nullptr ) == false )
		{
			LOGGER_ERROR(m_serviceProvider)("LoaderEngine::makeBin_ invalid initialize decoder xml2bin for %s:%s"
				, _pak.c_str()
				, _pathXml.c_str()
				);

			return false;
		}

		XmlCodecOptions options;
        options.pathProtocol = m_protocolPath;
		
        FileGroupInterfacePtr fileGroup = FILE_SERVICE(m_serviceProvider)
            ->getFileGroup( _pak );

        if( fileGroup == nullptr )
        {
            LOGGER_ERROR(m_serviceProvider)("LoaderEngine::makeBin_ invalid get file group %s (%s)"
                , _pak.c_str()
                , _pathXml.c_str()
                );

            return false;
        }

		const FilePath & path = fileGroup->getPath();
			
		options.pathXml = Helper::concatenationFilePath( m_serviceProvider, path, _pathXml );
		options.pathBin = Helper::concatenationFilePath( m_serviceProvider, path, _pathBin );

		if( decoder->setOptions( &options ) == false )
        {
            return false;
        }

		//if( decoder->initialize( m_serviceProvider, 0 ) == false )
		//{
			//decoder->destroy();

			//return false;
		//}

		if( decoder->decode( 0, 0 ) == 0 )
		{
			return false;
		}

		return true;
	}
开发者ID:irov,项目名称:Mengine,代码行数:65,代码来源:LoaderEngine.cpp

示例12: is_path_exists

bool is_path_exists(const FilePath& fullpath)
{
	DWORD attr = GetFileAttributes(fullpath.c_str());

	return (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY));
}
开发者ID:icedmaster,项目名称:mhe,代码行数:6,代码来源:win_fs.cpp

示例13: wxString

template<> inline
wxString
glue_cast<wxString, FilePath>(const FilePath &value)
{
  return wxString(value.c_str(), wxConvUTF8);
}
开发者ID:idle-code,项目名称:MRU,代码行数:6,代码来源:glue_extension.hpp

示例14: CreateFileMapping

	bool Win32FileMapped::open( const FilePath & _folder, const FilePath & _fileName )
	{
        WChar filePath[MENGINE_MAX_PATH];
        if( WINDOWSLAYER_SERVICE(m_serviceProvider)
			->concatenateFilePath( _folder, _fileName, filePath, MENGINE_MAX_PATH ) == false )
        {
            LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open invlalid concatenate filePath '%s':'%s'"
                , _folder.c_str()
                , _fileName.c_str()
                );

            return false;
        }

		m_hFile = WINDOWSLAYER_SERVICE(m_serviceProvider)->createFile( 
            filePath, // file to open
			GENERIC_READ, // open for reading
			FILE_SHARE_READ, // share for reading, exclusive for mapping
			OPEN_EXISTING // existing file only
            );

		if ( m_hFile == INVALID_HANDLE_VALUE)
		{
            LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open %ls invalid open"
                , filePath
                );

			return false;
		}

		m_hMapping = CreateFileMapping( m_hFile, NULL, PAGE_READONLY, 0, 0, NULL );

		if( m_hMapping == NULL )
		{
			DWORD error = GetLastError();

			LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open invalid create file mapping %ls error %d"
				, filePath
				, error
				);

			::CloseHandle( m_hFile );
			m_hFile = INVALID_HANDLE_VALUE;
		
			return false;
		}

		m_memory = MapViewOfFile( m_hMapping, FILE_MAP_READ, 0, 0, 0 );

		if( m_memory == NULL )
		{
			DWORD error = GetLastError();

			LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open invalid map view of file %ls error %d"
				, filePath
				, error
				);

			::CloseHandle( m_hMapping );
			m_hMapping = INVALID_HANDLE_VALUE;

			::CloseHandle( m_hFile );
			m_hFile = INVALID_HANDLE_VALUE;
			
			return false;
		}

		return true;
	}
开发者ID:irov,项目名称:Mengine,代码行数:69,代码来源:Win32FileMapped.cpp

示例15: validateResources

	bool ResourceManager::validateResources( const ConstString & _locale, const ConstString & _pakName, const FilePath & _path ) const
    {
		Metacode::Meta_DataBlock datablock;

		bool exist = false;
		if( LOADER_SERVICE( m_serviceProvider )->load( _pakName, _path, &datablock, exist ) == false )
		{
			if( exist == false )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources resource '%s:%s' not found"
					, _pakName.c_str()
					, _path.c_str()
					);
			}
			else
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources Invalid parse resource '%s:%s'"
					, _pakName.c_str()
					, _path.c_str()
					);
			}

			return false;
		}

		bool successful = true;

		ConstString groupName;
		datablock.swap_Name( groupName );

		const Metacode::Meta_DataBlock::TVectorMeta_Include & includes_include = datablock.get_IncludesInclude();

		for( Metacode::Meta_DataBlock::TVectorMeta_Include::const_iterator
			it = includes_include.begin(),
			it_end = includes_include.end();
		it != it_end;
		++it )
		{
			const Metacode::Meta_DataBlock::Meta_Include & meta_include = *it;

			const FilePath & path = meta_include.get_Path();

			if( this->validateResources( _locale, _pakName, path ) == false )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources load %s:%s resource invalid load include %s"
					, _pakName.c_str()
					, _path.c_str()
					, path.c_str()
					);

				successful = false;

				continue;
			}
		}

		const Metacode::Meta_DataBlock::TVectorMeta_Resource & includes_resource = datablock.get_IncludesResource();

		for( Metacode::Meta_DataBlock::TVectorMeta_Resource::const_iterator
			it = includes_resource.begin(),
			it_end = includes_resource.end();
		it != it_end;
		++it )
		{
			const Metacode::Meta_DataBlock::Meta_Resource * meta_resource = *it;

			const ConstString & name = meta_resource->get_Name();
			const ConstString & type = meta_resource->get_Type();

			bool unique = true;
			meta_resource->get_Unique( unique );

			ResourceReferencePtr resource =
				this->generateResource( type );

			if( resource == nullptr )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources '%s' invalid create resource '%s:%s' name %s type %s"
					, _path.c_str()
					, _pakName.c_str()
					, groupName.c_str()
					, name.c_str()
					, type.c_str()
					);

				successful = false;

				continue;
			}

			resource->setLocale( _locale );
			resource->setCategory( _pakName );
			resource->setGroup( groupName );
			resource->setName( name );

			if( resource->loader( meta_resource ) == false )
			{
				LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources '%s' category '%s' group '%s' name '%s' type '%s' invalid load"
					, _path.c_str()
					, _pakName.c_str()
//.........这里部分代码省略.........
开发者ID:irov,项目名称:Mengine,代码行数:101,代码来源:ResourceManager.cpp


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