How can I copy a file on Unix using C? -


I'm looking for Win32's Unix counterpart, I do not want to change the wheel again by typing my own version.

There is no need to call non-portable API such as sendfile , Or open outside external utilities The only method working back in the '70s still works:

  #include  0) {char * out_ptr = buf; Ssize_t nwritten; Do {nwritten = write (fd_to, out_ptr, nread); If (nwritten> = 0) {nread - = nwritten; Out_ptr + = nwritten; } And if (error! = EINTR) {geto out_error; }} While (pulse & gt; 0); } If (nail == 0) {if (close (fd_to) <0) {fd_to = -1; Goto out_rar; } Close (FD_ from); /* Success! * / Return 0; } Out_error: saved_errno = errno; Close (fd_from); If (fd_to> = 0) close (fd_to); Errno = saved_errno; Return -1; }  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -