check that the input file exists. make sure that the input file doesn't equal the output file

SVN revision: 11891
This commit is contained in:
tsauerbeck 2004-10-16 11:34:09 +00:00 committed by tsauerbeck
parent b52dafb5ed
commit 0750d18533
1 changed files with 22 additions and 0 deletions

View File

@ -1,3 +1,7 @@
/*
* vim:ts=8:sw=3:sts=3:noexpandtab
*/
#include "edje_cc.h"
static void main_help(void);
@ -45,6 +49,8 @@ int
main(int argc, char **argv)
{
int i;
struct stat st;
char rpath[PATH_MAX], rpath2[PATH_MAX];
setlocale(LC_NUMERIC, "C");
@ -128,6 +134,15 @@ main(int argc, char **argv)
main_help();
exit(-1);
}
/* check whether file_in exists */
if (!realpath(file_in, rpath) || stat(rpath, &st) || !S_ISREG(st.st_mode))
{
fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in);
main_help();
exit(-1);
}
if (!file_out)
{
char *suffix;
@ -149,6 +164,13 @@ main(int argc, char **argv)
exit(-1);
}
if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
{
fprintf(stderr, "%s: Error: input file equals output file.\n", progname);
main_help();
exit(-1);
}
edje_init();
edje_file = mem_alloc(SZ(Edje_File));