Ejemplo n.º 1
0
int PostMetaStrategy::Execute(FileManager* fm, CredentialsManager* cm) {
    int status = ret::A_OK;
    status = InitInstance(fm, cm);

    post_path_ = GetConfigValue("post_path");
    posts_feed_ = GetConfigValue("posts_feed");
    std::string filepath = GetConfigValue("filepath");
    std::string entity = GetConfigValue("entity");

    std::cout<<" Post meta strategy " << std::endl;
    if(ValidMasterKey()) {
        FileHandler fh(file_manager_);
        if(!fh.DoesFileExist(filepath)) {
            std::cout<<" File doesn't exist yet, create meta post" << std::endl;
            FileInfo fi;
            status = CreateFileEntry(filepath, fi);
        }
        else {
           // no nead to throw an error, postfilestrategy should dif the hashes 
           // and really determine if it should acutally be re-uploaded
           //
           // status = ret::A_FAIL_FILE_ALREADY_EXISTS;
        }
    }
    else {
        status = ret::A_FAIL_INVALID_MASTERKEY;
    }
    std::cout<<" post meta strategy status : " << status << std::endl;
    return status;
}
Ejemplo n.º 2
0
bool FileIntf::Impl::AppendImpl(FilePos pos, const char* buff, size_t buffSize)
{
	BlockHandle fileEntry = pos.fileEntry;
	FileEntry* pFileEntry = _blockReader.Get<FileEntry>(fileEntry);
	if (!pFileEntry)
	{
		LOG_ERROR("%s", "Block handle is not a file entry handle");
		return false;
	}
	if (pFileEntry->next)
	{
		LOG_ERROR("%s", "Position passed to AppendImpl is not EOF-like");
		return false;
	}
	while (buffSize)
	{
		BlockHandle newFileEntry = CreateFileEntry(std::min(buffSize, FileIntf::GetMaxPayloadSize()));
		size_t written = WriteToFileEntry(newFileEntry, buff, buffSize, 0);
		buff += written;
		buffSize -= written;
		pFileEntry = _blockReader.Get<FileEntry>(fileEntry);
		if (!pFileEntry)
		{
			LOG_ERROR("%s", "Invalid block");
		}
		pFileEntry->next = newFileEntry;
		fileEntry = newFileEntry;
	}
	return !buffSize;
}
Ejemplo n.º 3
0
/**
Processes a file entries block in the directory and creates the appropriate 
nodes for each file in the block

@param aStartPosition start for file block in the core image file
@param aSize size of the file entries block
*/
TInt TDirectoryEntry::AddFiles(long aStartPosition, int aSize )
	{
	long savedPosition = iReader->FilePosition();
	long currentPos = aStartPosition;
	iReader->SetFilePosition(aStartPosition);
	long endPos = aStartPosition+aSize;
	TRofsEntry entry;
	TInt result = KErrNone;
	while (currentPos < endPos && result == KErrNone)	
		{
		TInt size = iReader->ReadRofEntry(entry, currentPos);
		if (size > 0)
			{
			TText *nameStr = GetName(entry.iName[0], entry.iNameLength);
			if (nameStr != 0)
				{
				result = CreateFileEntry(nameStr, entry);
				currentPos += entry.iStructSize;
				}
			else
				result = KErrNoMemory;
			if(nameStr != 0)
			    delete [] nameStr;
			}
		else
			{
			result = KErrGeneral;
			}
		}
	iReader->SetFilePosition(savedPosition);
	return result;
	}
Ejemplo n.º 4
0
bool FileIntf::Impl::AppendImpl(BlockHandle fileHeader, const char* buff, size_t buffSize)
{
	FileHeader* pFileHeader = _blockReader.Get<FileHeader>(fileHeader);
	if (!pFileHeader)
	{
		LOG_ERROR("%s", "Invalid file header");
		return false;
	}
	if (pFileHeader->body)
	{
		LOG_ERROR("%s", "File is not empty");
		return false;
	}
	uint32_t fileEntrySize = std::min(buffSize, FileIntf::GetMaxPayloadSize());
	BlockHandle newFileEntry = CreateFileEntry(fileEntrySize);
	size_t written = WriteToFileEntry(newFileEntry, buff, buffSize, 0);
	// this block is the new body in file header
	pFileHeader = _blockReader.Get<FileHeader>(fileHeader);
	if (!pFileHeader)
	{
		LOG_ERROR("%s", "Invalid file header");
		return false;
	}
	pFileHeader->body = newFileEntry;
	if (written == buffSize)
	{
		return true;
	}
	FilePos pos;
	pos.fileEntry = newFileEntry;
	pos.memOffset = 0;
	pos.offset = 0;
	return AppendImpl(pos, buff + written, buffSize - written);
}
Ejemplo n.º 5
0
ALERROR CListSaveFilesTask::OnExecute (ITaskProcessor *pProcessor, CString *retsResult)

//	OnExecute
//
//	Execute the task
	
	{
	int i;

	const CVisualPalette &VI = m_HI.GetVisuals();

	//	Make a list of all files in the directory

	TArray<CString> SaveFiles;
	bool bAtLeastOneFolder = false;
	for (i = 0; i < m_Folders.GetCount(); i++)
		{
		if (!fileGetFileList(m_Folders[i], NULL_STR, CONSTLIT("*.sav"), 0, &SaveFiles))
			::kernelDebugLogMessage("Unable to read from save file folder: %s", m_Folders[i]);
		else
			bAtLeastOneFolder = true;
		}

	//	If we couldn't read from any folder, return an error

	if (!bAtLeastOneFolder)
		{
		*retsResult = ERR_DIRECTORY_FAILED;
		return ERR_FAIL;
		}

	//	Sort by modified time (most recent first)

	TSortMap<CTimeDate, CString> SortedList(DescendingSort);
	for (i = 0; i < SaveFiles.GetCount(); i++)
		SortedList.Insert(fileGetModifiedTime(SaveFiles[i]), SaveFiles[i]);

	//	Generate a Reanimator list of the profile. The root will be a CAniListBox

	m_pList = new CAniListBox;
	m_pList->SetPropertyMetric(PROP_FADE_EDGE_HEIGHT, 0.0);
	m_pList->SetPropertyMetric(PROP_PADDING_BOTTOM, (Metric)MAJOR_PADDING_BOTTOM);

	//	Set the selection style for the list

	IAnimatron *pStyle = new CAniRoundedRect;
	pStyle->SetPropertyColor(PROP_COLOR, VI.GetColor(colorAreaDialogInputFocus));
	pStyle->SetPropertyOpacity(PROP_OPACITY, 255);
	pStyle->SetPropertyString(PROP_LINE_TYPE, LINE_TYPE_SOLID);
	pStyle->SetPropertyColor(PROP_LINE_COLOR, VI.GetColor(colorAreaDialogHighlight));
	pStyle->SetPropertyInteger(PROP_LINE_WIDTH, SELECTION_BORDER_WIDTH);
	pStyle->SetPropertyInteger(PROP_UL_RADIUS, SELECTION_CORNER_RADIUS);
	pStyle->SetPropertyInteger(PROP_UR_RADIUS, SELECTION_CORNER_RADIUS);
	pStyle->SetPropertyInteger(PROP_LL_RADIUS, SELECTION_CORNER_RADIUS);
	pStyle->SetPropertyInteger(PROP_LR_RADIUS, SELECTION_CORNER_RADIUS);
	m_pList->SetStyle(STYLE_SELECTION_FOCUS, pStyle);

	pStyle = new CAniRoundedRect;
	pStyle->SetPropertyColor(PROP_COLOR, VI.GetColor(colorAreaDialogInputFocus));
	pStyle->SetPropertyOpacity(PROP_OPACITY, 255);
	pStyle->SetPropertyInteger(PROP_UL_RADIUS, SELECTION_CORNER_RADIUS);
	pStyle->SetPropertyInteger(PROP_UR_RADIUS, SELECTION_CORNER_RADIUS);
	pStyle->SetPropertyInteger(PROP_LL_RADIUS, SELECTION_CORNER_RADIUS);
	pStyle->SetPropertyInteger(PROP_LR_RADIUS, SELECTION_CORNER_RADIUS);
	m_pList->SetStyle(STYLE_SELECTION, pStyle);

	//	No need to log image load

	g_pUniverse->SetLogImageLoad(false);

	//	Loop over all files and add them to the scroller

	int y = MAJOR_PADDING_TOP;
	for (i = 0; i < SortedList.GetCount(); i++)
		{
		CString sFilename = SortedList[i];
		CGameFile GameFile;

		//	Ignore files that we can't open

		if (GameFile.Open(sFilename) != NOERROR)
			continue;

		//	If the universe is not valid, then this is not a proper save file
		//	(this can happen in the first system).

		if (!GameFile.IsUniverseValid())
			continue;

		//	If we're signed in, then we only show games for the given user
		//	(or unregistered games).

		if (GameFile.IsRegistered() && !strEquals(GameFile.GetUsername(), m_sUsername))
			continue;

		//	Generate a record for the file

		IAnimatron *pEntry;
		int cyHeight;
		CreateFileEntry(GameFile, SortedList.GetKey(i), y, &pEntry, &cyHeight);

		m_pList->AddEntry(sFilename, pEntry);
		y += cyHeight + INTER_LINE_SPACING;

		//	Done

		GameFile.Close();
		}

	g_pUniverse->SetLogImageLoad(true);

	//	Done

	return NOERROR;
	}