diff options
author | Darin Adler <darin@src.gnome.org> | 2002-03-31 05:10:33 +0000 |
---|---|---|
committer | Darin Adler <darin@src.gnome.org> | 2002-03-31 05:10:33 +0000 |
commit | 1a8424f07f632b2a35cb251cb2f51e11cf797fb2 (patch) | |
tree | f6863562df1a1dcb075722458862453419430d6c /libnautilus-private/nautilus-metafile.c | |
parent | 4af5e3de4851a9bfcf67118fd6913ee56038a2ee (diff) | |
download | nautilus-1a8424f07f632b2a35cb251cb2f51e11cf797fb2.tar.gz |
New. (metafile_write_local): Use write_all to do the multiple writes that
* libnautilus-private/nautilus-metafile.c: (write_all): New.
(metafile_write_local): Use write_all to do the multiple writes that
might be necessary in some cases.
Diffstat (limited to 'libnautilus-private/nautilus-metafile.c')
-rw-r--r-- | libnautilus-private/nautilus-metafile.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/libnautilus-private/nautilus-metafile.c b/libnautilus-private/nautilus-metafile.c index 549d6a69e..1abb88955 100644 --- a/libnautilus-private/nautilus-metafile.c +++ b/libnautilus-private/nautilus-metafile.c @@ -1928,6 +1928,27 @@ metafile_write_create_callback (GnomeVFSAsyncHandle *handle, metafile); } +static int +write_all (int fd, const char *buffer, int size) +{ + int size_remaining; + const char *p; + ssize_t result; + + p = buffer; + size_remaining = size; + while (size_remaining != 0) { + result = write (fd, p, size_remaining); + if (result <= 0 || result > size_remaining) { + return -1; + } + p += result; + size_remaining -= result; + } + + return size; +} + static void metafile_write_local (NautilusMetafile *metafile, const char *metafile_path) @@ -1951,9 +1972,9 @@ metafile_write_local (NautilusMetafile *metafile, if (!failed && fchmod (fd, METAFILE_PERMISSIONS) == -1) { failed = TRUE; } - if (!failed && write (fd, - metafile->details->write_state->buffer, - metafile->details->write_state->size) == -1) { + if (!failed && write_all (fd, + metafile->details->write_state->buffer, + metafile->details->write_state->size) == -1) { failed = TRUE; } if (fd != -1 && close (fd) == -1) { |