aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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_ */