I thought it would waste space to repeat it, but... sigh
#include <SPI.h>
#include <SD.h>
char* file_name1 = "flor1.jpg";
char* file_name2 = "flor2.jpg";
byte ibuffer[3000];
int ibufferspace = sizeof(ibuffer);
File File1;
File File2;
void setup() {
Serial.begin(19200);
Serial.print("Initializing SD card...");
pinMode(53, OUTPUT);
if (!SD.begin(53)) {
Serial.println("Initialization failed!");
return;
}else {
Serial.println("Initialization done.");
}
File1 = SD.open(file_name1);
if (File1) {
Serial.println("Opening the file: " + String(file_name1) + " done.");
}else {
Serial.println("Error opening " + String(file_name1));
}
if(SD.exists(file_name2)) {
SD.remove(file_name2);
Serial.println("File :" + String(file_name2) + " deleted...");
}
unsigned int previoustime = millis();
if (File1) {
File2 = SD.open(file_name2, FILE_WRITE);
if(File2) {
int i=0;
while (File1.available()>0) {
ibuffer = File1.read();
i++;
if (i==ibufferspace) {
File2.write(ibuffer,ibufferspace);
i=0;
}
}
File2.write(ibuffer,i-1);
}
Serial.println("Done copying...");
File1.close();
File2.close();
}
Serial.println("Time: " + String((millis()-previoustime)/1000) + " seg");
}
void loop()
{
// nothing happens after setup
}
I compiled for a Mega 256 with Arduino IDE 1.6.5 and got the error message above.