diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-23 18:27:16 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-23 18:27:16 +0800 |
commit | cb227b68b34052c2198cddfece3ee6da81a5e13e (patch) | |
tree | 92b59cae6ad2ec1192af87557b6fe847a09449d2 /e-util/e-util.c | |
parent | 83dfb929cf4f19ef73767a58e9b968bb6b11e55b (diff) | |
download | gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.tar gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.tar.gz gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.tar.bz2 gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.tar.lz gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.tar.xz gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.tar.zst gsoc2013-evolution-cb227b68b34052c2198cddfece3ee6da81a5e13e.zip |
Added e_write_file.
2000-05-23 Christopher James Lahey <clahey@helixcode.com>
* e-util.c, e-util.h: Added e_write_file.
svn path=/trunk/; revision=3181
Diffstat (limited to 'e-util/e-util.c')
-rw-r--r-- | e-util/e-util.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c index fd167599df..cac850b0d5 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -133,3 +133,29 @@ e_read_file(const char *filename) g_list_free(lengths); return ret_val; } + +gint +e_write_file(const char *filename, const char *data, int flags) +{ + int fd; + int length = strlen(data); + int bytes; + fd = open(filename, flags, 0666); + if (fd == -1) + return errno; + while (length > 0) { + bytes = write(fd, data, length); + if (bytes > 0) { + length -= bytes; + data += bytes; + } else { + if (errno != EINTR && errno != EAGAIN) { + int save_errno = errno; + close(fd); + return save_errno; + } + } + } + close(fd); + return 0; +} |