allow the user to chose in which directory the temporary file
authorcaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 25 Aug 2009 17:25:23 +0000 (17:25 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 25 Aug 2009 17:25:23 +0000 (17:25 +0000)
will be created. The logic is the following:

 * if the environment variable TMPDIR is set, use its value
 * if it is not set, take the directory passed with the
   -td option (see edje_cc help)
 * otherwise on Windows use a temporary dir and on other
   platform, use /tmp

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@41978 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/bin/edje_cc.c
src/bin/edje_cc.h
src/bin/edje_cc_out.c
src/bin/edje_cc_parse.c

index 5b3ade7..93b7d50 100644 (file)
@@ -16,6 +16,7 @@ Eina_List *img_dirs = NULL;
 Eina_List *fnt_dirs = NULL;
 Eina_List *defines = NULL;
 char      *file_in = NULL;
+char      *tmp_dir = NULL;
 char      *file_out = NULL;
 char      *progname = NULL;
 int        verbose = 0;
@@ -37,6 +38,7 @@ main_help(void)
       "\n"
       "-id image/directory      Add a directory to look in for relative path images\n"
       "-fd font/directory       Add a directory to look in for relative path fonts\n"
+      "-td temp/directory       Directory to store temporary files\n"
       "-v                       Verbose output\n"
       "-no-lossy                Do NOT allow images to be lossy\n"
       "-no-comp                 Do NOT allow images to be stored with lossless compression\n"
@@ -58,6 +60,9 @@ main(int argc, char **argv)
 
    eina_init();
 
+   tmp_dir = getenv("TMPDIR");
+
+
    progname = argv[0];
    for (i = 1; i < argc; i++)
      {
@@ -92,6 +97,12 @@ main(int argc, char **argv)
             i++;
             fnt_dirs = eina_list_append(fnt_dirs, argv[i]);
          }
+       else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1)))
+         {
+            i++;
+             if (!tmp_dir)
+               tmp_dir = argv[i];
+         }
        else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
          {
             i++;
index a27d586..b62feb9 100644 (file)
@@ -124,6 +124,7 @@ char   *mem_strdup(const char *s);
 extern Eina_List             *img_dirs;
 extern Eina_List             *fnt_dirs;
 extern char                  *file_in;
+extern char                  *tmp_dir;
 extern char                  *file_out;
 extern char                  *progname;
 extern int                    verbose;
index 90f7f9d..d5a2957 100644 (file)
@@ -762,10 +762,11 @@ data_write_scripts(Eet_File *ef)
    Eina_List *l;
    int i;
 
+   if (!tmp_dir)
 #ifdef HAVE_EVIL
-   char *tmpdir = evil_tmpdir_get();
+     tmp_dir = evil_tmpdir_get();
 #else
-   char *tmpdir = "/tmp";
+     tmp_dir = "/tmp";
 #endif
 
    for (i = 0, l = codes; l; l = eina_list_next(l), i++)
@@ -779,7 +780,8 @@ data_write_scripts(Eet_File *ef)
          continue;
 
        char tmpn[4096];
-       snprintf(tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmpdir);
+       snprintf(tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmp_dir);
+        printf("%s\n", tmpn);
        fd = mkstemp(tmpn);
        if (fd < 0)
          error_and_abort(ef, "Unable to open temp file \"%s\" for script "
@@ -789,7 +791,8 @@ data_write_scripts(Eet_File *ef)
        close(fd);
 
        char tmpo[4096];
-       snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmpdir);
+       snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir);
+        printf("%s\n", tmpn);
        fd = mkstemp(tmpo);
        if (fd < 0)
          {
index ad492ce..6875cd4 100644 (file)
@@ -641,12 +641,12 @@ compile(void)
    int fd;
    off_t size;
    char *data, *p;
-   const char *tmpdir;
 
+   if (!tmp_dir)
 #ifdef HAVE_EVIL
-   tmpdir = evil_tmpdir_get();
+     tmp_dir = evil_tmpdir_get();
 #else
-   tmpdir = "/tmp";
+     tmp_dir = "/tmp";
 #endif
 
    strncpy(inc, file_in, 4000);
@@ -654,7 +654,8 @@ compile(void)
    p = strrchr(inc, '/');
    if (!p) strcpy(inc, "./");
    else *p = 0;
-   snprintf (tmpn, PATH_MAX, "%s/edje_cc.edc-tmp-XXXXXX", tmpdir);
+   snprintf (tmpn, PATH_MAX, "%s/edje_cc.edc-tmp-XXXXXX", tmp_dir);
+        printf("%s\n", tmpn);
    fd = mkstemp(tmpn);
    if (fd >= 0)
      {