PropWare  3.0.0.224
C++ objects and CMake build system for Parallax Propeller
FileWriter_Demo.cpp

Create a copy of a text file, character-by-character using a second buffer. The second buffer (writeBuffer) does increase the complexity by five lines of code, but it drastically increases the performance as well.

cmake_minimum_required(VERSION 3.12)
find_package(PropWare REQUIRED)
set(BOARD activityboard)
project(FileWriter_Demo)
create_simple_executable(${PROJECT_NAME} FileWriter_Demo.cpp)
int main() {
const SD driver;
FatFS filesystem(driver);
uint8_t writeBufferData[driver.get_sector_size()];
BlockStorage::MetaData writeMetaData;
BlockStorage::Buffer writeBuffer = {
buf: writeBufferData,
meta: &writeMetaData
};
filesystem.mount();
FatFileReader reader(filesystem, "fat_test.txt");
FatFileWriter writer(filesystem, "new2.txt", writeBuffer);
reader.open();
writer.open();
while (!reader.eof())
writer.put_char(reader.get_char());
writer.close();
reader.close();
filesystem.unmount();
return 0;
}