Files
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

66 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "HAL/FileManager.h"
#include "IMessageAttachment.h"
/**
* Implements a message attachment whose data is held in a file.
*
* WARNING: Message attachments do not work yet for out of process messages.
*/
class FFileMessageAttachment
: public IMessageAttachment
{
public:
/**
* Creates and initializes a new instance.
*
* @param Filename The full name and path of the file.
*/
FFileMessageAttachment( const FString& InFilename )
: AutoDeleteFile(false)
, Filename(InFilename)
{ }
/**
* Creates and initializes a new instance.
*
* @param Filename The full name and path of the file.
* @param AutoDeleteFile Whether to delete the file when this attachment is destroyed.
*/
FFileMessageAttachment( const FString& InFilename, bool InAutoDeleteFile )
: AutoDeleteFile(InAutoDeleteFile)
, Filename(InFilename)
{ }
/** Destructor. */
~FFileMessageAttachment()
{
if (AutoDeleteFile)
{
IFileManager::Get().Delete(*Filename);
}
}
public:
// IMessageAttachment interface
virtual FArchive* CreateReader() override
{
return IFileManager::Get().CreateFileReader(*Filename);
}
private:
/** Holds a flag indicating whether the file should be deleted. */
bool AutoDeleteFile;
/** Holds the name of the file that holds the attached data. */
FString Filename;
};