forked from enlightenment/edi
A pretty slim test of file loading and initial path apis
This commit is contained in:
parent
a78a0301e7
commit
b38f986767
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <Elementary.h>
|
||||
|
||||
#include <Eina.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
|
@ -38,6 +40,20 @@ extern "C" {
|
|||
* @brief These routines are used for interacting with files using Elm Code.
|
||||
*/
|
||||
|
||||
typedef struct _Elm_Code_Line
|
||||
{
|
||||
const char *content;
|
||||
const char *modified;
|
||||
|
||||
} Elm_Code_Line;
|
||||
|
||||
typedef struct _Elm_Code_File
|
||||
{
|
||||
Elm_Code_Line *lines;
|
||||
Eina_File *file;
|
||||
|
||||
} Elm_Code_File;
|
||||
|
||||
/**
|
||||
* @brief Init / shutdown functions.
|
||||
* @defgroup Init Init / Shutdown
|
||||
|
@ -84,6 +100,14 @@ EAPI int elm_code_init(void);
|
|||
*/
|
||||
EAPI int elm_code_shutdown(void);
|
||||
|
||||
EAPI Elm_Code_File *elm_code_open(const char *path);
|
||||
|
||||
EAPI void elm_code_close(Elm_Code_File *file);
|
||||
|
||||
EAPI const char *elm_code_filename_get(Elm_Code_File *file);
|
||||
|
||||
EAPI const char *elm_code_path_get(Elm_Code_File *file);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -56,3 +56,31 @@ elm_code_shutdown(void)
|
|||
|
||||
return _elm_code_init;
|
||||
}
|
||||
|
||||
EAPI Elm_Code_File *elm_code_open(const char *path)
|
||||
{
|
||||
Elm_Code_File *ret;
|
||||
Eina_File *file;
|
||||
|
||||
file = eina_file_open(path, EINA_FALSE);
|
||||
ret = calloc(1, sizeof(ret));
|
||||
ret->file = file;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EAPI void elm_code_close(Elm_Code_File *file)
|
||||
{
|
||||
eina_file_close(file->file);
|
||||
free(file);
|
||||
}
|
||||
|
||||
EAPI const char *elm_code_filename_get(Elm_Code_File *file)
|
||||
{
|
||||
return basename(eina_file_filename_get(file->file));
|
||||
}
|
||||
|
||||
EAPI const char *elm_code_path_get(Elm_Code_File *file)
|
||||
{
|
||||
return eina_file_filename_get(file->file);
|
||||
}
|
|
@ -6,7 +6,16 @@
|
|||
|
||||
START_TEST (elm_code_load)
|
||||
{
|
||||
ck_assert(1);
|
||||
char *path = "elm_code/tests/testfile.txt";
|
||||
char real[EINA_PATH_MAX];
|
||||
Elm_Code_File *file;
|
||||
|
||||
file = elm_code_open(path);
|
||||
realpath(path, real);
|
||||
|
||||
ck_assert_str_eq(basename(path), elm_code_filename_get(file));
|
||||
ck_assert_str_eq(real, elm_code_path_get(file));
|
||||
elm_code_close(file);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
line 1
|
||||
line2
|
||||
|
||||
another line
|
||||
5
|
Loading…
Reference in New Issue