elm_code_file: preserve file permissions on save.

Test Plan:
 * Run Edi (Python project)
 * Edit setup.py
 * Run build
 * Permissions should be preserved.
 * setup.py should build.

Reviewers: ajwillia.ms

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D7008
This commit is contained in:
Alastair Poole 2018-09-09 21:19:31 +01:00 committed by Andy Williams
parent 3c67890009
commit 0ae2211b40
1 changed files with 13 additions and 1 deletions

View File

@ -167,17 +167,26 @@ EAPI void elm_code_file_save(Elm_Code_File *file)
Eina_List *item;
Elm_Code *code;
Elm_Code_Line *line_item;
FILE *out;
const char *path, *content, *crchars;
char *tmp;
unsigned int length;
short crlength;
FILE *out;
struct stat st;
mode_t mode;
Eina_Bool have_mode = EINA_FALSE;
code = file->parent;
path = elm_code_file_path_get(file);
tmp = _elm_code_file_tmp_path_get(file);
crchars = elm_code_file_line_ending_chars_get(file, &crlength);
if (stat(path, &st) != -1)
{
mode = st.st_mode;
have_mode = EINA_TRUE;
}
out = fopen(tmp, "w");
if (out == NULL)
{
@ -202,6 +211,9 @@ EAPI void elm_code_file_save(Elm_Code_File *file)
ecore_file_mv(tmp, path);
free(tmp);
if (have_mode)
chmod(path, mode);
if (file->parent)
{
_elm_code_parse_reset_file(file->parent, file);