XBOX::VError VProjectItemFolder::Rename( const XBOX::VString& inNewName)
{
	if (fOwner == NULL)
		return VE_FOLDER_CANNOT_RENAME;
	
	VFilePath path;
	if (!fOwner->GetFilePath( path))
		return VE_FOLDER_CANNOT_RENAME;

	VFolder *newFolder = NULL;
	VFolder folder( path);
	VError err = folder.Rename( inNewName, &newFolder);
	if (err == VE_OK && newFolder != NULL)
	{
		VString folderName;
		newFolder->GetName( folderName);

		fOwner->SetName( folderName);	// sc 26/09/2011, WAK0073011
		fOwner->SetDisplayName( folderName);
		
		if (fOwner->HasRelativePath())
		{
			folderName += FOLDER_SEPARATOR;
			fOwner->SetRelativePath( folderName);
		}
		else
		{
			VFilePath path;
			newFolder->GetPath( path);
			fOwner->SetURL( VURL( path));
		}
	}

	if (err != VE_OK)
		err = VE_FOLDER_CANNOT_RENAME;
	
	return err;	
}
//ACI0078887 23rd Nov 2012, O.R., always specify folder used for computing relative path of entry in TOC
VError VArchiveStream::_WriteCatalog( const VFile* inFile, const XBOX::VFilePath& inSourceFolder,const VString &inExtraInfo, uLONG8 &ioTotalByteCount )
{
	VString fileInfo;
	VStr8 slash("/");
	VStr8 extra("::");
	VStr8 folderSep(XBOX::FOLDER_SEPARATOR);
	VError result = VE_INVALID_PARAMETER;
	XBOX::VString savedExtraInfo = inExtraInfo;

	//ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder
	//don't assume that extra info carries relative folder info
		//ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder
	//don't assume that extra info carries relative folder info
	if (savedExtraInfo == PRESERVE_PARENT_OPTION)
	{
		//this is a bogus extra info that we use internally so we need to clear it so that it is not saved into
		//the archive.
		//This options means that the file will have to be restored in with its parent directory preserved.
		savedExtraInfo.Clear();

		VFolder *folder = inFile->RetainParentFolder();
		VString fileName;
		folder->GetName(fileInfo);
		// folder name can be a drive letter like Z:
		fileInfo.Exchange( (UniChar) ':', (UniChar) '_');
		inFile->GetName(fileName);
		fileInfo += slash;
		fileInfo += fileName;
		fileInfo.Insert( slash, 1 );
		folder->Release();
		result  = VE_OK;
	}
	else
	{
		if(testAssert(inFile->GetPath().GetRelativePath(inSourceFolder,fileInfo)))
		{
			result  = VE_OK;
			fileInfo.Insert( FOLDER_SEPARATOR, 1);
		}
	}

	if(result == VE_OK)
	{
		fileInfo.Exchange(folderSep ,slash, 1, 255);
		if ( fileInfo.GetUniChar(1) == '/' )
			fileInfo.Insert( '.', 1 );

		fileInfo += extra;
		fileInfo += savedExtraInfo;
		result = fStream->PutLong('file');
		if ( result == VE_OK )
		{
			result = fileInfo.WriteToStream(fStream);
		}
		if ( result == VE_OK )
		{
			sLONG8 fileSize = 0;
			inFile->GetSize(&fileSize);
			fStream->PutLong8(fileSize);
			ioTotalByteCount += fileSize;
	#if VERSIONWIN || VERSION_LINUX
			/* rez file size */
			fStream->PutLong8(0);
			/* no file kind or creator under Windows */
			fStream->PutLong(0); /* kind */
			fStream->PutLong(0); /* creator */
	#elif VERSIONMAC
			inFile->GetResourceForkSize(&fileSize);
			fStream->PutLong8(fileSize);
			ioTotalByteCount += fileSize;

			OsType osType;
			inFile->MAC_GetKind( &osType );
			result = fStream->PutLong( osType );
			inFile->MAC_GetCreator( &osType );
			result = fStream->PutLong( osType );
	#endif
		}
	}
	return result;
}