OSDN Git Service
(root)
/
hengband
/
hengband.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
58333a4
)
Use return value of write function
author
habu
<habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 26 Feb 2013 07:53:04 +0000
(07:53 +0000)
committer
habu
<habu@0568b783-4c39-0410-ac80-bf13821ea2a2>
Tue, 26 Feb 2013 07:53:04 +0000
(07:53 +0000)
But fd_copy is unused currently
src/util.c
patch
|
blob
|
history
diff --git
a/src/util.c
b/src/util.c
index
d6547b8
..
0da8e97
100644
(file)
--- a/
src/util.c
+++ b/
src/util.c
@@
-661,7
+661,19
@@
errr fd_copy(cptr file, cptr what)
/* Copy */
while ((read_num = read(src_fd, buf, 1024)) > 0)
{
- write(dst_fd, buf, read_num);
+ int write_num = 0;
+ while (write_num < read_num)
+ {
+ int ret = write(dst_fd, buf + write_num, read_num - write_num);
+ if (ret < 0) {
+ /* Close files */
+ fd_close(src_fd);
+ fd_close(dst_fd);
+
+ return ret;
+ }
+ write_num += ret;
+ }
}
/* Close files */