IVGCVSW-4487 Remove boost::filesystem

 * Replace filesystem::path
 * Replace filesystem::exists
 * Replace filesystem::is_directory
 * Replace filesystem::directory_iterator
 * Replace filesystem::filesystem_error exception
 * Replace filesystem::temp_directory_path
 * Replace filesystem::unique path
 * Replace filesystem::ofstream with std::ofstream
 * Replace filesystem::remove
 * Replace filesystem::is_regular_file
 * Replace boost::optional with armnn::Optional in touched files
 * Remove some superfluous includes
 * Update build guides, GlobalConfig.cmake and CMakeLists.txt
 * Remove redundant armnnUtils::Filesystem::Remove function.
 * Remove redundant armnnUtils::Filesystem::GetFileSize function.

Temporarily adding back Boost::filesystem to enable Boost::dll.

Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>

Change-Id: Ifa46d4a0097d2612ddacd8e9736c0b36e365fb11
diff --git a/src/armnn/test/CsvReaderTest.cpp b/src/armnn/test/CsvReaderTest.cpp
index 8491ad7..96185c8 100644
--- a/src/armnn/test/CsvReaderTest.cpp
+++ b/src/armnn/test/CsvReaderTest.cpp
@@ -3,13 +3,13 @@
 // SPDX-License-Identifier: MIT
 //
 #include "CsvReader.hpp"
+#include "armnn/Optional.hpp"
+#include <Filesystem.hpp>
 
 #include <boost/test/unit_test.hpp>
 
 #include <iostream>
 #include <string>
-#include <boost/filesystem.hpp>
-#include <boost/optional.hpp>
 
 using namespace armnnUtils;
 
@@ -29,11 +29,10 @@
 
     std::string CreateTempCsvFile()
     {
-        boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
-        boost::filesystem::path p{fileDir / boost::filesystem::unique_path("%%%%-%%%%-%%%%.csv")};
+        fs::path p = armnnUtils::Filesystem::NamedTempFile("Armnn-CreateTempCsvFileTest-TempFile.csv");
         try
         {
-            boost::filesystem::ofstream ofs{p};
+            std::ofstream ofs{p};
             ofs << "airplane, bicycle , bird , \"m,o,n,k,e,y\"\n";
             ofs << "banana, shoe, \"ice\"";
             ofs.close();
@@ -63,17 +62,17 @@
         {
             try
             {
-                boost::filesystem::remove(*m_CsvFile);
+                fs::remove(m_CsvFile.value());
             }
             catch (std::exception &e)
             {
-                std::cerr << "Unable to delete file [" << *m_CsvFile << "] : " << e.what() << std::endl;
+                std::cerr << "Unable to delete file [" << m_CsvFile.value() << "] : " << e.what() << std::endl;
                 BOOST_TEST(false);
             }
         }
     }
 
-    boost::optional<boost::filesystem::path> m_CsvFile;
+    armnn::Optional<fs::path> m_CsvFile;
 };
 }
 
diff --git a/src/armnn/test/ModelAccuracyCheckerTest.cpp b/src/armnn/test/ModelAccuracyCheckerTest.cpp
index 1bffa9c..c6c93ed 100644
--- a/src/armnn/test/ModelAccuracyCheckerTest.cpp
+++ b/src/armnn/test/ModelAccuracyCheckerTest.cpp
@@ -6,8 +6,6 @@
 
 #include <boost/test/unit_test.hpp>
 
-#include <boost/filesystem.hpp>
-#include <boost/optional.hpp>
 #include <boost/variant.hpp>
 #include <iostream>
 #include <string>
diff --git a/src/armnnDeserializer/Deserializer.cpp b/src/armnnDeserializer/Deserializer.cpp
index b9579d5..f59c757 100644
--- a/src/armnnDeserializer/Deserializer.cpp
+++ b/src/armnnDeserializer/Deserializer.cpp
@@ -19,7 +19,6 @@
 #include <ParserHelper.hpp>
 #include <VerificationHelpers.hpp>
 
-#include <boost/filesystem.hpp>
 #include <boost/format.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 
diff --git a/src/armnnQuantizer/CommandLineProcessor.cpp b/src/armnnQuantizer/CommandLineProcessor.cpp
index 0cccb66..ace4a50 100644
--- a/src/armnnQuantizer/CommandLineProcessor.cpp
+++ b/src/armnnQuantizer/CommandLineProcessor.cpp
@@ -4,12 +4,9 @@
 //
 
 #include "CommandLineProcessor.hpp"
-
-#define BOOST_FILESYSTEM_NO_DEPRECATED
+#include <Filesystem.hpp>
 
 #include <boost/program_options.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
 
 namespace armnnQuantizer
 {
@@ -27,13 +24,13 @@
         dir += "/";
     }
 
-    if (!boost::filesystem::exists(dir))
+    if (!fs::exists(dir))
     {
         std::cerr << "Output directory [" << dir << "] does not exist" << std::endl;
         return false;
     }
 
-    if (!boost::filesystem::is_directory(dir))
+    if (!fs::is_directory(dir))
     {
         std::cerr << "Given output directory [" << dir << "] is not a directory" << std::endl;
         return false;
@@ -44,13 +41,13 @@
 
 bool ValidateProvidedFile(const std::string& inputFileName)
 {
-    if (!boost::filesystem::exists(inputFileName))
+    if (!fs::exists(inputFileName))
     {
         std::cerr << "Provided file [" << inputFileName << "] does not exist" << std::endl;
         return false;
     }
 
-    if (boost::filesystem::is_directory(inputFileName))
+    if (fs::is_directory(inputFileName))
     {
         std::cerr << "Given file [" << inputFileName << "] is a directory" << std::endl;
         return false;
@@ -154,7 +151,7 @@
         }
         else
         {
-            boost::filesystem::path csvFilePath(m_CsvFileName);
+            fs::path csvFilePath(m_CsvFileName);
             m_CsvFileDirectory = csvFilePath.parent_path().c_str();
         }
 
@@ -170,7 +167,7 @@
     std::string output(m_OutputDirectory);
     output.append(m_OutputFileName);
 
-    if (boost::filesystem::exists(output))
+    if (fs::exists(output))
     {
         std::cerr << "Output file [" << output << "] already exists" << std::endl;
         return false;
diff --git a/src/armnnQuantizer/QuantizationDataSet.cpp b/src/armnnQuantizer/QuantizationDataSet.cpp
index 7042d74..819b437 100644
--- a/src/armnnQuantizer/QuantizationDataSet.cpp
+++ b/src/armnnQuantizer/QuantizationDataSet.cpp
@@ -6,12 +6,8 @@
 #include "QuantizationDataSet.hpp"
 #include "CsvReader.hpp"
 
-#define BOOST_FILESYSTEM_NO_DEPRECATED
-
 #include <armnn/utility/IgnoreUnused.hpp>
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
+#include <Filesystem.hpp>
 
 namespace armnnQuantizer
 {
@@ -105,7 +101,7 @@
 {
     std::string fileName = csvRows[rowIndex].values[2];
 
-    if (!boost::filesystem::exists(fileName))
+    if (!fs::exists(fileName))
     {
         throw armnn::ParseException("File [ " + fileName + "] provided on CSV row " + std::to_string(rowIndex) +
                                     " does not exist.");
diff --git a/src/armnnQuantizer/test/QuantizationDataSetTests.cpp b/src/armnnQuantizer/test/QuantizationDataSetTests.cpp
index 2b46aae..9e71f68 100644
--- a/src/armnnQuantizer/test/QuantizationDataSetTests.cpp
+++ b/src/armnnQuantizer/test/QuantizationDataSetTests.cpp
@@ -6,18 +6,14 @@
 #include <boost/test/unit_test.hpp>
 
 #include "../QuantizationDataSet.hpp"
+
+#include <armnn/Optional.hpp>
+#include <Filesystem.hpp>
 #include <iostream>
 #include <fstream>
 #include <vector>
 #include <map>
 
-#define BOOST_FILESYSTEM_NO_DEPRECATED
-
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/filesystem/path.hpp>
-#include <boost/optional/optional.hpp>
-
 
 using namespace armnnQuantizer;
 
@@ -36,20 +32,20 @@
 
     std::string CreateTempCsvFile(std::map<int, std::vector<float>> csvData)
     {
-        boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
-        boost::filesystem::path p{fileDir / boost::filesystem::unique_path("%%%%-%%%%-%%%%.csv")};
+        fs::path fileDir = fs::temp_directory_path();
+        fs::path p = armnnUtils::Filesystem::NamedTempFile("Armnn-QuantizationCreateTempCsvFileTest-TempFile.csv");
 
-        boost::filesystem::path tensorInput1{fileDir / boost::filesystem::unique_path("input_0_0.raw")};
-        boost::filesystem::path tensorInput2{fileDir / boost::filesystem::unique_path("input_1_0.raw")};
-        boost::filesystem::path tensorInput3{fileDir / boost::filesystem::unique_path("input_2_0.raw")};
+        fs::path tensorInput1{fileDir / "input_0_0.raw"};
+        fs::path tensorInput2{fileDir / "input_1_0.raw"};
+        fs::path tensorInput3{fileDir / "input_2_0.raw"};
 
         try
         {
-            boost::filesystem::ofstream ofs{p};
+            std::ofstream ofs{p};
 
-            boost::filesystem::ofstream ofs1{tensorInput1};
-            boost::filesystem::ofstream ofs2{tensorInput2};
-            boost::filesystem::ofstream ofs3{tensorInput3};
+            std::ofstream ofs1{tensorInput1};
+            std::ofstream ofs2{tensorInput2};
+            std::ofstream ofs3{tensorInput3};
 
 
             for(auto entry : csvData.at(0))
@@ -95,17 +91,17 @@
         {
             try
             {
-                boost::filesystem::remove(*m_CsvFile);
+                fs::remove(m_CsvFile.value());
             }
             catch (std::exception &e)
             {
-                std::cerr << "Unable to delete file [" << *m_CsvFile << "] : " << e.what() << std::endl;
+                std::cerr << "Unable to delete file [" << m_CsvFile.value() << "] : " << e.what() << std::endl;
                 BOOST_TEST(false);
             }
         }
     }
 
-    boost::optional<boost::filesystem::path> m_CsvFile;
+    armnn::Optional<fs::path> m_CsvFile;
 };
 
 
diff --git a/src/armnnTfLiteParser/CMakeLists.txt b/src/armnnTfLiteParser/CMakeLists.txt
index 97c55a1..d14cb75 100755
--- a/src/armnnTfLiteParser/CMakeLists.txt
+++ b/src/armnnTfLiteParser/CMakeLists.txt
@@ -18,7 +18,7 @@
     target_include_directories(armnnTfLiteParser PRIVATE ../armnnUtils)
     target_include_directories(armnnTfLiteParser SYSTEM PRIVATE "${TF_LITE_SCHEMA_INCLUDE_PATH}")
 
-    target_link_libraries(armnnTfLiteParser ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY})
+    target_link_libraries(armnnTfLiteParser ${Boost_THREAD_LIBRARY})
 
     # If user has explicitly specified flatbuffers lib then use that,
     # otherwise search for it based on FLATBUFFERS_BUILD_DIR
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp
index 7f68199..bad2504 100644
--- a/src/armnnTfLiteParser/TfLiteParser.cpp
+++ b/src/armnnTfLiteParser/TfLiteParser.cpp
@@ -15,6 +15,7 @@
 
 // armnnUtils:
 #include <armnnUtils/Permute.hpp>
+#include <Filesystem.hpp>
 
 #include <ParserHelper.hpp>
 #include <VerificationHelpers.hpp>
@@ -26,7 +27,6 @@
 
 #include <boost/format.hpp>
 #include <boost/numeric/conversion/cast.hpp>
-#include <boost/filesystem.hpp>
 
 #include <fstream>
 #include <algorithm>
@@ -2868,9 +2868,9 @@
         throw InvalidArgumentException(boost::str(boost::format("Invalid (null) file name %1%") %
                                        CHECK_LOCATION().AsString()));
     }
-    boost::system::error_code errorCode;
-    boost::filesystem::path pathToFile(fileName);
-    if (!boost::filesystem::exists(pathToFile, errorCode))
+    std::error_code errorCode;
+    fs::path pathToFile(fileName);
+    if (!fs::exists(pathToFile, errorCode))
     {
         std::string locationString = CHECK_LOCATION().AsString();
         std::string msg = boost::str(boost::format("Cannot find the file (%1%) errorCode: %2% %3%") %
diff --git a/src/armnnTfLiteParser/test/LoadModel.cpp b/src/armnnTfLiteParser/test/LoadModel.cpp
index 9ae3412..9777333 100644
--- a/src/armnnTfLiteParser/test/LoadModel.cpp
+++ b/src/armnnTfLiteParser/test/LoadModel.cpp
@@ -6,6 +6,8 @@
 #include "ParserFlatbuffersFixture.hpp"
 #include "../TfLiteParser.hpp"
 
+#include <Filesystem.hpp>
+
 using armnnTfLiteParser::TfLiteParser;
 using ModelPtr = TfLiteParser::ModelPtr;
 using SubgraphPtr = TfLiteParser::SubgraphPtr;
@@ -196,8 +198,8 @@
 
 BOOST_FIXTURE_TEST_CASE(LoadModelFromFile, LoadModelFixture)
 {
-    using namespace boost::filesystem;
-    std::string fname = unique_path(temp_directory_path() / "%%%%-%%%%-%%%%.tflite").string();
+    using namespace fs;
+    fs::path fname = armnnUtils::Filesystem::NamedTempFile("Armnn-tfLite-LoadModelFromFile-TempFile.csv");
     bool saved = flatbuffers::SaveFile(fname.c_str(),
                                        reinterpret_cast<char *>(m_GraphBinary.data()),
                                        m_GraphBinary.size(), true);
diff --git a/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp b/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
index 56811b5..891e0be 100644
--- a/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
+++ b/src/armnnTfLiteParser/test/ParserFlatbuffersFixture.hpp
@@ -19,7 +19,6 @@
 
 #include <test/TensorHelpers.hpp>
 
-#include <boost/filesystem.hpp>
 #include <boost/format.hpp>
 
 #include "flatbuffers/idl.h"
diff --git a/src/armnnUtils/Filesystem.cpp b/src/armnnUtils/Filesystem.cpp
index 4a2e2ed..ac9a414 100644
--- a/src/armnnUtils/Filesystem.cpp
+++ b/src/armnnUtils/Filesystem.cpp
@@ -5,51 +5,30 @@
 
 #include "Filesystem.hpp"
 
-#if defined(__unix__)
-#include <sys/stat.h>
-#include <stdio.h>
-#elif defined(_MSC_VER)
-#include "WindowsWrapper.hpp"
-#endif
-
 namespace armnnUtils
 {
 namespace Filesystem
 {
 
-long long GetFileSize(const char* path)
+/**
+ * @brief Construct a temporary file name.
+ *
+ * Given a specified file name construct a path to that file in the
+ * system temporary directory. If the file already exists it is deleted. This
+ * could throw filesystem_error exceptions.
+ *
+ * @param fileName the file name required in the temporary directory.
+ * @return path consisting of system temporary directory and file name.
+ */
+fs::path NamedTempFile(const char* fileName)
 {
-#if defined(__ANDROID__)
-    struct stat statusBuffer;
-    if (stat(path, & statusBuffer) != 0)
+    fs::path tmpDir = fs::temp_directory_path();
+    fs::path namedTempFile{tmpDir / fileName};
+    if (fs::exists(namedTempFile))
     {
-        return -1;
+        fs::remove(namedTempFile);
     }
-    return statusBuffer.st_size;
-#elif defined(__unix__)
-    struct stat statusBuffer;
-    if (stat(path, & statusBuffer) != 0)
-    {
-        return -1;
-    }
-    return static_cast<long long>(statusBuffer.st_size);
-#elif defined(_MSC_VER)
-    WIN32_FILE_ATTRIBUTE_DATA attr;
-    if (::GetFileAttributesEx(path, GetFileExInfoStandard, &attr) == 0)
-    {
-        return -1;
-    }
-    return attr.nFileSizeLow;
-#endif
-}
-
-bool Remove(const char* path)
-{
-#if defined(__unix__)
-    return remove(path) == 0;
-#elif defined(_MSC_VER)
-    return ::DeleteFile(path);
-#endif
+    return namedTempFile;
 }
 
 }
diff --git a/src/armnnUtils/Filesystem.hpp b/src/armnnUtils/Filesystem.hpp
index 1b12502..869b0c1 100644
--- a/src/armnnUtils/Filesystem.hpp
+++ b/src/armnnUtils/Filesystem.hpp
@@ -13,9 +13,8 @@
 namespace Filesystem
 {
 
-long long GetFileSize(const char* path);
-
-bool Remove(const char* path);
+/// Returns a path to a file in the system temporary folder. If the file existed it will be deleted.
+fs::path NamedTempFile(const char* fileName);
 
 }
 }
diff --git a/src/armnnUtils/ModelAccuracyChecker.cpp b/src/armnnUtils/ModelAccuracyChecker.cpp
index d197dc8..418737c 100644
--- a/src/armnnUtils/ModelAccuracyChecker.cpp
+++ b/src/armnnUtils/ModelAccuracyChecker.cpp
@@ -7,7 +7,6 @@
 
 #include <armnn/Logging.hpp>
 
-#include <boost/filesystem.hpp>
 #include <map>
 #include <vector>
 
diff --git a/src/backends/backendsCommon/DynamicBackendUtils.cpp b/src/backends/backendsCommon/DynamicBackendUtils.cpp
index 5b675ba..1abea11 100644
--- a/src/backends/backendsCommon/DynamicBackendUtils.cpp
+++ b/src/backends/backendsCommon/DynamicBackendUtils.cpp
@@ -6,8 +6,7 @@
 #include <armnn/Logging.hpp>
 #include <backendsCommon/DynamicBackendUtils.hpp>
 #include "armnn/utility/StringUtils.hpp"
-
-#include <boost/filesystem.hpp>
+#include <Filesystem.hpp>
 
 #include <regex>
 
@@ -149,21 +148,21 @@
         return false;
     }
 
-    boost::filesystem::path boostPath(path);
+    fs::path fsPath(path);
 
-    if (!boost::filesystem::exists(boostPath))
+    if (!fs::exists(fsPath))
     {
         ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" does not exist";
         return false;
     }
 
-    if (!boost::filesystem::is_directory(boostPath))
+    if (!fs::is_directory(fsPath))
     {
         ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" is not a directory";
         return false;
     }
 
-    if (!boostPath.is_absolute())
+    if (!fsPath.is_absolute())
     {
         ARMNN_LOG(warning) << "WARNING: The given backend path \"" << path << "\" is not absolute";
         return false;
@@ -179,7 +178,7 @@
 
     for (const std::string& backendPath : backendPaths)
     {
-        using namespace boost::filesystem;
+        using namespace fs;
 
         // Check if the path is valid. In case of error, IsValidPath will log an error message
         if (!IsPathValid(backendPath))
diff --git a/src/backends/backendsCommon/test/DynamicBackendTests.hpp b/src/backends/backendsCommon/test/DynamicBackendTests.hpp
index a2a6df0..79f208d 100644
--- a/src/backends/backendsCommon/test/DynamicBackendTests.hpp
+++ b/src/backends/backendsCommon/test/DynamicBackendTests.hpp
@@ -11,6 +11,7 @@
 #include <armnn/utility/PolymorphicDowncast.hpp>
 #include <backendsCommon/CpuTensorHandle.hpp>
 #include <backendsCommon/DynamicBackendUtils.hpp>
+#include <Filesystem.hpp>
 #include <reference/workloads/RefConvolution2dWorkload.hpp>
 #include <Runtime.hpp>
 
@@ -18,7 +19,6 @@
 #include <memory>
 
 #include <boost/test/unit_test.hpp>
-#include <boost/filesystem.hpp>
 #include <boost/dll.hpp>
 
 static std::string g_TestBaseDir                            = "src/backends/backendsCommon/test/";
@@ -104,9 +104,9 @@
 
 std::string GetBasePath(const std::string& basePath)
 {
-    using namespace boost::filesystem;
+    using namespace fs;
 
-    path programLocation = boost::dll::program_location().parent_path();
+    path programLocation = boost::dll::program_location().parent_path().c_str();
     path sharedObjectPath = programLocation.append(basePath);
     BOOST_CHECK_MESSAGE(exists(sharedObjectPath), "Base path for shared objects does not exist: " +
                                                    sharedObjectPath.string());
@@ -125,7 +125,7 @@
 
 std::string GetTestSubDirectory(const std::string& subdir)
 {
-    using namespace boost::filesystem;
+    using namespace fs;
 
     std::string testDynamicBackendsBaseDir = GetTestDirectoryBasePath();
     path testDynamicBackendsBasePath(testDynamicBackendsBaseDir);
@@ -137,7 +137,7 @@
 
 std::string GetTestSubDirectory(const std::string& basePath, const std::string& subdir)
 {
-    using namespace boost::filesystem;
+    using namespace fs;
 
     path testDynamicBackendsBasePath(basePath);
     path testDynamicBackendsSubDir = testDynamicBackendsBasePath.append(subdir);
@@ -148,7 +148,7 @@
 
 std::string GetTestFilePath(const std::string& directory, const std::string& fileName)
 {
-    using namespace boost::filesystem;
+    using namespace fs;
 
     path directoryPath(directory);
     path fileNamePath = directoryPath.append(fileName);
@@ -346,7 +346,7 @@
     std::string testSubDirectory = GetTestSubDirectory(g_TestDynamicBackendSubDir);
 
     // We expect this path to exists so we can load a valid dynamic backend.
-    BOOST_CHECK_MESSAGE(boost::filesystem::exists(testSubDirectory),
+    BOOST_CHECK_MESSAGE(fs::exists(testSubDirectory),
                        "Base path for shared objects does not exist: " + testSubDirectory);
 
     std::string sharedObjectFilePath = GetTestFilePath(testSubDirectory, g_TestValidTestDynamicBackendFileName);
@@ -560,7 +560,7 @@
 void GetBackendPathsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // The test covers four directories:
     // <unit test path>/src/backends/backendsCommon/test/
@@ -640,7 +640,7 @@
 void GetBackendPathsOverrideTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     std::string subDir1 = GetTestSubDirectory(g_TestDynamicBackendsSubDir1);
     std::string subDir4 = GetTestSubDirectory(g_TestDynamicBackendsSubDir4);
@@ -661,7 +661,7 @@
 void GetSharedObjectsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // The test covers four directories:
     // <unit test path>/src/backends/backendsCommon/test/
@@ -752,7 +752,7 @@
 void CreateDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // The test covers four directories:
     // <unit test path>/src/backends/backendsCommon/test/
@@ -839,7 +839,7 @@
 void CreateDynamicBackendsMixedTypesTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     std::string testDynamicBackendsSubDir5 = GetTestSubDirectory(g_TestDynamicBackendsSubDir5);
     std::string testDynamicBackendsSubDir6 = GetTestSubDirectory(g_TestDynamicBackendsSubDir6);
@@ -873,7 +873,7 @@
 void RegisterSingleDynamicBackendTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Register one valid dynamic backend
 
@@ -920,7 +920,7 @@
 void RegisterMultipleDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Register many valid dynamic backends
 
@@ -996,7 +996,7 @@
 void RegisterMultipleInvalidDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Try to register many invalid dynamic backends
 
@@ -1056,7 +1056,7 @@
 void RegisterMixedDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // The test covers five directories:
     // <unit test path>/src/backends/backendsCommon/test/
@@ -1226,7 +1226,7 @@
 void RuntimeDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Swapping the backend registry storage for testing
     TestBackendRegistry testBackendRegistry;
@@ -1267,7 +1267,7 @@
 void RuntimeDuplicateDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Swapping the backend registry storage for testing
     TestBackendRegistry testBackendRegistry;
@@ -1308,7 +1308,7 @@
 void RuntimeInvalidDynamicBackendsTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Swapping the backend registry storage for testing
     TestBackendRegistry testBackendRegistry;
@@ -1357,7 +1357,7 @@
 void CreateReferenceDynamicBackendTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
+    using namespace fs;
 
     // Swapping the backend registry storage for testing
     TestBackendRegistry testBackendRegistry;
@@ -1520,7 +1520,6 @@
 void SampleDynamicBackendEndToEndTestImpl()
 {
     using namespace armnn;
-    using namespace boost::filesystem;
     // Create runtime in which test will run
     IRuntime::CreationOptions options;
     IRuntimePtr runtime(IRuntime::Create(options));
diff --git a/src/dynamic/README.md b/src/dynamic/README.md
index 36a238a..39ed188 100644
--- a/src/dynamic/README.md
+++ b/src/dynamic/README.md
@@ -31,7 +31,6 @@
 cd build
 cmake -DBOOST_ROOT=${BOOST_PATH} \
       -DBoost_SYSTEM_LIBRARY=${BOOST_PATH}/lib/libboost_system.a \
-      -DBoost_FILESYSTEM_LIBRARY=${BOOST_PATH}/lib/libboost_filesystem.a \
       -DARMNN_PATH=${ARMNN_PATH}/libarmnn.so ..
 ```
 
diff --git a/src/dynamic/sample/CMakeLists.txt b/src/dynamic/sample/CMakeLists.txt
index 452ca94..a6c2906 100644
--- a/src/dynamic/sample/CMakeLists.txt
+++ b/src/dynamic/sample/CMakeLists.txt
@@ -38,5 +38,5 @@
 target_include_directories(Arm_SampleDynamic_backend PRIVATE ${PROJECT_SOURCE_DIR}/../../../src/profiling)
 target_include_directories(Arm_SampleDynamic_backend PRIVATE ${PROJECT_SOURCE_DIR}/../../../profiling/common/include)
 target_include_directories(Arm_SampleDynamic_backend PRIVATE ${Boost_INCLUDE_DIRS})
-target_link_libraries(Arm_SampleDynamic_backend ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
+target_link_libraries(Arm_SampleDynamic_backend ${Boost_SYSTEM_LIBRARY})
 target_link_libraries(Arm_SampleDynamic_backend ${ARMNN_PATH})
diff --git a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
index e968d67..79da17a 100644
--- a/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
+++ b/src/profiling/test/FileOnlyProfilingDecoratorTests.cpp
@@ -11,7 +11,6 @@
 #include <Runtime.hpp>
 #include "TestTimelinePacketHandler.hpp"
 
-#include <boost/filesystem.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/test/unit_test.hpp>
 
@@ -37,18 +36,6 @@
 
 BOOST_AUTO_TEST_SUITE(FileOnlyProfilingDecoratorTests)
 
-std::string UniqueFileName()
-{
-    std::time_t t = std::time(nullptr);
-    char mbstr[100];
-    std::strftime(mbstr, sizeof(mbstr), "%Y_%m_%d_%H_%M_%S_", std::localtime(&t));
-    std::stringstream ss;
-    ss << mbstr;
-    ss << t;
-    ss << ".bin";
-    return ss.str();
-}
-
 BOOST_AUTO_TEST_CASE(TestFileOnlyProfiling)
 {
     // This test requires at least one backend registry to be enabled
@@ -58,10 +45,8 @@
         return;
     }
 
-    // Create a temporary file name.
-    fs::path tempPath = fs::temp_directory_path();
-    fs::path tempFile = UniqueFileName();
-    tempPath          = tempPath / tempFile;
+    // Enable m_FileOnly but also provide ILocalPacketHandler which should consume the packets.
+    // This won't dump anything to file.
     armnn::Runtime::CreationOptions creationOptions;
     creationOptions.m_ProfilingOptions.m_EnableProfiling     = true;
     creationOptions.m_ProfilingOptions.m_FileOnly            = true;
@@ -180,9 +165,7 @@
     }
 
     // Create a temporary file name.
-    fs::path tempPath = fs::temp_directory_path();
-    fs::path tempFile = UniqueFileName();
-    tempPath          = tempPath / tempFile;
+    fs::path tempPath = armnnUtils::Filesystem::NamedTempFile("DumpOutgoingValidFileEndToEnd_CaptureFile.txt");
     armnn::Runtime::CreationOptions options;
     options.m_ProfilingOptions.m_EnableProfiling     = true;
     options.m_ProfilingOptions.m_FileOnly            = true;
@@ -195,7 +178,7 @@
     options.m_ProfilingOptions.m_LocalPacketHandlers.push_back(localPacketHandlerPtr);
 
     // Make sure the file does not exist at this point
-    BOOST_CHECK(armnnUtils::Filesystem::GetFileSize(tempPath.string().c_str()) == -1);
+    BOOST_CHECK(!fs::exists(tempPath));
 
     armnn::Runtime runtime(options);
     // ensure the GUID generator is reset to zero
@@ -255,12 +238,12 @@
     GetProfilingService(&runtime).ResetExternalProfilingOptions(options.m_ProfilingOptions, true);
 
     // The output file size should be greater than 0.
-    BOOST_CHECK(armnnUtils::Filesystem::GetFileSize(tempPath.string().c_str()) > 0);
+    BOOST_CHECK(fs::file_size(tempPath) > 0);
 
     // NOTE: would be an interesting exercise to take this file and decode it
 
     // Delete the tmp file.
-    BOOST_CHECK(armnnUtils::Filesystem::Remove(tempPath.string().c_str()));
+    BOOST_CHECK(fs::remove(tempPath));
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
index c368678..6784dda 100644
--- a/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
+++ b/src/profiling/test/ProfilingConnectionDumpToFileDecoratorTests.cpp
@@ -4,13 +4,13 @@
 //
 
 #include "../ProfilingConnectionDumpToFileDecorator.hpp"
+#include <Filesystem.hpp>
 #include <Runtime.hpp>
 #include <armnn/utility/IgnoreUnused.hpp>
 
 #include <fstream>
 #include <sstream>
 
-#include <boost/filesystem.hpp>
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/test/unit_test.hpp>
 
@@ -96,8 +96,7 @@
 
 BOOST_AUTO_TEST_CASE(DumpIncomingValidFile)
 {
-    boost::filesystem::path fileName =
-        boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
+    fs::path fileName = armnnUtils::Filesystem::NamedTempFile("Armnn-DumpIncomingValidFileTest-TempFile");
 
     armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
     options.m_IncomingCaptureFile = fileName.string();
@@ -118,6 +117,7 @@
     constexpr unsigned int bytesToSkip = 2u * sizeof(uint32_t); // skip header and packet length
     int diff = std::strncmp(data.data() + bytesToSkip, packetData, g_DataLength);
     BOOST_CHECK(diff == 0);
+    fs::remove(fileName);
 }
 
 BOOST_AUTO_TEST_CASE(DumpOutgoingInvalidFile)
@@ -144,8 +144,7 @@
 
 BOOST_AUTO_TEST_CASE(DumpOutgoingValidFile)
 {
-    boost::filesystem::path fileName =
-        boost::filesystem::temp_directory_path() / boost::filesystem::unique_path();
+    fs::path fileName = armnnUtils::Filesystem::NamedTempFile("Armnn-DumpOutgoingValidFileTest-TempFile");
 
     armnn::Runtime::CreationOptions::ExternalProfilingOptions options;
     options.m_IncomingCaptureFile = "";
@@ -164,6 +163,7 @@
     // check if the data read back from the dump file matches the original
     int diff = std::strncmp(data.data(), g_Data.data(), g_DataLength);
     BOOST_CHECK(diff == 0);
+    fs::remove(fileName);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/timelineDecoder/CMakeLists.txt b/src/timelineDecoder/CMakeLists.txt
index 4702577..695aa5c 100644
--- a/src/timelineDecoder/CMakeLists.txt
+++ b/src/timelineDecoder/CMakeLists.txt
@@ -17,7 +17,8 @@
         TimelineDirectoryCaptureCommandHandler.hpp)
 
     include_directories(${PROJECT_SOURCE_DIR}/src/profiling
-                        ${PROJECT_SOURCE_DIR}/profiling/common/include)
+                        ${PROJECT_SOURCE_DIR}/profiling/common/include
+                        ${PROJECT_SOURCE_DIR}/src/armnnUtils)
 
     if(BUILD_UNIT_TESTS)
       target_include_directories(UnitTests PRIVATE ${PROJECT_SOURCE_DIR}/src/timelineDecoder)
diff --git a/src/timelineDecoder/JSONTimelineDecoder.cpp b/src/timelineDecoder/JSONTimelineDecoder.cpp
index 84472d8..a039214 100644
--- a/src/timelineDecoder/JSONTimelineDecoder.cpp
+++ b/src/timelineDecoder/JSONTimelineDecoder.cpp
@@ -8,7 +8,6 @@
 
 #include <string>
 #include <fstream>
-#include <boost/filesystem/fstream.hpp>
 
 namespace armnn
 {
@@ -246,7 +245,7 @@
 void JSONTimelineDecoder::PrintJSON(JSONTimelineDecoder::JSONEntity& rootEntity)
 {
     std::string jsonString = GetJSONString(rootEntity);
-    boost::filesystem::ofstream ofs{this->outputJSONFile};
+    std::ofstream ofs{this->outputJSONFile};
     ofs << jsonString;
     ofs.close();
 }
diff --git a/src/timelineDecoder/JSONTimelineDecoder.hpp b/src/timelineDecoder/JSONTimelineDecoder.hpp
index 38d6983..4d6fcec 100644
--- a/src/timelineDecoder/JSONTimelineDecoder.hpp
+++ b/src/timelineDecoder/JSONTimelineDecoder.hpp
@@ -7,10 +7,9 @@
 
 #include <armnn/profiling/ITimelineDecoder.hpp>
 
+#include <Filesystem.hpp>
 #include <map>
 #include <vector>
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem.hpp>
 
 namespace armnn
 {
@@ -65,8 +64,7 @@
 
 private:
     Model m_Model;
-    boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
-    boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
+    fs::path p = armnnUtils::Filesystem::NamedTempFile("output.json");
 
     std::string outputJSONFile = p.string();
 
diff --git a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
index 2d78564..8241419 100644
--- a/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
+++ b/src/timelineDecoder/tests/JSONTimelineDecoderTests.cpp
@@ -6,12 +6,12 @@
 #include <JSONTimelineDecoder.hpp>
 #include <TimelineCaptureCommandHandler.hpp>
 #include <TimelineDecoder.hpp>
+#include <Filesystem.hpp>
 
 #include <boost/test/test_tools.hpp>
 #include <boost/test/unit_test_suite.hpp>
 
 #include <fstream>
-#include <boost/filesystem.hpp>
 
 BOOST_AUTO_TEST_SUITE(JSONTimelineDecoderTests)
 
@@ -797,10 +797,8 @@
 
     timelineDecoder.PrintJSON(rootEntity);
 
-    boost::filesystem::ifstream inFile;
-    boost::filesystem::path fileDir = boost::filesystem::temp_directory_path();
-    boost::filesystem::path p{fileDir / boost::filesystem::unique_path("output.json")};
-
+    fs::ifstream inFile;
+    fs::path p{fs::temp_directory_path() / "output.json"};
     inFile.open(p); //open the input file
 
     std::stringstream strStream;