Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Colm Donelan | a98e79a | 2022-12-06 21:32:29 +0000 | [diff] [blame] | 2 | // Copyright © 2020,2022 Arm Ltd and Contributors. All rights reserved. |
Rob Hughes | bdee426 | 2020-01-07 17:05:24 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
Jim Flynn | 870b96c | 2022-03-25 21:24:56 +0000 | [diff] [blame] | 7 | #if !defined(ARMNN_DISABLE_FILESYSTEM) |
Rob Hughes | bdee426 | 2020-01-07 17:05:24 +0000 | [diff] [blame] | 8 | |
Rob Hughes | 35c31c0 | 2020-08-17 15:47:20 +0100 | [diff] [blame] | 9 | #if defined(_MSC_VER) |
| 10 | // ghc includes Windows.h directly, bringing in macros that we don't want (e.g. min/max). |
| 11 | // By including Windows.h ourselves first (with appropriate options), we prevent this. |
| 12 | #include <common/include/WindowsWrapper.hpp> |
| 13 | #endif |
Jim Flynn | c963110 | 2020-06-24 11:11:20 +0100 | [diff] [blame] | 14 | #include <ghc/filesystem.hpp> |
Colm Donelan | a98e79a | 2022-12-06 21:32:29 +0000 | [diff] [blame] | 15 | #include <string> |
| 16 | |
Jim Flynn | c963110 | 2020-06-24 11:11:20 +0100 | [diff] [blame] | 17 | namespace fs = ghc::filesystem; |
| 18 | |
Rob Hughes | bdee426 | 2020-01-07 17:05:24 +0000 | [diff] [blame] | 19 | namespace armnnUtils |
| 20 | { |
| 21 | namespace Filesystem |
| 22 | { |
| 23 | |
Keith Davis | 15f9c68 | 2022-10-14 15:50:33 +0100 | [diff] [blame] | 24 | using FileContents = std::string; |
| 25 | |
Francis Murtagh | 532a29d | 2020-06-29 11:50:01 +0100 | [diff] [blame] | 26 | /// Returns a path to a file in the system temporary folder. If the file existed it will be deleted. |
| 27 | fs::path NamedTempFile(const char* fileName); |
Rob Hughes | bdee426 | 2020-01-07 17:05:24 +0000 | [diff] [blame] | 28 | |
Keith Davis | 15f9c68 | 2022-10-14 15:50:33 +0100 | [diff] [blame] | 29 | /// Returns full path to temporary folder |
| 30 | std::string CreateDirectory(std::string sPath); |
| 31 | |
Colm Donelan | b5ea589 | 2023-02-10 15:19:46 +0000 | [diff] [blame] | 32 | FileContents ReadFileContentsIntoString(const std::string& path); |
| 33 | |
| 34 | void RemoveDirectoryAndContents(const std::string& path); |
Keith Davis | 15f9c68 | 2022-10-14 15:50:33 +0100 | [diff] [blame] | 35 | |
Jim Flynn | 870b96c | 2022-03-25 21:24:56 +0000 | [diff] [blame] | 36 | } // namespace armnnUtils |
| 37 | } // namespace Filesystem |
| 38 | |
| 39 | #endif // !defined(ARMNN_DISABLE_FILESYSTEM) |