Ejemplo n.º 1
0
void FCollectionManager::LoadCollections()
{
	const double LoadStartTime = FPlatformTime::Seconds();
	int32 NumCollectionsLoaded = 0;

	for (int32 CacheIdx = 0; CacheIdx < ECollectionShareType::CST_All; ++CacheIdx)
	{
		const FString& CollectionFolder = CollectionFolders[CacheIdx];
		const FString WildCard = FString::Printf(TEXT("%s/*.%s"), *CollectionFolder, *CollectionExtension);

		TArray<FString> Filenames;
		IFileManager::Get().FindFiles(Filenames, *WildCard, true, false);

		for (int32 FileIdx = 0; FileIdx < Filenames.Num(); ++FileIdx)
		{
			const FString Filename = CollectionFolder / Filenames[FileIdx];

			FCollection Collection;
			const bool bUseSCC = ShouldUseSCC(ECollectionShareType::Type(CacheIdx));
			if ( Collection.LoadFromFile(Filename, bUseSCC) )
			{
				AddCollection(Collection, ECollectionShareType::Type(CacheIdx));
			}
			else
			{
				UE_LOG(LogCollectionManager, Warning, TEXT("Failed to load collection file %s"), *Filename);
			}
		}
		
		NumCollectionsLoaded += CachedCollections[CacheIdx].Num();
	}

	UE_LOG( LogCollectionManager, Log, TEXT( "Loaded %d collections in %0.6f seconds" ), NumCollectionsLoaded, FPlatformTime::Seconds() - LoadStartTime );
}
Ejemplo n.º 2
0
void CMsregPacketCatalogOrderLineItem::ReadDataFromFile(CFile& cfFile, DWORD& dwChecksum)
{
	CString csCollection;

	TRY
	{
		// Read the category name.
		m_csCategory = CMsregPacket::ReadString(cfFile, dwChecksum);

		// Read the quantity.
		m_dwQuantity = CMsregPacket::ReadDword(cfFile, dwChecksum);

		// Write the cost.
		m_dwCost = CMsregPacket::ReadDword(cfFile, dwChecksum);

		// Read the collection count.
		DWORD dwCollections = CMsregPacket::ReadDword(cfFile, dwChecksum);

		// Read Collections.
		DeleteAllCollections();
		for (DWORD i = 0; i < dwCollections; i++)
		{
			csCollection = CMsregPacket::ReadString(cfFile, dwChecksum);
			AddCollection(csCollection);
		}
	}
	CATCH_ALL(e)
	{
		csCollection.Empty();
		THROW_LAST();
	}
	END_CATCH_ALL
}
Ejemplo n.º 3
0
static void ScanPath (TRI_vocbase_t* vocbase, char const* path) {
  TRI_vector_string_t files;
  TRI_col_type_e type;
  size_t n;
  size_t i;

  files = TRI_FilesDirectory(path);
  n = files._length;

  for (i = 0;  i < n;  ++i) {
    char* name;
    char* file;

    name = files._buffer[i];

    if (name[0] == '\0' || name[0] == '_' || name[0] == '.') {
      continue;
    }

    file = TRI_Concatenate2File(path, name);
    if (!file) {
      continue;
    }

    if (TRI_IsDirectory(file)) {
      TRI_col_info_t info;
      bool ok;

      ok = TRI_LoadParameterInfo(file, &info);

      if (! ok) {
        LOG_DEBUG("ignoring directory '%s' without valid parameter file '%s'", file, TRI_COL_PARAMETER_FILE);
      }
      else {
        type = info._type;

        if (type == TRI_COL_TYPE_SIMPLE_DOCUMENT) {
          AddCollection(vocbase, type, info._name, info._cid, file);
          LOG_DEBUG("added simple document collection from '%s'", file);
        }
        else {
          LOG_DEBUG("skipping collection of unknown type %d", (int) type);
        }
      }
    }
    else {
      LOG_DEBUG("ignoring non-directory '%s'", file);
    }

    TRI_FreeString(file);
  }

  TRI_DestroyVectorString(&files);
}
Ejemplo n.º 4
0
void IPCCollectionEvent(int argc, char** argv, PLSOBJECT Object)
{
	char* Name = argv[0];
	LSTypeDefinition* Type = pLSInterface->FindLSType(argv[1]);
	char* SubType = argv[2];
	char* Method = argv[3];

	LSOBJECT collectionobject;
	if((collectionobject.Ptr = FindCollection(Name)) == 0)
	{
		collectionobject.Ptr = new LSObjectCollection(Type, SubType);
		AddCollection(Name, (LSObjectCollection*)collectionobject.Ptr);
	}
	pCollectionType->GetMethodEx(collectionobject.GetObjectData(), Method, argc - 4, &argv[4]);
}
Ejemplo n.º 5
0
bool FCollectionManager::CreateCollection(FName CollectionName, ECollectionShareType::Type ShareType)
{
	if ( !ensure(ShareType < ECollectionShareType::CST_All) )
	{
		// Bad share type
		LastError = LOCTEXT("Error_Internal", "There was an internal error.");
		return false;
	}

	// Try to add the collection
	bool bUseSCC = ShouldUseSCC(ShareType);
	FString SourceFolder = CollectionFolders[ShareType];

	FCollection NewCollection(CollectionName, SourceFolder, CollectionExtension, bUseSCC);
	FCollection* Collection = AddCollection(NewCollection, ShareType);

	if ( !Collection )
	{
		// Failed to add the collection, it already exists
		LastError = LOCTEXT("Error_AlreadyExists", "The collection already exists.");
		return false;
	}

	if ( Collection->Save(LastError) )
	{
		// Collection saved!
		CollectionCreatedEvent.Broadcast( FCollectionNameType( CollectionName, ShareType ) );
		return true;
	}
	else
	{
		// Collection failed to save, remove it from the cache
		RemoveCollection(Collection, ShareType);
		return false;
	}
}
Ejemplo n.º 6
0
bool IPCCollectionType::GetMethod(LSOBJECTDATA &ObjectData, PLSTYPEMETHOD pMethod, int argc, char *argv[])
{
/*******************************************
 * Parameters
 *
 * [in] LSOBJECTDATA ObjectData: ObjectData is a 32-bit value that can be accessed in any number of different ways
 *        by way of union.  Most commonly, ObjectData.Ptr, ObjectData.DWord, or ObjectData.CharPtr are useful.  This
 *        value is the representation of some object of this object type.  "ipcfoo" works on IPCFoo*
 *        so ObjectData is a IPCFoo*
 *
 * [in] PLSTYPEMETHOD pMethod: pMethod is a pointer to the information on the method to be retrieved, including its
 *        Name and ID.  We use the ID in a switch statement in order to quickly process the method, since the Name
 *        has already been resolved by the LavishScript engine.
 *
 * [in] int argc, char *argv[]: argc and argv are *nearly* standard C console program parameters.  The difference here
 *        is that the name of the method is NOT given as the first argument (in contrast to LavishScript commands).
 *        Therefore, argc is 0 unless arguments are specifically given to the method retrieval.
 */

/*******************************************
 * Return Value
 *
 * The return value for this function is very simple.  If the method execution fails for any reason, OR the object
 * is destroyed during execution, return false.  Otherwise, return true (indicating the object still exists AND
 * the method execution succeeded).
 *
 */
	/* Validate the pointer */
	if (!pCollection)
		return false;

	/* Perform the given member retrieval */
	switch(pMethod->ID)
	{
	case Erase:
		if(argc)
		{
			pCollection->Collection->RemoveItem(argv[0]);
			CollectionRelay(pCollection->IPCName, pCollection->Type->GetName(), pCollection->SubType, "Erase", argc, argv);
			return true;
		}
		return false;
	case Clear:
		pCollection->Collection->Clear();
		CollectionRelay(pCollection->IPCName, pCollection->Type->GetName(), pCollection->SubType, "Clear", argc, argv);
		return true;
	case Set:
		if (argc>1)
		{			
			pCollection->Collection->SetItem(argv[0], argc-1, &argv[1]);
			CollectionRelay(pCollection->IPCName, pCollection->Type->GetName(), pCollection->SubType, "Set", argc, argv);
			return true;
		}
	case SetIPCName:
		if(argc==1)
		{
			LSObjectCollection *newCollection;
			strncpy(pCollection->IPCName, argv[0], sizeof(pCollection->IPCName));
			if((newCollection=FindCollection(pCollection->IPCName))==0)
			{
				newCollection = new LSObjectCollection(pCollection->Type, pCollection->SubType);
				AddCollection(pCollection->IPCName, newCollection);
			}
			pCollection->Collection = newCollection;
			return true;
		}
		return false;
	case GetIterator:
		LSOBJECT iteratorobject;
		if(argc)
		{
			//printf("%s %s %d", argv[0], pCollection->IPCName, pCollection->Collection->GetContainerUsed());
			if(pLSInterface->DataParse(argv[0], iteratorobject))
			{
				return InitializeIterator(pCollection->Collection, 0, iteratorobject);
			}
		}
		return false;
	}
	return false;
}