From c802e6d3738673f81288d1bc92fb30b89f3a0a48 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 13 May 2009 12:23:58 +0000 Subject: Create all directories as appropriate. Now takes an extra parameter specifying the destination directory. svn path=/trunk/tools/ttf2f/; revision=7500 --- src/cli.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/cli.c b/src/cli.c index e38bb46..1ee4392 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -29,9 +30,15 @@ int main(int argc, char **argv) ttf2f_ctx ctx; int fail; ttf2f_result err = TTF2F_RESULT_OK; + char *dot, *path; + char full_path[PATH_MAX]; /* Lazy */ - if (argc != 3) { - fprintf(stderr, "Usage: %s \n", argv[0]); + if (argc != 4) { + fprintf(stderr, + "Usage: %s \n" + " must be in the platform's path format\n" + " must be in the form Trinity.Bold\n", + argv[0]); return 1; } @@ -91,13 +98,31 @@ int main(int argc, char **argv) mkdir(argv[2], 0755); - if ((err = intmetrics_write(argv[2], argv[2], &ctx, progress)) != + strncpy(full_path, argv[2], sizeof(full_path)); + path = full_path + strlen(full_path); + + if (*(path - 1) != *DIR_SEP) + *(path++) = *DIR_SEP; + + for (dot = argv[3]; *dot != '\0'; dot++) { + if (*dot == '.') { + *path = '\0'; + mkdir(full_path, 0755); + *(path++) = *DIR_SEP; + } else { + *(path++) = *dot; + } + } + *path = '\0'; + mkdir(full_path, 0755); + + if ((err = intmetrics_write(full_path, argv[3], &ctx, progress)) != TTF2F_RESULT_OK) goto error_out; - if ((err = outlines_write(argv[2], argv[2], &ctx, progress)) != + if ((err = outlines_write(full_path, argv[3], &ctx, progress)) != TTF2F_RESULT_OK) goto error_out; - if ((err = encoding_write(argv[2], argv[2], &ctx, + if ((err = encoding_write(full_path, argv[3], &ctx, ENCODING_TYPE_NORMAL, progress)) != TTF2F_RESULT_OK) goto error_out; -- cgit v1.2.3