Changeset 608 for trunk/user/ksh
- Timestamp:
- Dec 3, 2018, 12:24:13 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/ksh/ksh.c
r596 r608 56 56 #define MAIN_DEBUG 0 57 57 #define CMD_LOAD_DEBUG 0 58 #define CMD_CAT_DEBUG 158 #define CMD_CAT_DEBUG 0 59 59 60 60 ////////////////////////////////////////////////////////////////////////////////////////// … … 226 226 int size; // source file size 227 227 int bytes; // number of transfered bytes 228 char buf[ 1024];228 char buf[4096]; 229 229 stat_t st; 230 230 … … 293 293 while (bytes < size) 294 294 { 295 int rlen = ((size - bytes) < 1024) ? (size - bytes) : 1024; 296 int wlen; 297 int ret; 295 int len = ((size - bytes) < 4096) ? (size - bytes) : 4096; 298 296 299 297 // read the source 300 ret = read( src_fd , buf , rlen ); 301 if (ret == -1) 298 if ( read( src_fd , buf , len ) != len ) 302 299 { 303 300 printf(" error: cannot read from file %s\n", srcpath); … … 305 302 } 306 303 307 rlen = (int)ret;308 309 304 // write to the destination 310 ret = write( dst_fd , buf , rlen ); 311 if (ret == -1) 305 if ( write( dst_fd , buf , len ) != len ) 312 306 { 313 307 printf(" error: cannot write to file %s\n", dstpath); … … 315 309 } 316 310 317 wlen = (int)ret; 318 319 // check 320 if (wlen != rlen) 321 { 322 printf(" error: cannot write on device\n"); 323 goto exit; 324 } 325 326 bytes += rlen; 311 bytes += len; 327 312 } 328 313 … … 848 833 pathname = argv[1]; 849 834 850 printf(" error: not implemented yet\n"); 835 if ( unlink( pathname ) ) 836 { 837 printf(" error: unable to remove %s\n", pathname ); 838 } 851 839 } 852 840
Note: See TracChangeset
for help on using the changeset viewer.