From bdb08ab644959cd077ea77b41fa86a1bac569afd Mon Sep 17 00:00:00 2001 From: Aryan Salmanpour Date: Wed, 8 May 2024 14:45:32 -0400 Subject: [PATCH] Fix compilation issues on distro without std::filesystem (#348) --- samples/videoDecodeBatch/videodecodebatch.cpp | 11 +++++++++++ src/rocdecode/vaapi/vaapi_videodecoder.cpp | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/samples/videoDecodeBatch/videodecodebatch.cpp b/samples/videoDecodeBatch/videodecodebatch.cpp index 0e46340ef0..702199010c 100644 --- a/samples/videoDecodeBatch/videodecodebatch.cpp +++ b/samples/videoDecodeBatch/videodecodebatch.cpp @@ -203,10 +203,17 @@ void ParseCommandLine(std::string &input_folder_path, std::string &output_folder ShowHelpAndExit("-o"); } output_folder_path = argv[i]; +#if __cplusplus >= 201703L && __has_include() if (std::filesystem::is_directory(output_folder_path)) { std::filesystem::remove_all(output_folder_path); } std::filesystem::create_directory(output_folder_path); +#else + if (std::experimental::filesystem::is_directory(output_folder_path)) { + std::experimental::filesystem::remove_all(output_folder_path); + } + std::experimental::filesystem::create_directory(output_folder_path); +#endif b_dump_output_frames = true; continue; } @@ -233,7 +240,11 @@ int main(int argc, char **argv) { ParseCommandLine(input_folder_path, output_folder_path, device_id, n_thread, b_dump_output_frames, mem_type, argc, argv); try { +#if __cplusplus >= 201703L && __has_include() for (const auto& entry : std::filesystem::directory_iterator(input_folder_path)) { +#else + for (const auto& entry : std::experimental::filesystem::directory_iterator(input_folder_path)) { +#endif input_file_names.push_back(entry.path()); num_files++; } diff --git a/src/rocdecode/vaapi/vaapi_videodecoder.cpp b/src/rocdecode/vaapi/vaapi_videodecoder.cpp index 1e195e7060..335fe03bf1 100644 --- a/src/rocdecode/vaapi/vaapi_videodecoder.cpp +++ b/src/rocdecode/vaapi/vaapi_videodecoder.cpp @@ -435,7 +435,11 @@ void VaapiVideoDecoder::GetVisibleDevices(std::vector& visible_devices_veto void VaapiVideoDecoder::GetCurrentComputePartition(std::vector ¤t_compute_partitions) { std::string search_path = "/sys/devices/"; std::string partition_file = "current_compute_partition"; +#if __cplusplus >= 201703L && __has_include() for (const auto& entry : std::filesystem::recursive_directory_iterator(search_path)) { +#else + for (const auto& entry : std::experimental::filesystem::recursive_directory_iterator(search_path)) { +#endif if (entry.path().filename() == partition_file) { std::ifstream file(entry.path()); if (file.is_open()) {