Syntax
int fcopy(
char *filename1,
char *filename2,
int mode,
pFileCopy FileCopyCb
);
Parameters
- filename1
- [in] Pointer to the destination file name.
- filename2
- [in] Pointer to the file name of the copy source.
If you specify a file that does not exist or a file with a file size of 0, an error will occur. - mode
- [in] This is the operation to be executed.
The following values can be specified.Value Description WRITE_ONLY Copy only WRITE_VERIFY After copy verify - FileCopyCb
- [in] Specifies a callback function to get the copy and verify progress.
If you do not need to get it, specify NULL.
The format of the callback function is as follows.
Please refer to the example.
pFileCopy FileCopyCb(unsigned char stat, unsigned char progress)
FileCopyCb
It is the contents of the acquired progress.
Contains one of the following values
Value Description COPY_FILE Copy progress VERIFY_FILE Verify progress
Enter with a progress value of 0 to 100 (%).
Return value
Returns OK if the function ends normally (copy success), and other values if it ends abnormally.Value | Description |
---|---|
OK | Copy success |
Other values | Parameter error, copy failure, etc. |
Remarks
This API is compatible with OS version TH15J06 or later.Requirements
Header file:
lib.hLibrary file:
libSTARTUPOPH5000.a
Sample
#include <stdio.h>
#include "lib.h"
void fcopy_cb(unsigned char stat, unsigned char progress)
{
switch(stat)
{
case COPY_FILE:
GotoXY(0,1);
printf(" COPY-%d%%", progress);
break;
case VERIFY_FILE:
GotoXY(11,1);
printf(" VERI-%d%%", progress);
break;
}
}
void main(void)
{
int ret;
ret = fcopy("copy.txt", "original.txt", WRITE_ONLY, fcopy_cb);
if(ret == OK)
{
printf("fcopy succeed.\n\r");
} else {
printf("fcopy failed.\n\r");
}
while(1)
{
Idle();
}
}
Last updated: 2020/10/08