forked from enlightenment/efl
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:
parent
f6d397df04
commit
5cc05b66d6
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue