mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
ZVISION: Add documentation to utility functions and add a glorified trim function
This commit is contained in:
@@ -29,7 +29,14 @@
|
||||
|
||||
namespace ZVision {
|
||||
|
||||
void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile) {
|
||||
/**
|
||||
* Opens the sourceFile utilizing Common::File (aka SearchMan) and writes the
|
||||
* contents to destFile. destFile is created in the working directory
|
||||
*
|
||||
* @param sourceFile The 'file' you want the contents of
|
||||
* @param destFile The name of the file where the content will be written to
|
||||
*/
|
||||
void writeFileContentsToFile(Common::String sourceFile, Common::String destFile) {
|
||||
Common::File f;
|
||||
f.open(sourceFile);
|
||||
byte* buffer = new byte[f.size()];
|
||||
@@ -45,6 +52,23 @@ void WriteFileContentsToFile(Common::String sourceFile, Common::String destFile)
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes any line comments using '#' as a sequence start.
|
||||
* Then removes any trailing and leading 'whitespace'.
|
||||
* Uses isspace() to determine what is whitespace and what is not.
|
||||
*
|
||||
* @param string The string to modify. It is modified in place
|
||||
*/
|
||||
void trimCommentsAndWhiteSpace(Common::String &string) {
|
||||
for (int i = string.size(); i >= 0; --i) {
|
||||
if (string[i] == '#') {
|
||||
string.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
string.trim();
|
||||
}
|
||||
|
||||
} // End namespace ZVision
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user