Code:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int FileCopy( char * Fromt, char * To, char * Display );
int gotoxy(int x, int y);
int clrscr();
int kill_cursor(void);
int main()
{
clrscr(0, 0);
kill_cursor();
FileCopy("d:\\roms\\mameb16\\mk2.zip",
"c:\\mk2.zip",
"MK2");
return 0;
}
int FileCopy( char * From, char * To, char * Display )
{
size_t len;
char buf[BUFSIZ];
FILE * in, * out;
FILE * Tmp;
if ( ( Tmp = fopen ( From, "r" ) ) == 0 )
{
printf("%s not found, skipping.\n", Display);
Sleep(200);
}
else
{
fclose(Tmp);
if ( ( in = fopen ( From, "rb" ) ) != NULL )
{
if ( ( out = fopen ( To, "wb" ) ) != NULL )
{
gotoxy(0, 0);
printf("Copying..");
do
{
len = fread ( buf, 1, sizeof buf, in );
if ( len != 0 )
{
fwrite ( buf, 1, len, out );
}
gotoxy(0, 1);
printf("\\");
gotoxy(0, 1);
printf("|");
gotoxy(0, 1);
printf("/");
gotoxy(0 ,1);
printf("-");
}
while ( len == sizeof buf );
{
fclose ( out );
gotoxy(0, 1);
printf("Copied: %s\n", Display);
}
}
else
{
printf("File copy output error: %s\n", Display);
}
fclose ( in );
}
else
{
printf("File copy input error: %s\n", Display);
}
}
return EXIT_SUCCESS;
}
int gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
return 0;
}
int kill_cursor(void)
{
CONSOLE_CURSOR_INFO cci;
cci.dwSize = 1;
cci.bVisible = FALSE;
SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cci );
return 0;
}
int clrscr()
{
COORD coordScreen = { 0, 0};
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '),
dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
return 0;
}
Now, I ran this, and copied a 15mb ( or so ) file, and the little cursor animates perfectly, and the copied message displays perfectly, etc. With one simple file, this does great.