From b23c95cab3872bb619768274ec29949f71de27c4 Mon Sep 17 00:00:00 2001 From: srikappa Date: Tue, 8 Jun 2021 17:58:59 -0700 Subject: [PATCH] Removed the new added flavor of ReadFile and reused existing one --- Code/Framework/AzCore/AzCore/Utils/Utils.cpp | 31 ------------------- Code/Framework/AzCore/AzCore/Utils/Utils.h | 4 --- .../AzToolsFramework/Prefab/PrefabLoader.cpp | 2 +- 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Utils/Utils.cpp b/Code/Framework/AzCore/AzCore/Utils/Utils.cpp index 5521ff6131..7025b3977e 100644 --- a/Code/Framework/AzCore/AzCore/Utils/Utils.cpp +++ b/Code/Framework/AzCore/AzCore/Utils/Utils.cpp @@ -169,37 +169,6 @@ namespace AZ::Utils template AZ::Outcome, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize); template AZ::Outcome, AZStd::string> ReadFile(AZStd::string_view filePath, size_t maxFileSize); - template - AZ::Outcome 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 ReadFileWithNoSizeLimit(AZStd::string_view filePath); - template AZ::Outcome, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath); - template AZ::Outcome, AZStd::string> ReadFileWithNoSizeLimit(AZStd::string_view filePath); - AZ::IO::FixedMaxPathString GetO3deManifestDirectory() { AZ::IO::FixedMaxPath path = GetHomeDirectory(); diff --git a/Code/Framework/AzCore/AzCore/Utils/Utils.h b/Code/Framework/AzCore/AzCore/Utils/Utils.h index 6aaa1b868f..d082a3ebe0 100644 --- a/Code/Framework/AzCore/AzCore/Utils/Utils.h +++ b/Code/Framework/AzCore/AzCore/Utils/Utils.h @@ -117,9 +117,5 @@ namespace AZ //! the file size is larger than the max file size provided. template AZ::Outcome 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 - AZ::Outcome ReadFileWithNoSizeLimit(AZStd::string_view filePath); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp index 25a16f18a8..44dff93cb5 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp @@ -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::max()); if (!readResult.IsSuccess()) { AZ_Error(