Rework config manager to use VEX API instead of std::fstream#41
Open
Rework config manager to use VEX API instead of std::fstream#41
Conversation
Co-authored-by: Voidless7125 <167136334+Voidless7125@users.noreply.github.com>
Co-authored-by: Voidless7125 <167136334+Voidless7125@users.noreply.github.com>
Co-authored-by: Voidless7125 <167136334+Voidless7125@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Rework on config manager cpp
Rework config manager to use VEX API instead of std::fstream
Jun 4, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR reworks the file I/O operations in the configuration manager and related modules to use the VEX Brain.SDcard API instead of the traditional std::fstream library. Key changes include the integration of VEX API calls in logging, GIF player, and configuration functions, as well as the addition of helper functions to support file operations with the VEX hardware.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/display/logging.cpp | Replaced std::ofstream with VEX API for log file appending and improved SD card error handling. |
| src/display/gifplayer/gifplayer.cpp | Updated file reading operations to use VEX SD card API and added validations for card status and file existence. |
| src/config/extern/sdcard.cpp | Converted config file operations to use VEX API, with modifications to file content construction. |
| src/config/extern/configManager.cpp | Added VEX API helper functions for reading, writing, and checking file existence/size. |
| include/vex.h | Removed unused header inclusion in favor of modern C++ headers. |
| include/config/extern/configManager.h | Declared new helper functions for file I/O using VEX API. |
Comments suppressed due to low confidence (1)
src/config/extern/sdcard.cpp:78
- The version string concatenation is not appended to the 'configContent' variable, so the version information may be missing from the final configuration file. Consider appending it using 'configContent += "VERSION=)" + Version + "\n";' to ensure it is included.
VERSION=)" + Version + "\n";
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR completely reworks the config manager's file operations to use the VEX Brain.SDcard API instead of standard C++ file streams, as requested in the issue.
Changes Made
VEX API Integration
Replaced all
std::ifstream/std::ofstreamoperations with VEX Brain.SDcard API calls:Brain.SDcard.isInserted()- Check if SD card is availableBrain.SDcard.exists(filename)- Check if file existsBrain.SDcard.size(filename)- Get file sizeBrain.SDcard.loadfile(filename, buffer, len)- Read file contentsBrain.SDcard.savefile(filename, buffer, len)- Write file contentsBrain.SDcard.appendfile(filename, buffer, len)- Append to fileFiles Modified
readFileToString,writeStringToFile, etc.)Brain.SDcard.appendfile()Brain.SDcard.loadfile()Functions Converted
resetOrInitializeConfig()- Config file creationwriteMaintenanceData()- Maintenance data persistencesetDriveMode()- Drive mode config updatesreadMaintenanceData()- Maintenance data loadingsetValuesFromConfig()- Config file parsingparseConfig()- Main config initializationSD_Card_Logging()- Log file operationsemu_open()- GIF file loadingBefore/After Example
Before (using std::fstream):
After (using VEX API):
Benefits
The changes are minimal and surgical - only the file I/O implementation was changed while preserving all existing functionality. No working code was removed or modified beyond the necessary API conversion.
Fixes #40.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
http://168.63.129.16:80/machine//usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.