]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - ppdc/ppdc-file.cxx
Don't create the full name twice (<rdar://problem/23144358>)
[thirdparty/cups.git] / ppdc / ppdc-file.cxx
index 3af0e4975129f6f3d0b2b9332e21d7ca3f84423a..1f1d9a84e1980c3d13b532683a8be902b3f24a42 100644 (file)
@@ -3,7 +3,7 @@
 //
 //   File class for the CUPS PPD Compiler.
 //
-//   Copyright 2007 by Apple Inc.
+//   Copyright 2007-2010 by Apple Inc.
 //   Copyright 2002-2005 by Easy Software Products.
 //
 //   These coded instructions, statements, and computer programs are the
 // Include necessary headers...
 //
 
-#include "ppdc.h"
+#include "ppdc-private.h"
 
 
 //
 // 'ppdcFile::ppdcFile()' - Create (open) a file.
 //
 
-ppdcFile::ppdcFile(const char *f)              // I - File to open
+ppdcFile::ppdcFile(const char  *f,             // I - File to open
+                   cups_file_t *ffp)           // I - File pointer to use
 {
-  fp       = cupsFileOpen(f, "r");
-  filename = f;
-  line     = 1;
+  if (ffp)
+  {
+    fp = ffp;
+    cupsFileRewind(fp);
+  }
+  else
+    fp = cupsFileOpen(f, "r");
+
+  close_on_delete = !ffp;
+  filename        = f;
+  line            = 1;
 
   if (!fp)
-    fprintf(stderr, "ppdc: Unable to open %s: %s\n", f, strerror(errno));
+    _cupsLangPrintf(stderr, _("ppdc: Unable to open %s: %s"), f,
+                    strerror(errno));
 }
 
 
@@ -48,7 +58,7 @@ ppdcFile::ppdcFile(const char *f)             // I - File to open
 
 ppdcFile::~ppdcFile()
 {
-  if (fp)
+  if (close_on_delete && fp)
     cupsFileClose(fp);
 }