Alexandre Julliard : sfnt2fnt: Remove output file on failure.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Mar 21 13:21:22 CST 2006
Module: wine
Branch: refs/heads/master
Commit: ef4440ad1b68d0e8007f632b3c27b0b511213ff9
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=ef4440ad1b68d0e8007f632b3c27b0b511213ff9
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Mar 21 16:18:45 2006 +0100
sfnt2fnt: Remove output file on failure.
---
tools/sfnt2fnt.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/tools/sfnt2fnt.c b/tools/sfnt2fnt.c
index 6b9f341..63e5b7a 100644
--- a/tools/sfnt2fnt.c
+++ b/tools/sfnt2fnt.c
@@ -55,6 +55,8 @@ typedef struct {
#include "poppack.h"
+static const char *output_name;
+
static void usage(char **argv)
{
fprintf(stderr, "%s foo.ttf ppem enc dpi def_char avg_width\n", argv[0]);
@@ -65,6 +67,12 @@ static void usage(char **argv)
#define __attribute__(X)
#endif
+/* atexit handler to cleanup files */
+static void cleanup(void)
+{
+ if (output_name) unlink( output_name );
+}
+
static void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
static void error(const char *s, ...)
@@ -377,10 +385,13 @@ int main(int argc, char **argv)
sprintf(output, "%s-%d-%d-%d.fnt", name, enc, dpi, ppem);
+ atexit( cleanup );
fp = fopen(output, "w");
+ output_name = output;
fill_fontinfo(face, enc, fp, dpi, def_char, avg_width);
fclose(fp);
+ output_name = NULL;
exit(0);
}
More information about the wine-cvs
mailing list