Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::IO::MockFileIOBase Class Reference

Inherits AZ::IO::FileIOBase.

Public Member Functions

 MOCK_METHOD3 (Open, Result(const char *filePath, OpenMode mode, HandleType &fileHandle))
 
 MOCK_METHOD1 (Close, Result(HandleType fileHandle))
 
 MOCK_METHOD2 (Tell, Result(HandleType fileHandle, AZ::u64 &offset))
 
 MOCK_METHOD3 (Seek, Result(HandleType fileHandle, AZ::s64 offset, SeekType type))
 
 MOCK_METHOD5 (Read, Result(HandleType, void *, AZ::u64, bool, AZ::u64 *))
 
 MOCK_METHOD4 (Write, Result(HandleType, const void *, AZ::u64, AZ::u64 *))
 
 MOCK_METHOD1 (Flush, Result(HandleType fileHandle))
 
 MOCK_METHOD1 (Eof, bool(HandleType fileHandle))
 
 MOCK_METHOD1 (ModificationTime, AZ::u64(HandleType fileHandle))
 
 MOCK_METHOD1 (ModificationTime, AZ::u64(const char *filePath))
 
 MOCK_METHOD2 (Size, Result(const char *filePath, AZ::u64 &size))
 
 MOCK_METHOD2 (Size, Result(HandleType fileHandle, AZ::u64 &size))
 
 MOCK_METHOD1 (Exists, bool(const char *filePath))
 
 MOCK_METHOD1 (IsDirectory, bool(const char *filePath))
 
 MOCK_METHOD1 (IsReadOnly, bool(const char *filePath))
 
 MOCK_METHOD1 (CreatePath, Result(const char *filePath))
 
 MOCK_METHOD1 (DestroyPath, Result(const char *filePath))
 
 MOCK_METHOD1 (Remove, Result(const char *filePath))
 
 MOCK_METHOD2 (Copy, Result(const char *sourceFilePath, const char *destinationFilePath))
 
 MOCK_METHOD2 (Rename, Result(const char *originalFilePath, const char *newFilePath))
 
 MOCK_METHOD3 (FindFiles, Result(const char *filePath, const char *filter, FindFilesCallbackType callback))
 
 MOCK_METHOD2 (SetAlias, void(const char *alias, const char *path))
 
 MOCK_METHOD1 (ClearAlias, void(const char *alias))
 
 MOCK_CONST_METHOD1 (GetAlias, const char *(const char *alias))
 
 MOCK_METHOD2 (SetDeprecatedAlias, void(AZStd::string_view, AZStd::string_view))
 
 MOCK_CONST_METHOD2 (ConvertToAlias, AZStd::optional< AZ::u64 >(char *inOutBuffer, AZ::u64 bufferLength))
 
 MOCK_CONST_METHOD2 (ConvertToAlias, bool(AZ::IO::FixedMaxPath &aliasPath, const AZ::IO::PathView &path))
 
 MOCK_CONST_METHOD3 (ResolvePath, bool(const char *path, char *resolvedPath, AZ::u64 resolvedPathSize))
 
 MOCK_CONST_METHOD2 (ResolvePath, bool(AZ::IO::FixedMaxPath &resolvedPath, const AZ::IO::PathView &path))
 
 MOCK_CONST_METHOD2 (ReplaceAlias, bool(AZ::IO::FixedMaxPath &replacedAliasPath, const AZ::IO::PathView &path))
 
 MOCK_CONST_METHOD3 (GetFilename, bool(HandleType fileHandle, char *filename, AZ::u64 filenameSize))
 
virtual AZStd::optional< AZ::u64 > ConvertToAlias (char *inOutBuffer, AZ::u64 bufferLength) const=0
 
virtual bool ConvertToAlias (AZ::IO::FixedMaxPath &convertedPath, const AZ::IO::PathView &path) const=0
 
AZStd::optional< AZ::IO::FixedMaxPathConvertToAlias (const AZ::IO::PathView &path) const
 
virtual bool ResolvePath (const char *path, char *resolvedPath, AZ::u64 resolvedPathSize) const=0
 
virtual bool ResolvePath (AZ::IO::FixedMaxPath &resolvedPath, const AZ::IO::PathView &path) const=0
 
AZStd::optional< AZ::IO::FixedMaxPathResolvePath (const AZ::IO::PathView &path) const
 
- Public Member Functions inherited from AZ::IO::FileIOBase
virtual Result Open (const char *filePath, OpenMode mode, HandleType &fileHandle)=0
 
virtual Result Close (HandleType fileHandle)=0
 
virtual Result Tell (HandleType fileHandle, AZ::u64 &offset)=0
 
virtual Result Seek (HandleType fileHandle, AZ::s64 offset, SeekType type)=0
 
virtual Result Read (HandleType fileHandle, void *buffer, AZ::u64 size, bool failOnFewerThanSizeBytesRead=false, AZ::u64 *bytesRead=nullptr)=0
 
virtual Result Write (HandleType fileHandle, const void *buffer, AZ::u64 size, AZ::u64 *bytesWritten=nullptr)=0
 
virtual Result Flush (HandleType fileHandle)=0
 
virtual bool Eof (HandleType fileHandle)=0
 
virtual AZ::u64 ModificationTime (HandleType fileHandle)=0
 
virtual AZ::u64 ModificationTime (const char *filePath)=0
 
virtual Result Size (const char *filePath, AZ::u64 &size)=0
 Get the size of the file. Returns Success if we report size.
 
virtual Result Size (HandleType fileHandle, AZ::u64 &size)=0
 
virtual bool Exists (const char *filePath)=0
 no fail, returns false if it does not exist
 
virtual bool IsDirectory (const char *filePath)=0
 no fail, returns false if its not a directory or does not exist
 
virtual bool IsReadOnly (const char *filePath)=0
 no fail, returns false if its read only or does not exist
 
virtual Result CreatePath (const char *filePath)=0
 create a path, recursively
 
virtual Result DestroyPath (const char *filePath)=0
 
virtual Result Remove (const char *filePath)=0
 
virtual Result Copy (const char *sourceFilePath, const char *destinationFilePath)=0
 
virtual Result Rename (const char *originalFilePath, const char *newFilePath)=0
 
virtual Result FindFiles (const char *filePath, const char *filter, FindFilesCallbackType callback)=0
 
virtual void SetAlias (const char *alias, const char *path)=0
 SetAlias - Adds an alias to the path resolution system, e.g. @user@, @products@, etc.
 
virtual void ClearAlias (const char *alias)=0
 ClearAlias - Removes an alias from the path resolution system.
 
virtual const char * GetAlias (const char *alias) const =0
 GetAlias - Returns the destination path for a given alias, or nullptr if the alias does not exist.
 
virtual void SetDeprecatedAlias (AZStd::string_view oldAlias, AZStd::string_view newAlias)=0
 
virtual AZStd::optional< AZ::u64 > ConvertToAlias (char *inOutBuffer, AZ::u64 bufferLength) const =0
 
virtual bool ConvertToAlias (AZ::IO::FixedMaxPath &convertedPath, const AZ::IO::PathView &path) const =0
 
AZStd::optional< AZ::IO::FixedMaxPathConvertToAlias (const AZ::IO::PathView &path) const
 
virtual bool ResolvePath (const char *path, char *resolvedPath, AZ::u64 resolvedPathSize) const =0
 
virtual bool ResolvePath (AZ::IO::FixedMaxPath &resolvedPath, const AZ::IO::PathView &path) const =0
 
AZStd::optional< AZ::IO::FixedMaxPathResolvePath (const AZ::IO::PathView &path) const
 
virtual bool ReplaceAlias (AZ::IO::FixedMaxPath &replacedAliasPath, const AZ::IO::PathView &path) const =0
 
virtual bool GetFilename (HandleType fileHandle, char *filename, AZ::u64 filenameSize) const =0
 Divulge the filename used to originally open that handle.
 
virtual bool IsRemoteIOEnabled ()
 

Static Public Member Functions

static void InstallDefaultReturns (NiceFileIOBaseMock &target)
 
- Static Public Member Functions inherited from AZ::IO::FileIOBase
static FileIOBaseGetInstance ()
 
static void SetInstance (FileIOBase *instance)
 
static FileIOBaseGetDirectInstance ()
 
static void SetDirectInstance (FileIOBase *instance)
 

Static Public Attributes

static const AZ::IO::HandleType FakeFileHandle = AZ::IO::HandleType(1234)
 

Additional Inherited Members

- Public Types inherited from AZ::IO::FileIOBase
typedef AZStd::function< bool(const char *)> FindFilesCallbackType
 

Member Function Documentation

◆ ConvertToAlias() [1/2]

virtual bool AZ::IO::FileIOBase::ConvertToAlias ( AZ::IO::FixedMaxPath convertedPath,
const AZ::IO::PathView path 
) const
virtual

ConvertToAlias - Converts the start of the path to alias form. i.e @alias@/... if possible i.e if

Implements AZ::IO::FileIOBase.

◆ ConvertToAlias() [2/2]

virtual AZStd::optional< AZ::u64 > AZ::IO::FileIOBase::ConvertToAlias ( char *  inOutBuffer,
AZ::u64  bufferLength 
) const
virtual

Shorten the given path if it contains an alias. it will always pick the longest alias match. note that it re-uses the buffer, since the data can only get smaller and we don't want to internally allocate memory if we can avoid it. If for some reason the @alias@ is longer than the path it represents and the path cannot fit in the buffer a nullopt is returned, otherwise it returns the length of the result

Implements AZ::IO::FileIOBase.

◆ InstallDefaultReturns()

static void AZ::IO::MockFileIOBase::InstallDefaultReturns ( NiceFileIOBaseMock &  target)
inlinestatic

Installs some default result values for the above functions. Note that you can always override these in scope of your test by adding additional ON_CALL / EXPECT_CALL statements in the body of your test or after calling this function, and yours will take precidence.

◆ ResolvePath() [1/2]

virtual bool AZ::IO::FileIOBase::ResolvePath ( AZ::IO::FixedMaxPath resolvedPath,
const AZ::IO::PathView path 
) const
virtual

ResolvePath - Replaces any @ aliases in the supplied path with their the resolved alias values Converts the path to an absolute path, and replaces path separators with unix slashes The resolved path is returned in as a FixedMaxPath, unless it is longer than MaxPathLength in which case a null optional is returned

Implements AZ::IO::FileIOBase.

◆ ResolvePath() [2/2]

virtual bool AZ::IO::FileIOBase::ResolvePath ( const char *  path,
char *  resolvedPath,
AZ::u64  resolvedPathSize 
) const
virtual

ResolvePath - Replaces any aliases in path with their values and stores the result in resolvedPath, also ensures that the path is absolute NOTE: If the path does not start with an alias then the resolved value of the @products@ is used which has the effect of making the path relative to the @products@/ folder returns true if path was resolved, false otherwise note that all of the above file-finding and opening functions automatically resolve the path before operating so you should not need to call this except in very exceptional circumstances where you absolutely need to hit a physical file and don't want to use SystemFile

Implements AZ::IO::FileIOBase.


The documentation for this class was generated from the following file: