summaryrefslogtreecommitdiff
path: root/src/PSEditModel.cxx
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-26 14:12:19 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2004-10-26 14:12:19 +0000
commitd2b86baae9e361de2f1a06cfefa0218f0c66ca8a (patch)
tree821051b910f6e6afc2cac4472c4829415c712877 /src/PSEditModel.cxx
parenta6c28e22fcfca80231bd1061d906195e5735fb37 (diff)
cleanup input/output file handling
cleanup input/output file handling
Diffstat (limited to 'src/PSEditModel.cxx')
-rw-r--r--src/PSEditModel.cxx17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/PSEditModel.cxx b/src/PSEditModel.cxx
index b6bcbd2..2b5cb07 100644
--- a/src/PSEditModel.cxx
+++ b/src/PSEditModel.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: PSEditModel.cxx,v 1.6 2004/10/25 20:58:55 hofmann Exp $"
+// "$Id: PSEditModel.cxx,v 1.7 2004/10/26 16:12:19 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -217,8 +217,7 @@ int PSEditModel::ps_y(int y1) {
return paper_y - (int)((float) y1 * 72.0 / ydpi);
}
-int PSEditModel::load(char *f) {
- FILE *fp;
+int PSEditModel::load(FILE *fp) {
char tmpname[256];
char linebuf[1024];
int ret;
@@ -226,12 +225,6 @@ int PSEditModel::load(char *f) {
PSParser *p2 = new PSParser_2(this);
int tmp_fd;
- fp = fopen(f, "r");
- if (!fp) {
- fprintf(stderr, "Could not open file %s.\n", f);
- return -1;
- }
-
strncpy(tmpname, "/tmp/PSEditorXXXXXX", 256);
tmp_fd = mkstemp(tmpname);
if (tmp_fd < 0) {
@@ -251,7 +244,6 @@ int PSEditModel::load(char *f) {
}
}
- fclose(fp);
lseek(tmp_fd, 0L, SEEK_SET);
delete(p1);
@@ -262,7 +254,7 @@ int PSEditModel::load(char *f) {
-int PSEditModel::save(const char* savefile, int tmp_fd) {
+int PSEditModel::save(FILE *sfp, int tmp_fd) {
off_t pos = lseek(tmp_fd, 0, SEEK_CUR); // save current position
if (pos == -1) {
@@ -273,7 +265,7 @@ int PSEditModel::save(const char* savefile, int tmp_fd) {
FILE *fp = fdopen(tmp_fd, "r");
rewind(fp);
- FILE *sfp = fopen(savefile, "w");
+
PSWriter *pw;
pw = new PSLevel1Writer(this);
@@ -282,7 +274,6 @@ int PSEditModel::save(const char* savefile, int tmp_fd) {
delete(pw);
- fclose(sfp);
lseek(tmp_fd, pos, SEEK_SET); // restore current position
return 0;