Removed the new added flavor of ReadFile and reused existing one

This commit is contained in:
srikappa
2021-06-08 17:58:59 -07:00
parent 9dec723e33
commit b23c95cab3
3 changed files with 1 additions and 36 deletions
@@ -169,37 +169,6 @@ namespace AZ::Utils
template AZ::Outcome<AZStd::vector<int8_t>, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize);
template AZ::Outcome<AZStd::vector<uint8_t>, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize);
template<typename Container>
AZ::Outcome<Container, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath)
{
IO::FileIOStream file;
if (!file.Open(filePath.data(), IO::OpenMode::ModeRead))
{
return AZ::Failure(AZStd::string::format("Failed to open '%.*s'.", AZ_STRING_ARG(filePath)));
}
AZ::IO::SizeType length = file.GetLength();
if (length == 0)
{
return AZ::Failure(AZStd::string::format("Failed to load '%.*s'. File is empty.", AZ_STRING_ARG(filePath)));
}
Container fileContent;
fileContent.resize(length);
AZ::IO::SizeType bytesRead = file.Read(length, fileContent.data());
file.Close();
// Resize again just in case bytesRead is less than length for some reason
fileContent.resize(bytesRead);
return AZ::Success(AZStd::move(fileContent));
}
template AZ::Outcome<AZStd::string, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath);
template AZ::Outcome<AZStd::vector<int8_t>, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath);
template AZ::Outcome<AZStd::vector<uint8_t>, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath);
AZ::IO::FixedMaxPathString GetO3deManifestDirectory()
{
AZ::IO::FixedMaxPath path = GetHomeDirectory();
@@ -117,9 +117,5 @@ namespace AZ
//! the file size is larger than the max file size provided.
template<typename Container = AZStd::string>
AZ::Outcome<Container, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize = DefaultMaxFileSize);
//! Read a file into a string. Returns a failure with error message if the content could not be loaded.
template<typename Container = AZStd::string>
AZ::Outcome<Container, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath);
}
}
@@ -74,7 +74,7 @@ namespace AzToolsFramework
return InvalidTemplateId;
}
auto readResult = AZ::Utils::ReadFileWithNoSizeLimit(GetFullPath(filePath).Native());
auto readResult = AZ::Utils::ReadFile(GetFullPath(filePath).Native(), AZStd::numeric_limits<size_t>::max());
if (!readResult.IsSuccess())
{
AZ_Error(