コード例 #1
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
std::string CVProjectUtil::ConstructPath(
	const std::string &srcDst,
	const std::string &type,
	const std::string &file,
	const std::string &ext,
	bool enforceExtension ) const
{
	try
	{
		// See if an extension was supplied in file, use it if supplied

		std::string newFile( File( file ) );
		std::string newExt( ext );
		boost::replace_all( newFile, "\\", "/" );

		boost::smatch match;
		if ( boost::regex_match( newFile, match, boost::regex( "([^\\.]+)\\.([^/\\.]+)" ) ) )
		{
			newFile.assign( match[ 1 ].first, match[ 1 ].second );

			if ( !enforceExtension || newExt.empty() )
			{
				newExt.assign( match[ 2 ].first, match[ 2 ].second );
			}
		}

		if ( newExt.empty() )
		{
			newExt = "unk";
		}

		if ( m_game.size() )
		{
			return FullPath( std::string( m_prefix +
				"/" + srcDst +
				( m_game.size() ? std::string( "/" ) + m_game : "" ) +
				"/" + type + ( ( type == m_subType ) ? ( "" ) : ( "/" + m_subType ) ) +
				( m_path.size() ? std::string( "/" ) + m_path : "" ) +
				"/" + newFile + "." + newExt ) );
		}

		return FullPath( std::string( m_prefix +
			( m_game.size() ? std::string( "/" ) + m_game : "" ) +
			( m_path.size() ? std::string( "/" ) + m_path : "" ) +
			"/" + newFile + "." + newExt ) );
	}
	catch ( ... )
	{
	}

	return std::string();
}
コード例 #2
0
void CSettingTypeRelativePath::BuildPath(void)
{
    CPath FullPath(g_Settings->LoadStringVal(Cmd_BaseDirectory).c_str(),"");
    FullPath.AppendDirectory(m_Directory.c_str());
    FullPath.SetNameExtension(m_FileName.c_str());
    m_FullPath = (const char *)FullPath;
}
コード例 #3
0
ファイル: screenshot.cpp プロジェクト: AMDmi3/symwars3
void SaveScreenshot()
{
	Player* py = &g_player[g_curP];

	LoadedTex screenshot;
	screenshot.channels = 3;
	screenshot.sizeX = py->width;
	screenshot.sizeY = py->height;
	screenshot.data = (unsigned char*)malloc( sizeof(unsigned char) * py->width * py->height * 3 );

	if(!screenshot.data)
	{
		OutOfMem(__FILE__, __LINE__);
		return;
	}

	memset(screenshot.data, 0, py->width * py->height * 3);

	glReadPixels(0, 0, py->width, py->height, GL_RGB, GL_UNSIGNED_BYTE, screenshot.data);

	FlipImage(&screenshot);

	char relative[256];
	std::string datetime = FileDateTime();
	sprintf(relative, "screenshots/%s.jpg", datetime.c_str());
	char fullpath[MAX_PATH+1];
	FullPath(relative, fullpath);

	g_log<<"Writing screenshot "<<fullpath<<std::endl;
	g_log.flush();

	SaveJPEG(fullpath, &screenshot, 0.9f);

	//free(screenshot.data);
}
コード例 #4
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
std::string CVProjectUtil::CopyTextureToMaterialSrc(
	const std::string &srcFile,
	const std::string &dstFile )
{
	try
	{
		std::string src( FullPath( srcFile ) );
		boost::replace_all( src, "\\", "/" );

		// See if the source file is accessible
		if ( _access( src.c_str(), 04 ) < 0 )
		{
			merr << "Cannot read source texture file: " << src << std::endl;
			return "";
		}

		boost::smatch match;
		if ( !boost::regex_match( src, match, boost::regex( ".*/([^/\\.]+)\\.([^/\\.]*)?" ) ) )
		{
			merr << "Cannot determine source texture filename from: " << src << std::endl;
			return "";
		}

		std::string file( match[ 1 ].first, match[ 1 ].second );
		std::string ext( match[ 2 ].first, match[ 2 ].second );

		const std::string dst( MaterialSrc( dstFile, ext ) );

		if ( _access( dst.c_str(), 00 ) == 0 )
		{
			merr << "Cannot overwrite destination file: " << dst << std::endl;
			return "";
		}

		if ( file.empty() )
		{
			merr << "Cannot determine source texture filename from: " << src << std::endl;
			return "";
		}

		if ( ext.empty() )
		{
			ext = "tga";
		}

		minfo << "Copying " << src << " -> " << dst << std::endl;

		if ( !CopyFile( src.c_str(), dst.c_str(), true ) )
		{
			merr << "Cannot copy Source texture from " << src << " to " << dst << std::endl;
			return "";
		}
	}
	catch ( ... )
	{
	}

	return dstFile;
}
コード例 #5
0
ファイル: debug.cpp プロジェクト: AMDmi3/symwars3
void WriteProfiles(int in, int layer)
{
	double parentavgms;

	if(in == -1)
	{
		char fullpath[MAX_PATH+1];
		FullPath("profiles.txt", fullpath);
		g_profF.open(fullpath, std::ios_base::out);
		parentavgms = g_profile[TIMER_FRAME].averagems;
	}
	else
	{
		parentavgms = g_profile[in].averagems;
	}

	double ofparentpct;
	double totalms = 0;
	double totalofparentpct = 0;
	double percentage;
	int subprofiles = 0;

	for(int j=0; j<TIMERS; j++)
	{
		if(g_profile[j].inside != in)
			continue;

		totalms += g_profile[j].averagems;
	}

	for(int j=0; j<TIMERS; j++)
	{
		if(g_profile[j].inside != in)
			continue;

		percentage = 100.0 * g_profile[j].averagems / totalms;
		ofparentpct = 100.0 * g_profile[j].averagems / parentavgms;
		totalofparentpct += ofparentpct;
		subprofiles++;

		for(int k=0; k<layer; k++)
			g_profF<<"\t";

		g_profF<<g_profile[j].name<<"\t...\t"<<g_profile[j].averagems<<"ms per frame, "<<percentage<<"% of this level's total"<<std::endl;

		WriteProfiles(j, layer+1);
	}

	if(subprofiles > 0)
	{
		for(int k=0; k<layer; k++)
			g_profF<<"\t";

		g_profF<<"level total sum: "<<totalms<<" ms per frame, that means "<<totalofparentpct<<"% of this parent's duration underwent profiling"<<std::endl;
	}

	if(in == -1)
		g_profF.flush();
}
コード例 #6
0
BOOL CFileUtil::RemoveDir(char* szPathName)
{
    char    sz[MAX_PATH];

    if (FullPath(sz, szPathName, MAX_PATH))
    {
        return RecurseRemoveDir(sz);
    }
    return FALSE;
}
/** Simple parsing of a record set to update state */
static void ParseRecordSetForState(const FP4RecordSet& InRecords, TMap<FString, EPerforceState::Type>& OutResults)
{
	// Iterate over each record found as a result of the command, parsing it for relevant information
	for (int32 Index = 0; Index < InRecords.Num(); ++Index)
	{
		const FP4Record& ClientRecord = InRecords[Index];
		FString FileName = ClientRecord(TEXT("clientFile"));
		FString Action = ClientRecord(TEXT("action"));

		check(FileName.Len());
		FString FullPath(FileName);
		FPaths::NormalizeFilename(FullPath);

		if(Action.Len() > 0)
		{
			if(Action == TEXT("add"))
			{
				OutResults.Add(FullPath, EPerforceState::OpenForAdd);
			}
			else if(Action == TEXT("edit"))
			{
				OutResults.Add(FullPath, EPerforceState::CheckedOut);
			}
			else if(Action == TEXT("delete"))
			{
				OutResults.Add(FullPath, EPerforceState::MarkedForDelete);
			}
			else if(Action == TEXT("abandoned"))
			{
				OutResults.Add(FullPath, EPerforceState::NotInDepot);
			}
			else if(Action == TEXT("reverted"))
			{
				FString OldAction = ClientRecord(TEXT("oldAction"));
				if(OldAction == TEXT("add"))
				{
					OutResults.Add(FullPath, EPerforceState::NotInDepot);
				}
				else if(OldAction == TEXT("edit"))
				{
					OutResults.Add(FullPath, EPerforceState::ReadOnly);
				}
				else if(OldAction == TEXT("delete"))
				{
					OutResults.Add(FullPath, EPerforceState::ReadOnly);
				}
			}
			else if(Action == TEXT("branch"))
			{
				OutResults.Add(FullPath, EPerforceState::Branched);
			}
		}
	}
}
コード例 #8
0
ファイル: debug.cpp プロジェクト: AMDmi3/symwars3
void LastNum(const char* l)
{
	return;

#if 1
	char fullpath[MAX_PATH+1];
	FullPath("last.txt", fullpath);
	std::ofstream last;
	last.open(fullpath, std::ios_base::out);
	last<<l;
	last.flush();
#else
	g_log<<l<<std::endl;
	g_log.flush();
#endif
}
コード例 #9
0
ファイル: dialogs.c プロジェクト: jmzaleski/ivtools-1.2
FileDialog::FileDialog (
    const char* msg, const char* dir, const char* confirmLbl
) {
    int space = Math::round(fspace*ivcm);
    _browser = new FileBrowser(state, dir, 20, 35, false, Reversed,"\000\007");
    _dirs = new FileBrowser(
        "dirBrowser", state, dir, 20, 24, true, Reversed,"d\007"
    );
    _dirs->SetTextFilter("^$");                 // show directories only
    _dirs->Update();

    _cur_dir = new MarginFrame(new Message("path", FullPath(_dirs)));
    HBox* dirBox = new HBox(
        new Message("Directory: "),
        _cur_dir,
        new HGlue
    );
    dirBox->Propagate(false);

    Insert(
        new MarginFrame(
            new VBox(
                new HBox(
                    new VBox(
                        new Message("Change directory to:", Left, 0, hfil),
                        new Frame(AddScroller(_dirs))
                    ),
                    new HGlue(space, 0),
                    new VBox(
                        new Message(msg, Left, 0, hfil),
                        new Frame(AddScroller(_browser))
                    )
                ),
                new VGlue(space, 0),
                dirBox,
                new VGlue(space, 0),
                new HBox(
                    new HGlue,
                    new PushButton(" Cancel ", state, '\007'),
                    new HGlue(space, 0),
                    new PushButton(confirmLbl, state, '\r')
                )
            ), space, space, 0
        )
    );
}
コード例 #10
0
filePos CFileUtil::Size(char* szFileName)
{
    struct stat         sBuffer;
    int                 iStatus;
    char                sz[MAX_PATH];

    if (FullPath(sz, szFileName, MAX_PATH))
    {
        iStatus = stat(sz, &sBuffer);
        if (iStatus == -1)
        {
            return -1;
        }
        return sBuffer.st_size;
    }
    return -1;
}
コード例 #11
0
ファイル: keymagic-driver.cpp プロジェクト: HughP/keymagic
bool
keymagic_driver::SetIcon(const std::string& path)
{
	char cwd[256],
	base_path[256];
	bool retVal = false;
	
	GetCurrentDir(cwd);
	FullPath(file.c_str(), base_path);
	for (int i = strlen(base_path); i > 0 &&
		 !(base_path[i] == '/' || base_path[i] == '\\'); --i) {
		base_path[i] = '\0';
	}
	SetCurrentDir(base_path);
	
	FILE * f = fopen(path.c_str(), "rb");
	
	SetCurrentDir(cwd);

	if (f  == 0) {
		std::cerr << "Error: Cannot open icon file '" << path.c_str() << "'" << std::endl;
		exit(1);
	}
	
	fseek(f, 0, SEEK_END);
	long s = ftell(f);
	fseek(f, 0, SEEK_SET);
	
	char * data = new char[s+1];
	
	int read = fread(data, 1, s, f);
	if (read == s) {
		AddInfo('icon', data, s);
		retVal = true;
	}

	
	fclose(f);
	delete[] data;	
	
	return retVal;
}
コード例 #12
0
ファイル: keymagic-driver.cpp プロジェクト: HughP/keymagic
bool
keymagic_driver::openIncludeFile(const std::string& from, const std::string& incFile, std::string * realPath)
{
	bool fRet;
	char cwd[256],
		base_path[256];

	GetCurrentDir(cwd);
	FullPath(from.c_str(), base_path);

	for (int i = strlen(base_path); i > 0 &&
		!(base_path[i] == '/' || base_path[i] == '\\'); --i) {
		base_path[i] = '\0';
	}
	*realPath = base_path + incFile;

	SetCurrentDir(base_path);
	fRet = openFile(incFile);
	SetCurrentDir(cwd);

	return fRet;
}
static void ParseSyncResults(const FP4RecordSet& InRecords, TMap<FString, EPerforceState::Type>& OutResults)
{
	// Iterate over each record found as a result of the command, parsing it for relevant information
	for (int32 Index = 0; Index < InRecords.Num(); ++Index)
	{
		const FP4Record& ClientRecord = InRecords[Index];
		FString FileName = ClientRecord(TEXT("clientFile"));
		FString Action = ClientRecord(TEXT("action"));

		check(FileName.Len());
		FString FullPath(FileName);
		FPaths::NormalizeFilename(FullPath);

		if(Action.Len() > 0)
		{
			if(Action == TEXT("updated"))
			{
				OutResults.Add(FullPath, EPerforceState::ReadOnly);
			}
		}
	}
}
コード例 #14
0
ファイル: main.cpp プロジェクト: pombreda/main
	Path* parsePath(PCWSTR path)
	{
		auto_array < WCHAR > extendedPath(MAX_PATH_LEN);
		Copy(extendedPath, PATH_PREFIX_NT, extendedPath.size());
		Cat(extendedPath, FullPath(path).c_str(), extendedPath.size());
		::GetLongPathName(extendedPath, extendedPath, extendedPath.size());
		PWSTR tmp = (PWSTR)find_last_not_of((PCWSTR)extendedPath, L"\\ ");
		if (tmp && (tmp - extendedPath) < (ssize_t)extendedPath.size()) {
			tmp[1] = STR_END;		//erase tailing path separators
		}

		Path* Result = nullptr;
		if (Empty(extendedPath) || !is_exists(extendedPath)) {
			logError(L"Path \"%s\" is not existing or accessible!\n", extendedPath.data());
		} else {
			{
				ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
				logInfo(L"Adding directory: ");
			}
			logInfo(L"\"%s\"\n", path);
			Result = new Path(shared_ptr<Path>(), AutoUTF(extendedPath));
		}
		return Result;
	}
コード例 #15
0
ファイル: dialogs.c プロジェクト: jmzaleski/ivtools-1.2
boolean FileDialog::Accept () {
    Event e;
    int v = 0;

    state->SetValue(0);

    do {
        Read(e);
        if (e.target == nil) {
            break;
        }
        if (!KeyEquiv(e)) {
            Forward(e);
        }
        state->GetValue(v);

        if (v == 'd') {
            if (_dirs->Selections() > 0) {
                int sel = _dirs->Selection();
                char path[MAX_PATH_LENGTH];
                strcpy(path, _dirs->Path(sel));

                _browser->SetDirectory(path);
                _dirs->SetDirectory(path);

                Message* path_msg = new Message("path", FullPath(_dirs));
                _cur_dir->Insert(path_msg);
                _cur_dir->Change(path_msg);
            }
            state->SetValue(0);
            v = 0;
        }
    } while (v == 0);

    return v == '\r';
}
コード例 #16
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
bool CVProjectUtil::SetPath(
	std::string path )
{
	Clear();

	m_rawPath = path;

	path = FullPath( path );

	m_fullPath = path;

	try {
		// Change the path separator to ensure that they are all /'s
		boost::replace_all( path, "\\", "/" );

		boost::smatch match;
		if ( boost::regex_match( path, match,
			boost::regex(
//				 1       2         3       4                                               5          6              7
				"(.*)/(?:(content)|(game))/([^/]+)(?:(?:/(?:(?(2)materialsrc|materials)(?:/(models))?|(models)))?(?:/(.*))?)?/*",
				boost::regex::icase ) ) )
		{
			// Matches one of the known path configurations

			m_prefix.assign( match[ 1 ].first, match[ 1 ].second );
			m_game.assign( match[ 4 ].first, match[ 4 ].second );

			if ( match.length( 5 ) )
			{
				m_subType.assign( match[ 5 ].first, match[ 5 ].second );
			}
			else if ( match.length( 6 ) )
			{
				m_subType.assign( match[ 6 ].first, match[ 6 ].second );
			}

			const std::string tmpPath( match[ 7 ].first, match[ 7 ].second );
			if ( boost::regex_match( tmpPath, match, boost::regex( "/?(.*)/([^/\\.]+)\\.[^/\\.]*" ) ) )
			{
				m_path.assign( match[ 1 ].first, match[ 1 ].second );
				m_file.assign( match[ 2 ].first, match[ 2 ].second );
			}
			else if ( boost::regex_match( tmpPath, match, boost::regex( "([^/\\.]+)\\.[^/\\.]*" ) ) )
			{
				m_file.assign( match[ 1 ].first, match[ 1 ].second );
			}
			else
			{
				// TODO: Perhaps check to see if it really is a directory? (But might be chicken/egg thing)
				//       or maybe the right thing to do isn't to add an implict file named the same as the directory
				//       but in general, having raw files in game or content is not generally advisable
				m_path = tmpPath;
				m_file = tmpPath;
			}
		}
		else
		{
			// Didn't match a known path configuration... default to the lame approach which is just the
			// basename and the filename

			if ( boost::regex_match( path, match, boost::regex( "(.*)/([^/\\.]+)\\.[^/\\.]*" ) ) )
			{
				m_prefix.assign( match[ 1 ].first, match[ 1 ].second );
				m_file.assign( match[ 2 ].first, match[ 2 ].second );
			}
			else
			{
				// This should never happen due to the _fullpath call
				m_file = boost::regex_replace( path, boost::regex( ".[^\\.]*$" ), "" );
			}
		}
	}
	catch ( const std::exception &e )
	{
		merr << "Error: " << e.what() << std::endl;
		return false;
	}

	return true;
}
コード例 #17
0
void FProvider::PrepareFilenamesForAddCommand(
	const TArray<FString>& InFiles,
	TArray<FString>& OutAbsoluteFiles, TArray<FString>& OutAbsoluteLargeFiles
)
{
	if (Settings.IsLargefilesIntegrationEnabled())
	{
		FARFilter LargeAssetFilter;
		LargeAssetFilter.bRecursiveClasses = true;

		// convert filenames to long package names that can be used in the asset filter
		for (const auto& Filename : InFiles)
		{
			// currently only .uasset files can be auto-flagged as large
			if (!Filename.EndsWith(FPackageName::GetAssetPackageExtension()))
			{
				continue;
			}

			FString PackageName;
			if (!FPackageName::TryConvertFilenameToLongPackageName(Filename, PackageName))
			{
				UE_LOG(
					LogSourceControl, Error,
					TEXT("Failed to convert filename '%s' to package name"), *Filename
				);
				continue;
			}

			LargeAssetFilter.PackageNames.Add(*PackageName);
		}

		// add the asset types that the user has designated as "large" to the asset filter
		TArray<FString> LargeAssetTypes;
		Settings.GetLargeAssetTypes(LargeAssetTypes);
		for (const auto& ClassName : LargeAssetTypes)
		{
			LargeAssetFilter.ClassNames.Add(*ClassName);
		}

		FAssetRegistryModule& AssetRegistryModule = 
			FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));

		// find all the assets matching the asset filter
		TArray<FAssetData> LargeAssets;
		AssetRegistryModule.Get().GetAssets(LargeAssetFilter, LargeAssets);

		// convert the long package names of all matching assets back to filenames
		for (const auto& Asset : LargeAssets)
		{
			FString RelativePath = FPackageName::LongPackageNameToFilename(
				Asset.PackageName.ToString(), FPackageName::GetAssetPackageExtension()
			);
			OutAbsoluteLargeFiles.Add(
				FPaths::ConvertRelativePathToFull(RelativePath)
			);
		}

		// any input file that didn't match the asset filter will be added with no special flags
		for (const auto& Filename : InFiles)
		{
			FString FullPath(FPaths::ConvertRelativePathToFull(Filename));
			if (!OutAbsoluteLargeFiles.Contains(FullPath))
			{
				OutAbsoluteFiles.Add(FullPath);
			}
		}
	}
	else
	{
		for (const auto& Filename : InFiles)
		{
			OutAbsoluteFiles.Add(FPaths::ConvertRelativePathToFull(Filename));
		}
	}
}
コード例 #18
0
ファイル: dialogs.c プロジェクト: jmzaleski/ivtools-1.2
const char* FileDialog::FullPath (const char* relpath) {
    return FullPath(_dirs, relpath);
}
コード例 #19
0
ファイル: VDiskVmdk.cpp プロジェクト: deus-amd/vdk
//
//	Check VMDK sparse disk
//
VDKSTAT VDiskVmdk::Check()
{
	PVOID	cbparams[3];
	CHAR	path[MAX_PATH];
	ULONG	idx;
	VDKSTAT ret;

	FullPath(path);
	cbparams[0] = path;

	//
	//	At least one extent must be present
	//
	if (!m_nExtents) {
		VDiskCallBack(VDISK_CB_EMPTY_IMAGE, cbparams);
		return VDK_DATA;
	}

	//
	//	Sum up extent capacity
	//
	m_nCapacity = 0;

	for (idx = 0; idx < m_nExtents; idx++) {
		if ((ret = m_ppExtents[idx]->Check()) != VDK_OK) {
			return ret;
		}

		if (m_ppExtents[idx]->IsModified()) {
			SetFlag(VDISK_FLAG_DIRTY);
		}

		m_nCapacity += m_ppExtents[idx]->GetCapacity();
	}

	//
	//	Check total capacity
	//
	/*
	if (total_size != m_nCapacity) {

		cbparams[1] = (PVOID)m_nCapacity;
		cbparams[2] = (PVOID)total_size;

		if (!VDiskCallBack(VDISK_CB_EXT_CAPACITY, cbparams)) {
			return VDK_DATA;
		}

		m_nCapacity	= total_size;
		SetGeometry();

		SetFlag(VDISK_FLAG_DIRTY);

		for (idx = 0; idx < m_nExtents; idx++) {
			if (total_size < m_ppExtents[idx]->GetCapacity()) {
				m_ppExtents[idx]->SetCapacity(total_size);
				total_size = 0;
			}
			else {
				total_size -= m_ppExtents[idx]->GetCapacity();
			}
		}
	}
	*/

	//
	//	Any bad parameter?
	//
	if (m_nFlags & VDISK_FLAG_DIRTY) {

		if (VDiskCallBack(VDISK_CB_CONFIRM_FIX, cbparams)) {
			ret = WriteDescriptor(FALSE, FALSE);

			if (ret != VDK_OK) {
				return ret;
			}

			for (idx = 0; idx < m_nExtents; idx++) {
				ret = m_ppExtents[idx]->Update();

				if (ret != VDK_OK) {
					return ret;
				}
			}
		}
		ClrFlag(VDISK_FLAG_DIRTY);
	}

	return VDK_OK;
}
コード例 #20
0
BOOL CFileUtil::FindFiles(const char*szInDirectory, BOOL bDirs, const char*szInName, const char*szExtension, CArrayChars* paszFiles, BOOL bHidden)
{
	WIN32_FIND_DATA		sFindData;
	CChars				szFindName;
	CChars				szTemp;
	HANDLE				hFindHandle;
	BOOL				bContinue;
	int					iFileExtension;
	BOOL				bValid;
	CChars				szFake;
	CChars				szDirectory;

	szDirectory.Init(szInDirectory);
	FullPath(&szDirectory);
	szFindName.Init(szDirectory);
	AppendToPath(&szFindName, "*.*");

	hFindHandle = FindFirstFile(szFindName.Text(), &sFindData);
	bContinue = (hFindHandle != INVALID_HANDLE_VALUE);

	if (!bContinue)
	{
		szDirectory.Kill();
		szFindName.Kill();
		return FALSE;
	}

	while (bContinue)
	{
		if (!(sFindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || bHidden)
		{
			bValid = TRUE;
			if (sFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				if (bDirs)
				{
					if (szInName != NULL)
					{
						szTemp.Init(sFindData.cFileName);
						RemoveExtension(&szTemp);
						if (!szTemp.ContainsIgnoreCase(szInName))
						{
							bValid = FALSE;
						}
						szTemp.Kill();
					}
				}
				else
				{
					bValid = FALSE;
				}
			}
			else
			{
				if (!bDirs)
				{
					if (szExtension != NULL)
					{
						szFake.Fake(sFindData.cFileName);
						iFileExtension = FindExtension(szFake.Text());
						if (iFileExtension != -1)
						{
							if (!(szFake.SubStringEquals(iFileExtension+1, szExtension)))
							{
								bValid = FALSE;
							}
						}
						else
						{
							//If there is no file extension on the current file and the
							//extension being looked for is not empty...
							if (szExtension[0] != 0)
							{
								//Then this file is not valid.
								bValid = FALSE;
							}
						}
					}
					if (szInName != NULL)
					{
						szTemp.Init(sFindData.cFileName);
						RemoveExtension(&szTemp);
						if (!szTemp.ContainsIgnoreCase(szInName))
						{
							bValid = FALSE;
						}
						szTemp.Kill();
					}
				}
				else
				{
					bValid = FALSE;
				}
			}
		}
		else
		{
			bValid = FALSE;
		}

		if (bValid)
		{
			if (!((strcmp(sFindData.cFileName, ".") == 0) || (strcmp(sFindData.cFileName, "..") == 0)))
			{
				szTemp.Init(szDirectory);
				AppendToPath(&szTemp, sFindData.cFileName);
				paszFiles->Add(szTemp.Text());
				szTemp.Kill();
			}
		}

		bContinue = FindNextFile(hFindHandle, &sFindData);
	}
	FindClose(hFindHandle);

	szDirectory.Kill();
	szFindName.Kill();
	return TRUE;
}
static void ParseUpdateStatusResults(const FP4RecordSet& InRecords, const TArray<FText>& ErrorMessages, TArray<FPerforceSourceControlState>& OutStates)
{
	// Iterate over each record found as a result of the command, parsing it for relevant information
	for (int32 Index = 0; Index < InRecords.Num(); ++Index)
	{
		const FP4Record& ClientRecord = InRecords[Index];
		FString FileName = ClientRecord(TEXT("clientFile"));
		FString DepotFileName = ClientRecord(TEXT("depotFile"));
		FString HeadRev  = ClientRecord(TEXT("headRev"));
		FString HaveRev  = ClientRecord(TEXT("haveRev"));
		FString OtherOpen = ClientRecord(TEXT("otherOpen"));
		FString OpenType = ClientRecord(TEXT("type"));
		FString HeadAction = ClientRecord(TEXT("headAction"));
		FString Action = ClientRecord(TEXT("action"));
		FString HeadType = ClientRecord(TEXT("headType"));
		const bool bUnresolved = ClientRecord.Contains(TEXT("unresolved"));

		FString FullPath(FileName);
		FPaths::NormalizeFilename(FullPath);
		OutStates.Add(FPerforceSourceControlState(FullPath));
		FPerforceSourceControlState& State = OutStates.Last();
		State.DepotFilename = DepotFileName;

		State.State = EPerforceState::ReadOnly;
		if (Action.Len() > 0 && Action == TEXT("add")) 
		{
			State.State = EPerforceState::OpenForAdd;
		}
		else if (Action.Len() > 0 && Action == TEXT("delete")) 
		{
			State.State = EPerforceState::MarkedForDelete;
		}
		else if (OpenType.Len() > 0)
		{
			if(Action.Len() > 0 && Action == TEXT("branch")) 
			{
				State.State = EPerforceState::Branched;
			}
			else
			{
				State.State = EPerforceState::CheckedOut;
			}
		}
		else if (OtherOpen.Len() > 0)
		{
			// OtherOpen just reports the number of developers that have a file open, now add a string for every entry
			int32 OtherOpenNum = FCString::Atoi(*OtherOpen);
			for ( int32 OpenIdx = 0; OpenIdx < OtherOpenNum; ++OpenIdx )
			{
				const FString OtherOpenRecordKey = FString::Printf(TEXT("otherOpen%d"), OpenIdx);
				const FString OtherOpenRecordValue = ClientRecord(OtherOpenRecordKey);

				State.OtherUserCheckedOut += OtherOpenRecordValue;
				if(OpenIdx < OtherOpenNum - 1)
				{
					State.OtherUserCheckedOut += TEXT(", ");
				}
			}

			State.State = EPerforceState::CheckedOutOther;
		}
		//file has been previously deleted, ok to add again
		else if (HeadAction.Len() > 0 && HeadAction == TEXT("delete")) 
		{
			State.State = EPerforceState::NotInDepot;
		}
		
		if (HeadRev.Len() > 0 && HaveRev.Len() > 0)
		{
			TTypeFromString<int>::FromString(State.DepotRevNumber, *HeadRev);
			TTypeFromString<int>::FromString(State.LocalRevNumber, *HaveRev);
			if( bUnresolved )
			{
				int32 ResolveActionNumber = 0;
				for (;;)
				{
					// Extract the revision number
					FString VarName = FString::Printf(TEXT("resolveAction%d"), ResolveActionNumber);
					if (!ClientRecord.Contains(*VarName))
					{
						// No more revisions
						ensureMsgf( ResolveActionNumber > 0, TEXT("Resolve is pending but no resolve actions for file %s"), *FileName );
						break;
					}

					VarName = FString::Printf(TEXT("resolveBaseFile%d"), ResolveActionNumber);
					FString ResolveBaseFile = ClientRecord(VarName);
					VarName = FString::Printf(TEXT("resolveFromFile%d"), ResolveActionNumber);
					FString ResolveFromFile = ClientRecord(VarName);
					if(!ensureMsgf( ResolveFromFile == ResolveBaseFile, TEXT("Text cannot resolve %s with %s, we do not support cross file merging"), *ResolveBaseFile, *ResolveFromFile ) )
					{
						break;
					}

					VarName = FString::Printf(TEXT("resolveBaseRev%d"), ResolveActionNumber);
					FString ResolveBaseRev = ClientRecord(VarName);

					TTypeFromString<int>::FromString(State.PendingResolveRevNumber, *ResolveBaseRev);
					
					++ResolveActionNumber;
				}
			}
		}

		// Check binary status
		State.bBinary = false;
		if (HeadType.Len() > 0 && HeadType.Contains(TEXT("binary")))
		{
			State.bBinary = true;
		}

		// Check exclusive checkout flag
		State.bExclusiveCheckout = false;
		if (HeadType.Len() > 0 && HeadType.Contains(TEXT("+l")))
		{
			State.bExclusiveCheckout = true;
		}
	}

	// also see if we can glean anything from the error messages
	for (int32 Index = 0; Index < ErrorMessages.Num(); ++Index)
	{
		const FText& Error = ErrorMessages[Index];

		//@todo P4 could be returning localized error messages
		int32 NoSuchFilePos = Error.ToString().Find(TEXT(" - no such file(s).\n"), ESearchCase::IgnoreCase, ESearchDir::FromStart);
		if(NoSuchFilePos != INDEX_NONE)
		{
			// found an error about a file that is not in the depot
			FString FullPath(Error.ToString().Left(NoSuchFilePos));
			FPaths::NormalizeFilename(FullPath);
			OutStates.Add(FPerforceSourceControlState(FullPath));
			FPerforceSourceControlState& State = OutStates.Last();
			State.State = EPerforceState::NotInDepot;
		}

		//@todo P4 could be returning localized error messages
		int32 NotUnderClientRootPos = Error.ToString().Find(TEXT("' is not under client's root"), ESearchCase::IgnoreCase, ESearchDir::FromStart);
		if(NotUnderClientRootPos != INDEX_NONE)
		{
			// found an error about a file that is not under the client root
			static const FString Prefix(TEXT("Path \'"));
			FString FullPath(Error.ToString().Mid(Prefix.Len(), NotUnderClientRootPos - Prefix.Len()));
			FPaths::NormalizeFilename(FullPath);
			OutStates.Add(FPerforceSourceControlState(FullPath));
			FPerforceSourceControlState& State = OutStates.Last();
			State.State = EPerforceState::NotUnderClientRoot;	
		}
	}
}
コード例 #22
0
ファイル: MOVE.C プロジェクト: FDOS/move
static int extract_sources(int fileargc, char** fileargv)
{
    int i;
    char *sep;
    char tempname[MAXPATH];
    char argv[MAXPATH], *pargv;

    for (i= 0; i < fileargc; i++)
    {
	strmcpy(argv, fileargv[i], MAXPATH);

        /* Strip leading and ending ','s */
	pargv = strchr(argv, 0)	- 1;
	while (*pargv && (*pargv == ',')) pargv--;
	*(pargv+1) = 0;
	pargv = argv;
	while (*pargv && (*pargv == ',')) pargv++;
	if (!*pargv) continue;

	sep = strchr(pargv, ',');
	while (sep)
	{
	    if (sep-pargv < MAXPATH)
	    {
		memcpy(tempname, pargv, sep-pargv);
		tempname[sep-pargv] = '\0';
		if (!FullPath(SourcePaths[AmofSources++], tempname))
		{
#ifdef USE_KITTEN
		    error(1,9,"Invalid source file");
		    kittenclose();
#else
		    error("Invalid source file");
#endif
		    exit(1);
		}
	    }
	    else
		return 0;

	    sep = strchr(pargv = (sep + 1), ',');
	}

	if (strlen(pargv) < MAXPATH)
	{
	    if (!FullPath(SourcePaths[AmofSources++], pargv))
	    {
#ifdef USE_KITTEN
		error(1,9,"Invalid source file");
#else
		error("Invalid source file");
#endif
		return 0;
	    }
	}
	else
	    return 0;
    }

    return 1;
}
コード例 #23
0
BOOL CheckDBExists(CString csDBPath)
{
	//If this is the first time running this version then convert the old database to the new db
	if(csDBPath.IsEmpty() && g_Opt.m_bU3 == false)
	{
		csDBPath = GetDefaultDBName();

		if(FileExists(csDBPath) == FALSE && CGetSetOptions::GetIsPortableDitto() == FALSE)
		{
			CString csOldDB = CGetSetOptions::GetDBPathOld();
			if(csOldDB.IsEmpty())
			{
				csOldDB = GetOLDDefaultDBName();
			}

			if(FileExists(csOldDB))
			{
				//create the new sqlite db
				CreateDB(csDBPath);

				CAccessToSqlite Convert;
				Convert.ConvertDatabase(csDBPath, csOldDB);
			}
		}
	}

	BOOL bRet = FALSE;
	if(FileExists(csDBPath) == FALSE)
	{
		csDBPath = GetDefaultDBName();

		nsPath::CPath FullPath(csDBPath);
		CString csPath = FullPath.GetPath().GetStr();
		if(csPath.IsEmpty() == false && FileExists(csDBPath) == FALSE)
		{
			CreateDirectory(csPath, NULL);
		}

		// -- create a new one
		bRet = CreateDB(csDBPath);
	}
	else
	{
		if(ValidDB(csDBPath) == FALSE)
		{		
			//Db existed but was bad
			CString csMarkAsBad;
			
			csMarkAsBad = csDBPath;
			csMarkAsBad.Replace(_T("."), _T("_BAD."));
			
			CString csPath = GetDefaultDBName();
			
			CString cs;
			cs.Format(_T("%s \"%s\",\n")
				_T("%s \"%s\",\n")
				_T("%s,\n")
				_T("\"%s\""),
				theApp.m_Language.GetString("Database_Format", "Unrecognized Database Format"),
				csDBPath, 
				theApp.m_Language.GetString("File_Renamed", "the file will be renamed"),
				csMarkAsBad, 
				theApp.m_Language.GetString("New_Database", "and a new database will be created"),
				csPath);
			
			AfxMessageBox(cs);
			
			CFile::Rename(csDBPath, csMarkAsBad);

			csDBPath = csPath;
			
			bRet = CreateDB(csDBPath);
		}
		else
		{
			bRet = TRUE;
		}
	}

	if(bRet)
	{
		bRet = OpenDatabase(csDBPath);
	}
	
	return bRet;
}
コード例 #24
0
ファイル: unitmove.cpp プロジェクト: AMDmi3/symwars3
void MoveUnit(Unit* u)
{
	UnitT* t = &g_utype[u->type];
	u->prevpos = u->cmpos;
	u->collided = false;

	if(u->threadwait)
		return;

	if(Magnitude(u->goal - u->cmpos) <= t->cmspeed)
		return;

	if(u->underorder && u->target < 0 && Magnitude(u->goal - u->cmpos) <= PATHNODE_SIZE)
		return;

	if(u->path.size() <= 0 || *u->path.rbegin() != u->goal)
	{
#if 1
		if(t->military)
		{
			if(g_simframe - u->lastpath < u->pathdelay)
			{
				return;
			}

			//u->pathdelay += 1;
			//u->pathdelay *= 2;
			u->pathdelay += 10;
			u->lastpath = g_simframe;

			int nodesdist = Magnitude( u->goal - u->cmpos ) / PATHNODE_SIZE;
#if 1
			PartialPath(u->type, u->mode,
						u->cmpos.x, u->cmpos.y, u->target, u->target2, u->targtype, &u->path, &u->subgoal,
						u, NULL, NULL,
						u->goal.x, u->goal.y,
						u->goal.x, u->goal.y, u->goal.x, u->goal.y,
						nodesdist*10);
			//TILE_SIZE*4/PATHNODE_SIZE);
#else
			JPSPartPath(u->type, u->mode,
						u->cmpos.x, u->cmpos.y, u->target, u->target2, u->targtype, &u->path, &u->subgoal,
						u, NULL, NULL,
						u->goal.x, u->goal.y,
						u->goal.x, u->goal.y, u->goal.x, u->goal.y,
						nodesdist*4);
#endif

#if 0
			RichText rtext("ppathf");
			NewTransx(u->drawpos + Vec3f(0,t->size.y,0), &rtext);
#endif
		}
		else if(!u->pathblocked)
#endif
		{
#if 0
			if(!FullPath(0,
						 u->type, u->mode,
						 u->cmpos.x, u->cmpos.y, u->target, u->target, u->target2, u->path, u->subgoal,
						 u, NULL, NULL,
						 u->goal.x, u->goal.y,
						 u->goal.x, u->goal.y, u->goal.x, u->goal.y))
#endif

				JPSPath(
					u->type, u->mode,
					u->cmpos.x, u->cmpos.y, u->target, u->target2, u->targtype, &u->path, &u->subgoal,
					u, NULL, NULL,
					u->goal.x, u->goal.y,
					u->goal.x, u->goal.y, u->goal.x, u->goal.y);
		}

		return;
	}

	u->freecollider();

	Vec2i dir = u->subgoal - u->cmpos;

	if(Magnitude2(u->subgoal - u->cmpos) <= t->cmspeed * t->cmspeed)
	{
		u->cmpos = u->subgoal;

		if(u->path.size() >= 2)
		{
			u->path.erase( u->path.begin() );
			u->subgoal = *u->path.begin();
			dir = u->subgoal - u->cmpos;
		}
#if 0
		else
		{
			u->fillcollider();
			u->drawpos.x = u->cmpos.x;
			u->drawpos.z = u->cmpos.y;
			u->drawpos.y = g_hmap.accheight(u->drawpos.x, u->drawpos.z);
			u->rotation.y = GetYaw(dir.x, dir.y);
			return;
		}
#endif
	}

	if(dir.x != 0 || dir.y != 0)
	{
		u->rotation.y = GetYaw(dir.x, dir.y);

		int mag = Magnitude(dir);
#if 0
		if(mag <= 0)
			mag = 1;
#endif

		Vec2i scaleddir = dir * t->cmspeed / mag;
		u->cmpos = u->cmpos + scaleddir;

#if 1
		if(UnitCollides(u, u->cmpos, u->type))
#else
		if(Trace(u->type, u->mode, u->prevpos, u->cmpos, u, NULL, NULL) != COLLIDER_NONE)
#endif
		{
			u->collided = true;
			u->cmpos = u->prevpos;
			u->path.clear();
			u->subgoal = u->cmpos;
			u->fillcollider();
			return;
		}
#if 0
		u->collided = false;
#endif
	}

	if(UnitCollides(u, u->cmpos, u->type))
		u->collided = true;

	u->fillcollider();
	u->drawpos.x = u->cmpos.x;
	u->drawpos.z = u->cmpos.y;
	u->drawpos.y = g_hmap.accheight(u->cmpos.x, u->cmpos.y);
}