Skip to content

Commit

Permalink
feat: implement safe concurrent calls with asynchronous operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
poirierlouis committed May 12, 2024
1 parent 18fdace commit 093a0b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

------------------------

Expand Down
6 changes: 6 additions & 0 deletions scripts/RedFileSystem/Test/FileSystemStorageTest.reds
Original file line number Diff line number Diff line change
@@ -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<FileSystemStorage>;
public func Create() {
Expand Down Expand Up @@ -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)] == '<path>\\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] == '<path>\\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] == '<path>\\test.txt'", files[5].GetAbsolutePath(), s"\(this.STORAGE_PATH)test.txt");
}
}
4 changes: 3 additions & 1 deletion src/FileSystemStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Red::DynArray<Red::Handle<File>> FileSystemStorage::get_files() const {

for (const auto& entry : entries) {
if (entry.is_regular_file()) {
auto file = Red::MakeHandle<File>(entry.path().filename(), storage_path);
auto file_name = entry.path().filename();
auto file_path = storage_path / file_name;
auto file = Red::MakeHandle<File>(file_name, file_path);

files.PushBack(file);
}
Expand Down

0 comments on commit 093a0b7

Please sign in to comment.