summaryrefslogtreecommitdiff
path: root/src/PSEditModel.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-25 18:58:55 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-25 18:58:55 +0000
commita6c28e22fcfca80231bd1061d906195e5735fb37 (patch)
tree98bb976ac8a50e6ae0e6bf202f94cfdfc320f554 /src/PSEditModel.cxx
parent25da85de6a1eca08de94bbc9f1b63ae9a7c87841 (diff)
implement batch mode (needs cleanup)
implement batch mode (needs cleanup)
Diffstat (limited to 'src/PSEditModel.cxx')
-rw-r--r--src/PSEditModel.cxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/PSEditModel.cxx b/src/PSEditModel.cxx
index 75f96ee..b6bcbd2 100644
--- a/src/PSEditModel.cxx
+++ b/src/PSEditModel.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditModel.cxx,v 1.5 2004/10/24 18:28:37 hofmann Exp $"
+// "$Id: PSEditModel.cxx,v 1.6 2004/10/25 20:58:55 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -259,3 +259,31 @@ int PSEditModel::load(char *f) {
return tmp_fd;
}
+
+
+
+int PSEditModel::save(const char* savefile, int tmp_fd) {
+ off_t pos = lseek(tmp_fd, 0, SEEK_CUR); // save current position
+
+ if (pos == -1) {
+ perror("lseek");
+ return 1;
+ }
+
+ FILE *fp = fdopen(tmp_fd, "r");
+
+ rewind(fp);
+ FILE *sfp = fopen(savefile, "w");
+ PSWriter *pw;
+
+ pw = new PSLevel1Writer(this);
+
+ pw->write(fp, sfp);
+
+ delete(pw);
+
+ fclose(sfp);
+ lseek(tmp_fd, pos, SEEK_SET); // restore current position
+
+ return 0;
+}