forked from enlightenment/edi
Warn if the passed parameter is not a valid project location.
Currently EDI can only open existing directories or create them - no single file mode
This commit is contained in:
parent
50b9cd16f7
commit
95958caa31
|
@ -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");
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# define EDI_H_
|
||||
|
||||
#include <Elementary.h>
|
||||
#include <Eina.h>
|
||||
|
||||
#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.
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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 *
|
||||
|
|
Loading…
Reference in New Issue