Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor AssetCull for modern C++ #421

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DevGeniusCode
Copy link

This is an attempt to understand how it is desirable to improve the code of the tools that do not directly depend on the engine code, or at least wrapper code that does not touch the engine code itself.

A proposal is also made for documenting and log the changes as can be seen in the file.

These changes are not compatible with VC6.


This PR updates the assetcull tool to use modern C++ features, improving both performance and code readability. The key changes include:

  • Replaced findfirst and findnext with std::filesystem: Transitioned to a more modern, cross-platform way of handling directory iteration, making the code more maintainable and compatible with different operating systems.

  • Switched from fopen to std::ifstream: Improved file reading by using std::ifstream, which is safer and more efficient for binary file comparisons.

  • Changed from fixed-size buffers (16384 bytes) to iterators: Refactored the code to use iterators instead of hard-coded buffers, leading to cleaner and more efficient file comparison.

  • Permissions handling with std::filesystem::permissions: Enhanced the code to ensure proper file permissions before attempting deletion, preventing errors related to file access restrictions.

  • Code readability improvements: Made the code easier to read and maintain by using std::string and range-based for loops where appropriate.

Bug Fixes:

  • Ensured proper file permissions before file deletion to prevent access errors.

Other Improvements:

  • Cleaned up batch file creation logic to improve formatting and file path handling.

@DevGeniusCode DevGeniusCode added Enhancement Is new feature or request OngoingDiscussion Requires further discussion Tools Affects Tools only 🚫Do Not Merge labels Mar 14, 2025
@xezon xezon marked this pull request as draft March 14, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚫Do Not Merge Enhancement Is new feature or request OngoingDiscussion Requires further discussion Tools Affects Tools only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant