コード例 #1
0
ファイル: Path.cpp プロジェクト: dkoerner/base
	std::string Path::GetBaseFileExtension()
	{
		if(!IsValid())
		{
			return "";
		}
		
		std::string sTmpStr = GetBaseFileName();
		
		// make sure there is no / on the end.
		if(sTmpStr[sTmpStr.length() - 1] == PATH_SEPARATOR_CHAR)
		{
			sTmpStr = sTmpStr.substr(0, sTmpStr.length() - 1);
		}
				
		std::string::size_type pos = sTmpStr.rfind('.');
		
		if(pos != std::string::npos)
		{
			// extract extension.
			return sTmpStr.substr(pos + 1, sTmpStr.length() - (pos + 1));
		}
		else
		{
			// no extension!
			return "";
		}
	}
コード例 #2
0
/////////////////////////////////////////////////////////////////////////////
// GetFileNameTempPath
/////////////////////////////////////////////////////////////////////////////
LPCTSTR	GetFileNameTempPath(
	LPCTSTR	FileName)
{
	TCHAR*	FileNameTempPath		= NULL;
	TCHAR*	FriendlyFileNameBase	= GetBaseFileName(FileName);

	if (NULL != FriendlyFileNameBase)
	{
		TCHAR	TempPath[MAX_PATH]	= {0};

		GetTempPath(MAX_PATH, TempPath);

		FileNameTempPath = ConcatStrings(TempPath, FriendlyFileNameBase);
	}

	return FileNameTempPath;
}
コード例 #3
0
ファイル: Path.cpp プロジェクト: dkoerner/base
	std::string Path::GetBaseFileTitle()
	{
		if(!IsValid())
		{
			return "";
		}
		
		std::string sTmpStr = GetBaseFileName();
		std::string::size_type pos = sTmpStr.rfind('.');
		
		if(pos != std::string::npos)
		{
			// remove extension.
			sTmpStr = sTmpStr.substr(0, pos);
		}
		
		return sTmpStr;
	}
コード例 #4
0
bool CGrayInstall::OpenFile( VERFILE_TYPE i )
{
	CGFile	*pFile = GetMulFile(i);
	if ( !pFile )
		return false;
	if ( pFile->IsFileOpen())
		return true;

	if ( !pFile->GetFilePath().IsEmpty() )
	{
		if ( pFile->Open(pFile->GetFilePath(), OF_READ|OF_SHARE_DENY_WRITE) )
			return true;
	}

	LPCTSTR pszTitle = GetBaseFileName((VERFILE_TYPE)i);
	if ( !pszTitle ) return false;

	return OpenFile(m_File[i], pszTitle, OF_READ|OF_SHARE_DENY_WRITE);
}
コード例 #5
0
VERFILE_TYPE CGrayInstall::OpenFiles( DWORD dwMask )
{
	// Now open all the required files.
	// RETURN: VERFILE_QTY = all open success.
	int i(0);

	for ( i = 0; i < VERFILE_QTY; i++ )
	{
		if ( ! ( dwMask & ( 1 << i )) ) continue;
		if ( GetBaseFileName( (VERFILE_TYPE)i ) == NULL ) continue;

		if ( !OpenFile( (VERFILE_TYPE)i ))
		{
			//	make some MULs optional
			switch ( i )
			{
			case VERFILE_MAP:						//	map #0 is permanent and should exist!
			case VERFILE_STATICS:
			case VERFILE_STAIDX:
				memset(g_MapList.m_maps, false, sizeof(g_MapList.m_maps));
				break;
			case VERFILE_VERDATA:
				continue;
			}
			break;
		}
		else if ( i == VERFILE_MAP )
		{
			char z[256];

			//	check for map files of custom maps
			for ( int m = 0; m < 256; m++ )
			{
				if ( g_MapList.m_maps[m] )
				{
					int	index = g_MapList.m_mapnum[m];

					if ( !m_Maps[index].IsFileOpen() )
					{
						sprintf(z, "map%d.mul", index);
						OpenFile(m_Maps[index], z, OF_READ|OF_SHARE_DENY_WRITE);
					}
					if ( !m_Staidx[index].IsFileOpen() )
					{
						sprintf(z, "staidx%d.mul", index);
						OpenFile(m_Staidx[index], z, OF_READ|OF_SHARE_DENY_WRITE);
					}
					if ( !m_Statics[index].IsFileOpen() )
					{
						sprintf(z, "statics%d.mul", index);
						OpenFile(m_Statics[index], z, OF_READ|OF_SHARE_DENY_WRITE);
					}

					//	if any of the maps are not available, mark map as inavailable
					if ( !m_Maps[index].IsFileOpen() ||
						 !m_Staidx[index].IsFileOpen() ||
						 !m_Statics[index].IsFileOpen() )
					{
						if ( m_Maps[index].IsFileOpen() ) m_Maps[index].Close();
						if ( m_Staidx[index].IsFileOpen() ) m_Staidx[index].Close();
						if ( m_Statics[index].IsFileOpen() ) m_Statics[index].Close();
						g_MapList.m_maps[m] = false;
					}
				}
			}
		}
	}

	g_Log.Event(LOGM_INIT, "Supported Ultima Online expansions: T2A=%s, LBR=%s, AOS=%s, SE=%s" DEBUG_CR,
		( g_MapList.m_maps[0] ? "yes" : "no" ),
		( g_MapList.m_maps[2] ? "yes" : "no" ),
		( g_MapList.m_maps[3] ? "yes" : "no" ),
		( g_MapList.m_maps[4] ? "yes" : "no" ));

	g_MapList.Init();

	return (VERFILE_TYPE)i;
}