本文整理汇总了C++中FSourceControlStatePtr::CanAdd方法的典型用法代码示例。如果您正苦于以下问题:C++ FSourceControlStatePtr::CanAdd方法的具体用法?C++ FSourceControlStatePtr::CanAdd怎么用?C++ FSourceControlStatePtr::CanAdd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSourceControlStatePtr
的用法示例。
在下文中一共展示了FSourceControlStatePtr::CanAdd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitWithConfigAndProperty
void UPropertyConfigFileDisplayRow::InitWithConfigAndProperty(const FString& InConfigFileName, UProperty* InEditProperty)
{
ConfigFileName = FPaths::ConvertRelativePathToFull(InConfigFileName);
ExternalProperty = InEditProperty;
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
// We will add source control soon...
FSourceControlStatePtr SourceControlState = nullptr; // SourceControlProvider.GetState(ConfigFileName, EStateCacheUsage::Use);
// Only include config files that are currently checked out or packages not under source control
{
if (FPaths::FileExists(ConfigFileName))
{
if (SourceControlState.IsValid())
{
bIsFileWritable = SourceControlState->IsCheckedOut() || SourceControlState->IsAdded();
}
else
{
bIsFileWritable = !IFileManager::Get().IsReadOnly(*ConfigFileName);
}
}
else
{
if (SourceControlState.IsValid())
{
bIsFileWritable = (SourceControlState->IsSourceControlled() && SourceControlState->CanAdd());
}
else
{
bIsFileWritable = false;
}
}
}
}
示例2: CheckOutFile
bool FGatherTextSCC::CheckOutFile(const FString& InFile, FText& OutError)
{
if ( InFile.IsEmpty() || InFile.StartsWith(TEXT("\\\\")) )
{
OutError = NSLOCTEXT("GatherTextCmdlet", "InvalidFileSpecified", "Could not checkout file at invalid path.");
return false;
}
FText SCCError;
if( !IsReady( SCCError ) )
{
OutError = SCCError;
return false;
}
FString AbsoluteFilename = FPaths::ConvertRelativePathToFull( InFile );
if( CheckedOutFiles.Contains( AbsoluteFilename ) )
{
return true;
}
bool bSuccessfullyCheckedOut = false;
TArray<FString> FilesToBeCheckedOut;
FilesToBeCheckedOut.Add( AbsoluteFilename );
FFormatNamedArguments Args;
Args.Add(TEXT("Filepath"), FText::FromString(InFile));
ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState( AbsoluteFilename, EStateCacheUsage::ForceUpdate );
if(SourceControlState.IsValid())
{
FString Other;
if( SourceControlState->IsAdded() ||
SourceControlState->IsCheckedOut())
{
// Already checked out or opened for add
bSuccessfullyCheckedOut = true;
}
else if(SourceControlState->CanCheckout())
{
bSuccessfullyCheckedOut = (SourceControlProvider.Execute( ISourceControlOperation::Create<FCheckOut>(), FilesToBeCheckedOut ) == ECommandResult::Succeeded);
if (!bSuccessfullyCheckedOut)
{
OutError = FText::Format(NSLOCTEXT("GatherTextCmdlet", "FailedToCheckOutFile", "Failed to check out file '{Filepath}'."), Args);
}
}
else if(!SourceControlState->IsSourceControlled() && SourceControlState->CanAdd())
{
bSuccessfullyCheckedOut = (SourceControlProvider.Execute( ISourceControlOperation::Create<FMarkForAdd>(), FilesToBeCheckedOut ) == ECommandResult::Succeeded);
if (!bSuccessfullyCheckedOut)
{
OutError = FText::Format(NSLOCTEXT("GatherTextCmdlet", "FailedToAddFileToSourceControl", "Failed to add file '{Filepath}' to source control."), Args);
}
}
else if(!SourceControlState->IsCurrent())
{
OutError = FText::Format(NSLOCTEXT("GatherTextCmdlet", "FileIsNotAtHeadRevision", "File '{Filepath}' is not at head revision."), Args);
}
else if(SourceControlState->IsCheckedOutOther(&(Other)))
{
Args.Add(TEXT("Username"), FText::FromString(Other));
OutError = FText::Format(NSLOCTEXT("GatherTextCmdlet", "FileIsAlreadyCheckedOutByAnotherUser", "File '{Filepath}' is checked out by another ('{Username}')."), Args);
}
else
{
// Improper or invalid SCC state
OutError = FText::Format(NSLOCTEXT("GatherTextCmdlet", "CouldNotGetStateOfFile", "Could not determine source control state of file '{Filepath}'."), Args);
}
}
else
{
// Improper or invalid SCC state
OutError = FText::Format(NSLOCTEXT("GatherTextCmdlet", "CouldNotGetStateOfFile", "Could not determine source control state of file '{Filepath}'."), Args);
}
if( bSuccessfullyCheckedOut )
{
CheckedOutFiles.AddUnique(AbsoluteFilename);
}
return bSuccessfullyCheckedOut;
}