diff options
Diffstat (limited to 'src/armnnUtils/Filesystem.cpp')
-rw-r--r-- | src/armnnUtils/Filesystem.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/armnnUtils/Filesystem.cpp b/src/armnnUtils/Filesystem.cpp new file mode 100644 index 0000000000..08c447b3f6 --- /dev/null +++ b/src/armnnUtils/Filesystem.cpp @@ -0,0 +1,50 @@ +// +// Copyright © 2020 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include "Filesystem.hpp" + +#if defined(__unix__) +#include <sys/stat.h> +#include <stdio.h> +#elif defined(_MSC_VER) +#define WIN32_LEAN_AND_MEAN +#include <Windows.h> +#endif + +namespace armnnUtils +{ +namespace Filesystem +{ + +long GetFileSize(const char* path) +{ +#if defined(__unix__) + struct stat statusBuffer; + if (stat(path, & statusBuffer) != 0) + { + return -1; + } + return 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 +} + +} +} |