Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/arozx/voxels into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
arozx committed Feb 22, 2025
2 parents c6f941f + ce00f2b commit ba4353c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sandbox/assets/scripts/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ engine.trace("Creating build directory: " .. buildDir)
if not engine.exists(buildDir) then
local success = engine.mkdir(buildDir)
if not success then
engine.error(string.format("Failed to create directory" .. buildDir))
engine.error(string.format("Failed to create directory: %s", buildDir))
return
end
end
Expand Down Expand Up @@ -49,6 +49,7 @@ local function copyScript(name)
local dest, destErr = io.open(destPath, "wb")
if not dest then
engine.warn(string.format("Failed to create destination file" .. destPath .. ": " .. destErr))

closeFiles(source)
return false
end
Expand Down
12 changes: 11 additions & 1 deletion src/Core/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ namespace Engine {
return std::filesystem::create_directory(sanitizedPath);
}
static bool WriteFile(const std::string& filepath, const std::string& content) {
constexpr size_t MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB limit
if (content.size() > MAX_FILE_SIZE) {
LOG_ERROR("Content size exceeds limit: ", content.size(), " > ", MAX_FILE_SIZE);
return false;
}
std::string path = SantizePath(filepath);
std::ofstream file(path);
if (!file.is_open()) {
LOG_ERROR("Failed to open file: ", path);
LOG_ERROR("Failed to open file '", path, "': ", std::strerror(errno));
return false;
}
file << content;
if (file.fail()) {
LOG_ERROR("Failed to write to file '", path, "': ", std::strerror(errno));
file.close();
return false;
}
file.close();
return true;
}
Expand Down

0 comments on commit ba4353c

Please sign in to comment.