code vault - copy_fileWhat links here?
This copies a file from one location to another, preserving the creation and last access times.

Code

//#############################################################################
void copy_file(char* source, char* destination)
{
    FILE*   infile;
    FILE*   outfile;
    char*   buffer[8192];
    size_t  count_read;
    size_t  count_written;
    
    if(infile = fopen(source, "rb")) {
        if (outfile = fopen(destination, "wb")) {
            while (!feof(infile) && !ferror(outfile)) {
                count_read = fread(buffer, 1, 8192, infile);
                count_written = fwrite(buffer, 1, count_read, outfile);
            }
            fclose(outfile);
            struct stat buf;
            stat(source, &buf);
            utimbuf times;
            times.actime  = buf.st_atime;
            times.modtime = buf.st_mtime;
            utime(destination, &times);
        }
        else {
            printf("failed to open %s for output\n", destination);
        }
        fclose(infile);
    }
    else {
        printf("failed to open %s for input\n", source);
    }
}


code vault - copy_file
programming:windows:WM_SIZE
MC6802 - instruction set - condition code register
test page 004 - preformatted text
AutoCAD - Dialog Control Language (DCL) - (start_dialog)
programming - HTML - input
microprocessors - microchip 16F84A - option
filename:code vault - copy_file
filename:code%20vault%20%2D%20copy_file
last edit:March 26 2009 18:35:48 (5532 days ago)
ct = 1716081353.000000 = May 18 2024 21:15:53
ft = 1238106948.000000 = March 26 2009 18:35:48
dt = 477974405.000000