コード例 #1
0
/**
 * Returns a pointer to the duplicate of a given object, creating the duplicate object if necessary.
 *
 * @param	Object	the object to find a duplicate for
 *
 * @return	a pointer to the duplicate of the specified object
 */
UObject* FDuplicateDataWriter::GetDuplicatedObject(UObject* Object, bool bCreateIfMissing)
{
	UObject* Result = NULL;
	if (IsValid(Object))
	{
		// Check for an existing duplicate of the object.
		FDuplicatedObject DupObjectInfo = DuplicatedObjectAnnotation.GetAnnotation( Object );
		if( !DupObjectInfo.IsDefault() )
		{
			Result = DupObjectInfo.DuplicatedObject;
		}
		else if (bCreateIfMissing)
		{
			// Check to see if the object's outer is being duplicated.
			UObject* DupOuter = GetDuplicatedObject(Object->GetOuter());
			if(DupOuter != NULL)
			{
				// The object's outer is being duplicated, create a duplicate of this object.
				UObject* NewEmptyDuplicate = StaticConstructObject_Internal(Object->GetClass(), DupOuter, Object->GetFName(), 
					ApplyFlags | Object->GetMaskedFlags(FlagMask),
					ApplyInternalFlags | (Object->GetInternalFlags() & InternalFlagMask),
					Object->GetArchetype(), true, InstanceGraph);

				Result = AddDuplicate(Object, NewEmptyDuplicate);
			}
		}
	}

	return Result;
}
コード例 #2
0
/**
 * Constructor
 *
 * @param	InDuplicatedObjects		will contain the original object -> copy mappings
 * @param	InObjectData			will store the serialized data
 * @param	SourceObject			the object to copy
 * @param	DestObject				the object to copy to
 * @param	InFlagMask				the flags that should be copied when the object is duplicated
 * @param	InApplyFlags			the flags that should always be set on the duplicated objects (regardless of whether they're set on the source)
 * @param	InInstanceGraph			the instancing graph to use when creating the duplicate objects.
 */
FDuplicateDataWriter::FDuplicateDataWriter( FUObjectAnnotationSparse<FDuplicatedObject,false>& InDuplicatedObjects ,TArray<uint8>& InObjectData,UObject* SourceObject,
	UObject* DestObject, EObjectFlags InFlagMask, EObjectFlags InApplyFlags, EInternalObjectFlags InInternalFlagMask, EInternalObjectFlags InApplyInternalFlags, FObjectInstancingGraph* InInstanceGraph, uint32 InPortFlags)
: DuplicatedObjectAnnotation(InDuplicatedObjects)
, ObjectData(InObjectData)
, Offset(0)
, FlagMask(InFlagMask)
, ApplyFlags(InApplyFlags)
, InternalFlagMask(InInternalFlagMask)
, ApplyInternalFlags(InApplyInternalFlags)
, InstanceGraph(InInstanceGraph)
{
	ArIsSaving			= true;
	ArIsPersistent		= true;
	ArAllowLazyLoading	= false;
	ArPortFlags |= PPF_Duplicate | InPortFlags;

	AddDuplicate(SourceObject,DestObject);
}
コード例 #3
0
void AddFileToRecord(char *path, char *name, unsigned char tabCount){
	Node *p = tree;
	Node *prev = NULL;
	int res, existsCurrentFile, existsCheckFile;
	struct stat currentFile;
	struct stat checkFile;
	char *fullCurrentFilePath = malloc(256);
	char *fullCheckFilePath = malloc(256);
	PrintTabs(tabCount);

	if(tree->path == NULL){
		p->path = malloc(strlen(path));
		p->name = malloc(strlen(name));
		strcpy(p->path, path);
		strcpy(p->name, name);
		printf("Pievienoja '%s/%s'\n", p->path, p->name);
	}
	else {
		while(p != NULL){
			res = strcmp(name, p->name);
			prev = p;

			if(res < 0)
				p = p->left;
			else if(res > 0)
				p = p->right;
			else{
				strcpy(fullCurrentFilePath, path);
				strcat(fullCurrentFilePath, "/");
				strcat(fullCurrentFilePath, name);
				existsCurrentFile = stat(fullCurrentFilePath, &currentFile);
				strcpy(fullCheckFilePath, p->path);
				strcat(fullCheckFilePath, "/");
				strcat(fullCheckFilePath, p->name);
				printf("Path: '%s'\n", fullCheckFilePath);
				existsCheckFile = stat(fullCheckFilePath, &checkFile);
				if(existsCheckFile < 0 || existsCurrentFile < 0){
					perror("Problema ar faila atversanu: ");
					return;
				}
				else {
					if(currentFile.st_size == checkFile.st_size){
						AddDuplicate(path, name);
						return;
					}
					else{
						printf("Dazadz izmers!\n");
						p = p->right;
					}
				}

			}
		}
		p = malloc(sizeof(Node));
		p->left = NULL;
		p->path = malloc(strlen(path));
		strcpy(p->path, path);
		p->name = malloc(strlen(name));
		strcpy(p->name, name);
		p->right = NULL;

		if(res < 0)
			prev->left = p;
		else
			prev->right = p;

		printf("Pievienoja '%s/%s'\n", p->path, p->name);
	}
}