aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/elementary/elm_code_file.c10
-rw-r--r--src/lib/elementary/elm_code_file.h2
-rw-r--r--src/tests/elementary/elm_code_test_basic.c19
3 files changed, 31 insertions, 0 deletions
diff --git a/src/lib/elementary/elm_code_file.c b/src/lib/elementary/elm_code_file.c
index 1094929f1a..97c36597fd 100644
--- a/src/lib/elementary/elm_code_file.c
+++ b/src/lib/elementary/elm_code_file.c
@@ -210,6 +210,16 @@ EAPI void elm_code_file_save(Elm_Code_File *file)
}
}
+EAPI void elm_code_file_save_as(Elm_Code_File *file, const char *path)
+{
+ Eina_File *newfile;
+ newfile = eina_file_open(path, EINA_FALSE);
+ file->file = newfile;
+ file->mime = efreet_mime_type_get(path);
+
+ elm_code_file_save(file);
+}
+
EAPI void elm_code_file_free(Elm_Code_File *file)
{
Elm_Code_Line *l;
diff --git a/src/lib/elementary/elm_code_file.h b/src/lib/elementary/elm_code_file.h
index 9bafe431ac..80842bf318 100644
--- a/src/lib/elementary/elm_code_file.h
+++ b/src/lib/elementary/elm_code_file.h
@@ -43,6 +43,8 @@ EAPI Elm_Code_File *elm_code_file_open(Elm_Code *code, const char *path);
EAPI void elm_code_file_save(Elm_Code_File *file);
+EAPI void elm_code_file_save_as(Elm_Code_File *file, const char *path);
+
EAPI void elm_code_file_free(Elm_Code_File *file);
EAPI void elm_code_file_close(Elm_Code_File *file);
diff --git a/src/tests/elementary/elm_code_test_basic.c b/src/tests/elementary/elm_code_test_basic.c
index 5f6827b95e..887db8d7ed 100644
--- a/src/tests/elementary/elm_code_test_basic.c
+++ b/src/tests/elementary/elm_code_test_basic.c
@@ -42,9 +42,28 @@ START_TEST (elm_code_open_test)
}
END_TEST
+START_TEST (elm_code_save_as_test)
+{
+ char *path = TESTS_SRC_DIR "/testfile.txt";
+ char *dest = "/tmp/dest.txt";
+ Elm_Code *code;
+
+ elm_init(1, NULL);
+ code = elm_code_create();
+ elm_code_file_open(code, path);
+
+ elm_code_file_save_as(code->file, dest);
+ ck_assert(ecore_file_exists(dest));
+
+ ecore_file_remove(dest);
+ elm_code_free(code);
+ elm_shutdown();
+}
+END_TEST
void elm_code_test_basic(TCase *tc)
{
tcase_add_test(tc, elm_code_create_test);
tcase_add_test(tc, elm_code_open_test);
+ tcase_add_test(tc, elm_code_save_as_test);
}