diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index cc2d59f..1912797 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -386,7 +386,11 @@ edi_open(const char *path) Evas_Object *win, *vbx, *content, *tb; const char *winname; - edi_project_set(path); + if (!edi_project_set(path)) + { + fprintf(stderr, "Project path must be a directory\n"); + return NULL; + } elm_need_ethumb(); elm_need_efreet(); @@ -481,7 +485,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) if (args < argc) { - project_path = realpath(argv[args], NULL); + project_path = argv[args]; } elm_app_info_set(elm_main, "edi", "images/edi.png"); diff --git a/src/lib/Edi.h b/src/lib/Edi.h index c533995..aff9918 100644 --- a/src/lib/Edi.h +++ b/src/lib/Edi.h @@ -2,6 +2,7 @@ # define EDI_H_ #include +#include #ifdef EAPI # undef EAPI @@ -98,12 +99,15 @@ EAPI int edi_shutdown(void); * @{ * * Set the current edi project that is loaded. + * Any directory is deemed a valid project. * * @param path The path to the current project being loaded. + * @return EINA_TRUE if the path represented a valid project, + * EINA_FALSE otherwise * * @ingroup Main */ -EAPI void edi_project_set(const char *path); +EAPI Eina_Bool edi_project_set(const char *path); /** * Get the current edi project that is loaded. diff --git a/src/lib/edi.c b/src/lib/edi.c index 7d667ed..8950a49 100644 --- a/src/lib/edi.c +++ b/src/lib/edi.c @@ -2,6 +2,10 @@ # include "config.h" #endif +#include +#include +#include + #include "Edi.h" #include "edi_private.h" @@ -58,13 +62,36 @@ edi_shutdown(void) return _edi_init; } -EAPI void +static Eina_Bool +_edi_path_isdir(const char *path) +{ + struct stat buf; + + if (!path) + return EINA_FALSE; + + stat(path, &buf); + return S_ISDIR(buf.st_mode); +} + +EAPI Eina_Bool edi_project_set(const char *path) { + char *real = NULL; + + real = realpath(real, NULL); + if (!_edi_path_isdir(path)) + { + free(real); + return EINA_FALSE; + } + if (_edi_project_path) eina_stringshare_del(_edi_project_path); _edi_project_path = eina_stringshare_add(path); + free(real); + return EINA_TRUE; } EAPI const char *