From 093a0b79a06a1689e4b7f08b507dbea307705991 Mon Sep 17 00:00:00 2001 From: Louis Poirier Date: Sun, 12 May 2024 22:14:04 +0200 Subject: [PATCH] feat: implement safe concurrent calls with asynchronous operations. --- CHANGELOG.md | 2 ++ scripts/RedFileSystem/Test/FileSystemStorageTest.reds | 6 ++++++ src/FileSystemStorage.cpp | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3541715..9d52c9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- issue when using files listed with method `GetFiles`. ------------------------ diff --git a/scripts/RedFileSystem/Test/FileSystemStorageTest.reds b/scripts/RedFileSystem/Test/FileSystemStorageTest.reds index 6caaa62..1ed2b60 100644 --- a/scripts/RedFileSystem/Test/FileSystemStorageTest.reds +++ b/scripts/RedFileSystem/Test/FileSystemStorageTest.reds @@ -1,6 +1,8 @@ import RedFileSystem.* public class FileSystemStorageTest extends BaseTest { + private let STORAGE_PATH: String = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Cyberpunk 2077\\red4ext\\plugins\\RedFileSystem\\storages\\Test\\"; + private let m_storage: ref; public func Create() { @@ -56,10 +58,14 @@ public class FileSystemStorageTest extends BaseTest { while i < 4 { this.ExpectString(s"files[\(i)] == 'dummy\(i).txt'", files[i].GetFilename(), s"dummy\(i).txt"); + this.ExpectString(s"files[\(i)] == '\\dummy\(i).txt'", files[i].GetAbsolutePath(), s"\(this.STORAGE_PATH)dummy\(i).txt"); i += 1; } this.ExpectString("files[4] == 'test.json'", files[4].GetFilename(), "test.json"); + this.ExpectString("files[4] == '\\test.json'", files[4].GetAbsolutePath(), s"\(this.STORAGE_PATH)test.json"); + this.ExpectString("files[5] == 'test.txt'", files[5].GetFilename(), "test.txt"); + this.ExpectString("files[5] == '\\test.txt'", files[5].GetAbsolutePath(), s"\(this.STORAGE_PATH)test.txt"); } } diff --git a/src/FileSystemStorage.cpp b/src/FileSystemStorage.cpp index fd5e908..a51a507 100644 --- a/src/FileSystemStorage.cpp +++ b/src/FileSystemStorage.cpp @@ -80,7 +80,9 @@ Red::DynArray> FileSystemStorage::get_files() const { for (const auto& entry : entries) { if (entry.is_regular_file()) { - auto file = Red::MakeHandle(entry.path().filename(), storage_path); + auto file_name = entry.path().filename(); + auto file_path = storage_path / file_name; + auto file = Red::MakeHandle(file_name, file_path); files.PushBack(file); }