aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-23 18:27:16 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-23 18:27:16 +0800
commitcb227b68b34052c2198cddfece3ee6da81a5e13e (patch)
tree92b59cae6ad2ec1192af87557b6fe847a09449d2 /e-util
parent83dfb929cf4f19ef73767a58e9b968bb6b11e55b (diff)
downloadgsoc2013-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')
-rw-r--r--e-util/ChangeLog4
-rw-r--r--e-util/e-util.c26
-rw-r--r--e-util/e-util.c-861126
-rw-r--r--e-util/e-util.h1
-rw-r--r--e-util/e-util.h-290021
5 files changed, 58 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 2c0ed89a7c..ffad50d570 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,7 @@
+2000-05-23 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-util.c, e-util.h: Added e_write_file.
+
2000-05-19 Federico Mena Quintero <federico@helixcode.com>
* e-dialog-widgets.[ch]: New files with utilities for hooking up
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;
+}
diff --git a/e-util/e-util.c-8611 b/e-util/e-util.c-8611
index fd167599df..cac850b0d5 100644
--- a/e-util/e-util.c-8611
+++ b/e-util/e-util.c-8611
@@ -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;
+}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index fef56c0531..132c89e9a0 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -40,5 +40,6 @@ void e_free_object_list (GList *list);
void e_free_string_list (GList *list);
char *e_read_file (const char *filename);
+gint e_write_file(const char *filename, const char *data, int flags);
#endif /* _E_UTIL_H_ */
diff --git a/e-util/e-util.h-29002 b/e-util/e-util.h-29002
index fef56c0531..132c89e9a0 100644
--- a/e-util/e-util.h-29002
+++ b/e-util/e-util.h-29002
@@ -40,5 +40,6 @@ void e_free_object_list (GList *list);
void e_free_string_list (GList *list);
char *e_read_file (const char *filename);
+gint e_write_file(const char *filename, const char *data, int flags);
#endif /* _E_UTIL_H_ */