aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp39
1 files changed, 35 insertions, 4 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index 0f74b44c4..50a82c99b 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -621,12 +621,43 @@ ScanFile(std::filesystem::path Path, const uint64_t ChunkSize, std::function<voi
ProcessFunc(ReadBuffer.data(), dwBytesRead);
}
-
- return true;
#else
- ZEN_ERROR("ScanFile() is not implemented on this platform");
- return false;
+ int Fd = open(Path.c_str(), O_RDONLY);
+ if (Fd < 0)
+ {
+ return false;
+ }
+
+ bool Success = true;
+
+ void* Buffer = malloc(ChunkSize);
+ while (true)
+ {
+ int BytesRead = read(Fd, Buffer, ChunkSize);
+ if (BytesRead < 0)
+ {
+ Success = false;
+ break;
+ }
+
+ if (BytesRead == 0)
+ {
+ break;
+ }
+
+ ProcessFunc(Buffer, BytesRead);
+ }
+
+ free(Buffer);
+ close(Fd);
+
+ if (!Success)
+ {
+ ThrowLastError("file scan failed");
+ }
#endif // ZEN_PLATFORM_WINDOWS
+
+ return true;
}
std::string