Changeset 3b10e07b in mainline


Ignore:
Timestamp:
2008-11-28T10:02:36Z (15 years ago)
Author:
Tim Post <echo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c3c5640
Parents:
ee02922
Message:

make copy_file() deal with files with zero length

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    ree02922 r3b10e07b  
    7070}
    7171
    72 static size_t copy_file(const char *src, const char *dest, size_t blen, int vb)
     72static int64_t copy_file(const char *src, const char *dest, size_t blen, int vb)
    7373{
    7474        int fd1, fd2, bytes = 0;
    7575        off_t total = 0;
    76         size_t copied = 0;
     76        int copied = -1;
    7777        char *buff = NULL;
    7878
     
    8282        if (-1 == (fd1 = open(src, O_RDONLY))) {
    8383                printf("Unable to open source file %s\n", src);
    84                 return 0;
     84                return copied;
    8585        }
    8686
    8787        if (-1 == (fd2 = open(dest, O_CREAT))) {
    8888                printf("Unable to open destination file %s\n", dest);
    89                 return 0;
     89                return copied;
    9090        }
    9191
     
    112112        if (bytes == -1) {
    113113                printf("Error copying %s\n", src);
    114                 copied = 0;
     114                copied = bytes;
    115115                goto out;
    116116        }
     
    149149{
    150150        unsigned int argc, buffer = CP_DEFAULT_BUFLEN, verbose = 0;
    151         int c, opt_ind, ret = 0;
     151        int c, opt_ind;
     152        int64_t ret;
    152153
    153154        argc = cli_count_args(argv);
Note: See TracChangeset for help on using the changeset viewer.