Insider1984
Technical User
I have the following code setup to copy the first passin to the second. The problem is that the folders need to exsist. I would like it to create the folders if they do not exsist
Basically the program takes a "main" folder with subfolders full of images... renames them and then inside the main folder adds "_new" to the subfolder and places the images inside the folder.
Again currently this doesn't work because the folder needs to exsist the way my code is written currently.
Any help with this would be great.. Thanks!
Basically the program takes a "main" folder with subfolders full of images... renames them and then inside the main folder adds "_new" to the subfolder and places the images inside the folder.
Again currently this doesn't work because the folder needs to exsist the way my code is written currently.
Any help with this would be great.. Thanks!
Code:
int CCompareDlg::FileCopy( const char *src, const char *dst )
{
#define BUFSZ 16000
char *buf;
FILE *fi;
FILE *fo;
unsigned amount;
unsigned written;
int result;
buf = new char[BUFSZ];
fi = fopen( src, "rb" );
fo = fopen( dst, "wb" );
result = COPY_OK;
if ((fi == NULL) || (fo == NULL) )
{
result = COPY_ERROR;
if (fi != NULL) fclose(fi);
if (fo != NULL) fclose(fo);
}
if (result == COPY_OK)
{
do
{
amount = fread( buf, sizeof(char), BUFSZ, fi );
if (amount)
{
written = fwrite( buf, sizeof(char), amount, fo );
if (written != amount)
{
result = COPY_ERROR; // out of disk space or some other disk err?
}
}
} // when amount read is < BUFSZ, copy is done
while ((result == COPY_OK) && (amount == BUFSZ));
fclose(fi);
fclose(fo);
}
delete [] buf;
return(result);
}