2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2023-10-10 22:49:54 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/utilities/directory.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2023-10-10 22:49:54 +08:00
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/windows/windows_wrapper.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-10-21 18:58:50 +08:00
|
|
|
#include <direct.h>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-10-21 18:58:50 +08:00
|
|
|
namespace NEO::Directory {
|
|
|
|
|
|
|
|
std::vector<std::string> getFiles(const std::string &path) {
|
2017-12-21 07:45:38 +08:00
|
|
|
std::vector<std::string> files;
|
|
|
|
std::string newPath;
|
|
|
|
|
|
|
|
WIN32_FIND_DATAA ffd;
|
|
|
|
HANDLE hFind = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
if (path.c_str()[path.size() - 1] == '/') {
|
|
|
|
return files;
|
|
|
|
} else {
|
|
|
|
newPath = path + "/*";
|
|
|
|
}
|
|
|
|
|
|
|
|
hFind = FindFirstFileA(newPath.c_str(), &ffd);
|
|
|
|
|
|
|
|
if (INVALID_HANDLE_VALUE == hFind) {
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
|
|
|
files.push_back(path + "/" + ffd.cFileName);
|
|
|
|
} while (FindNextFileA(hFind, &ffd) != 0);
|
|
|
|
|
|
|
|
FindClose(hFind);
|
|
|
|
return files;
|
|
|
|
}
|
2022-10-21 18:58:50 +08:00
|
|
|
|
|
|
|
void createDirectory(const std::string &path) {
|
2023-10-10 22:49:54 +08:00
|
|
|
[[maybe_unused]] auto status = _mkdir(path.c_str());
|
2023-11-02 18:01:18 +08:00
|
|
|
DEBUG_BREAK_IF(status != 0 && errno != EEXIST);
|
2022-10-21 18:58:50 +08:00
|
|
|
}
|
|
|
|
}; // namespace NEO::Directory
|