//
// 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));
}
ppdcFile::~ppdcFile()
{
- if (fp)
+ if (close_on_delete && fp)
cupsFileClose(fp);
}