summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsauerbeck <tsauerbeck>2004-10-16 11:34:09 +0000
committertsauerbeck <tsauerbeck@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2004-10-16 11:34:09 +0000
commit0750d1853347b249a17335a5ad3d02306afe34dc (patch)
tree0cd6ca92a8a42cfcf8efd4d6f5a55aa55748d2f9
parentb52dafb5edb6490646257b596600f612c8981837 (diff)
check that the input file exists. make sure that the input file doesn't equal the output file
SVN revision: 11891
-rw-r--r--legacy/edje/src/bin/edje_cc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/legacy/edje/src/bin/edje_cc.c b/legacy/edje/src/bin/edje_cc.c
index 10e6ce8162..cf733f644f 100644
--- a/legacy/edje/src/bin/edje_cc.c
+++ b/legacy/edje/src/bin/edje_cc.c
@@ -1,3 +1,7 @@
1/*
2 * vim:ts=8:sw=3:sts=3:noexpandtab
3 */
4
1#include "edje_cc.h" 5#include "edje_cc.h"
2 6
3static void main_help(void); 7static void main_help(void);
@@ -45,6 +49,8 @@ int
45main(int argc, char **argv) 49main(int argc, char **argv)
46{ 50{
47 int i; 51 int i;
52 struct stat st;
53 char rpath[PATH_MAX], rpath2[PATH_MAX];
48 54
49 setlocale(LC_NUMERIC, "C"); 55 setlocale(LC_NUMERIC, "C");
50 56
@@ -128,6 +134,15 @@ main(int argc, char **argv)
128 main_help(); 134 main_help();
129 exit(-1); 135 exit(-1);
130 } 136 }
137
138 /* check whether file_in exists */
139 if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
140 {
141 fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in);
142 main_help();
143 exit(-1);
144 }
145
131 if (!file_out) 146 if (!file_out)
132 { 147 {
133 char *suffix; 148 char *suffix;
@@ -149,6 +164,13 @@ main(int argc, char **argv)
149 exit(-1); 164 exit(-1);
150 } 165 }
151 166
167 if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
168 {
169 fprintf(stderr, "%s: Error: input file equals output file.\n", progname);
170 main_help();
171 exit(-1);
172 }
173
152 edje_init(); 174 edje_init();
153 175
154 edje_file = mem_alloc(SZ(Edje_File)); 176 edje_file = mem_alloc(SZ(Edje_File));