made work: copy a file, move a file, check if a file exists, delete a file
This commit is contained in:
@@ -20,5 +20,31 @@ int main() {
|
||||
printf("if you are finished working with the file BEFORE the immediate end of the program, run 'fileCleanup(file_t*)', otherwise it is not strictly necessary\nit will, though, append a '\\n' at the end of the file if you have not done so, making writing into files more consistent, so for this reason, I recommend you use it with every file_t*\n");
|
||||
fileCleanup(f);
|
||||
|
||||
printf("copying and moving\nafter this block of code, the contents of test.txt will have been copied into copy_of_test.txt and moved to moved_copy_of_test.txt, which means that copy_of_test.txt is deleted and the contents of test.txt are only in test.txt and moved_copy_of_test.txt\n");
|
||||
|
||||
file_t* src = fileInit("test.txt");
|
||||
|
||||
fileCopy(src, "copy_of_test.txt");
|
||||
|
||||
printf("src:\n");
|
||||
filePrint(src);
|
||||
|
||||
printf("\ndst:\n");
|
||||
file_t* dst = fileInit("copy_of_test.txt");
|
||||
filePrint(dst);
|
||||
|
||||
fileMove(dst, "moved_copy_of_test.txt");
|
||||
|
||||
printf("moved file:\n");
|
||||
file_t* move_dst = fileInit("moved_copy_of_test.txt");
|
||||
filePrint(move_dst);
|
||||
|
||||
fileCleanup(src);
|
||||
printf("DO NOT cleanup a deleted file! (dst, in this case) it is already done for you by the 'fileMove(file_t*, char*)' function\n");
|
||||
// fileCleanup(dst);
|
||||
fileCleanup(move_dst);
|
||||
|
||||
printf("when copying and moving files, the first argument is a file_t* (source file) and the second argument is a char* (the path of the destination file), not a file_t*!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user