Exemplo n.º 1
0
VArrayString *VFolder::GetContents(FolderFilter inFolderFilter) const
{
	if (!Exists())
		return NULL;
	
	FileIteratorOptions flags = FI_WANT_NONE;
	switch( inFolderFilter) {
		case FF_NO_FILTER:		flags = FI_WANT_FILES | FI_WANT_FOLDERS; break;
		case FF_NO_FOLDERS:		flags = FI_WANT_FILES; break;
		case FF_NO_FILES:		flags = FI_WANT_FOLDERS; break;
		default:
			xbox_assert( false);
	}

	VArrayString *names = new VArrayString;
	VString name;

	if( flags & FI_WANT_FILES )
		for( VFileIterator i( this, FI_WANT_FILES) ; i.IsValid() ; ++i)
		{
			i->GetName( name);
			names->AppendString( name);
		}

	if( flags & FI_WANT_FOLDERS )
		for( VFolderIterator i( this, FI_WANT_FOLDERS) ; i.IsValid() ; ++i)
		{
			i->GetName( name);
			names->AppendString( name);
		}

	return names;
}
Exemplo n.º 2
0
VError VMacResFile::GetResourceListNames(const VString& inType, VArrayString& outNames) const
{
OSErr macError = noErr;

	outNames.SetCount(0);

	if (!testAssert(fRefNum != -1))
		return VE_STREAM_NOT_OPENED;
	
	ResType type = inType.GetOsType();
	if (type == 0)
		return VE_INVALID_PARAMETER;
	
	sWORD	oldref = ::CurResFile();
	sWORD	ref = fRefNum;
	while(ref != -1 && ref != 0)
	{
		::UseResFile(ref);
		sWORD	count = ::Count1Resources(type);
		::UseResFile(oldref);
		
		for(sWORD	i = 1 ; i <= count ; ++i)
		{
			::UseResFile(ref);
			::SetResLoad(false);
			Handle data = ::Get1IndResource(type, i);
			macError = ::ResError();
			::SetResLoad(true);
			::UseResFile(oldref); // one must restore proper context before calling VArrayValue::AppendWord

			if (data != NULL)
			{
				ResType type2;
				sWORD	id;
				Str255 spName;
				::GetResInfo(data, &id, &type2, spName);
				macError = ::ResError();
				if (macError == noErr && spName[0] > 0)
				{
					VString name;
					name.MAC_FromMacPString(spName);
					if (outNames.Find(name) == -1)
						outNames.AppendString(name);
				}
			}
		}
		
		if (!fUseResourceChain)
			break;
		else
		{
			macError = ::GetNextResourceFile(ref, &ref); // returns ref = 0 and noerror at the end
			if (!testAssert(macError == noErr))
				break;
		}
	}
	return VE_OK;
}
Exemplo n.º 3
0
bool VFolder::Contains( const XBOX::VString& inExtension) const
{
	bool found = false;

	VArrayString* files = GetContents(FF_NO_FOLDERS);
	if (files)
	{
		VString name;
		for (sLONG i = 1; i <= files->GetCount(); ++i)
		{
			files->GetString(name, i);
			if (name.EndsWith(inExtension))
			{
				found = true;
				break;
			}

		}
		delete files;
	}
	
	return found;
}
Exemplo n.º 4
0
VError VMacResFile::GetResourceListTypes(VArrayString& outTypes) const
{
	outTypes.SetCount(0);

	if (!testAssert(fRefNum != -1))
		return VE_STREAM_NOT_OPENED;

	sWORD	oldref = ::CurResFile();
	sWORD	ref = fRefNum;
	while(ref != -1 && ref != 0)
	{
		::UseResFile(ref);
		sWORD	count = ::Count1Types();
		::UseResFile(oldref);
		
		for(sWORD	i = 1 ; i <= count ; ++i)
		{
			ResType type;
			::UseResFile(ref);
			::Get1IndType(&type, i);
			::UseResFile(oldref); // one must restore proper context before calling outTypes.AppendVString

			outTypes.AppendString(VResTypeString(type));
		}
		
		if (!fUseResourceChain)
			break;
		else
		{
			OSErr macError = ::GetNextResourceFile(ref, &ref); // returns ref = 0 and noerror at the end
			if (!testAssert(macError == noErr))
				break;
		}
	}
	return VE_OK;
}
Exemplo n.º 5
0
void VValueBag::_ReadFromStream_v1( VStream *inStream)
{
	VStr31 name;

	VArrayString singleNames;
	singleNames.ReadFromStream( inStream);
	
	VIndex max_singlevalues = inStream->GetLong();
	for( VIndex i = 1 ; i <= max_singlevalues; i++)
	{
		sLONG value_kind = inStream->GetLong();
		VValue* temp_value = NewValueFromValueKind((ValueKind)value_kind);
		VValueSingle* temp_single_value = dynamic_cast<VValueSingle*>(temp_value);
		if (temp_single_value != NULL)
		{
			temp_single_value->ReadFromStream( inStream);
			
			singleNames.GetString( name, i);
			fAttributes.Append( name, *temp_single_value);
		}
		delete temp_value;
	}

	VArrayString				multipleNames;

	multipleNames.ReadFromStream( inStream);
	
	VIndex max_bag_array = inStream->GetLong();
	if (max_bag_array > 0)
	{
		fElements = new VPackedVBagArrayDictionary;
		for( VIndex j = 1 ; j <= max_bag_array ; j++)
		{
			VBagArray* bag_array = new VBagArray;
			bag_array->ReadFromStreamMinimal( inStream);
			multipleNames.GetString( name, j);
			if (fElements)
				fElements->Append( name, bag_array);
			bag_array->Release();
		}
	}
}