Mercurial > geeqie
comparison src/secure_save.c @ 309:99139bf9f380
Use path_from_utf8() on the passed filename.
Add const attribute.
author | zas_ |
---|---|
date | Fri, 11 Apr 2008 14:27:55 +0000 |
parents | 667e49f52168 |
children | 4b25b3b30f35 |
comparison
equal
deleted
inserted
replaced
308:6cb3c072be3f | 309:99139bf9f380 |
---|---|
13 #include <errno.h> | 13 #include <errno.h> |
14 | 14 |
15 #include "main.h" | 15 #include "main.h" |
16 #include "secure_save.h" | 16 #include "secure_save.h" |
17 | 17 |
18 #include "ui_fileops.h" | |
18 | 19 |
19 /* ABOUT SECURE SAVE */ | 20 /* ABOUT SECURE SAVE */ |
20 /* This code was borrowed from the ELinks project (http://elinks.cz) | 21 /* This code was borrowed from the ELinks project (http://elinks.cz) |
21 * It was originally written by me (Laurent Monin aka Zas) and heavily | 22 * It was originally written by me (Laurent Monin aka Zas) and heavily |
22 * modified and improved by all ELinks contributors. | 23 * modified and improved by all ELinks contributors. |
66 | 67 |
67 | 68 |
68 /** Open a file for writing in a secure way. @returns a pointer to a | 69 /** Open a file for writing in a secure way. @returns a pointer to a |
69 * structure secure_save_info on success, or NULL on failure. */ | 70 * structure secure_save_info on success, or NULL on failure. */ |
70 static SecureSaveInfo * | 71 static SecureSaveInfo * |
71 secure_open_umask(gchar *file_name) | 72 secure_open_umask(const gchar *file_name) |
72 { | 73 { |
73 struct stat st; | 74 struct stat st; |
74 SecureSaveInfo *ssi; | 75 SecureSaveInfo *ssi; |
75 | 76 |
76 secsave_errno = SS_ERR_NONE; | 77 secsave_errno = SS_ERR_NONE; |
81 goto end; | 82 goto end; |
82 } | 83 } |
83 | 84 |
84 ssi->secure_save = TRUE; | 85 ssi->secure_save = TRUE; |
85 | 86 |
86 ssi->file_name = g_strdup(file_name); | 87 ssi->file_name = path_from_utf8(file_name); |
87 if (!ssi->file_name) { | 88 if (!ssi->file_name) { |
88 secsave_errno = SS_ERR_OUT_OF_MEM; | 89 secsave_errno = SS_ERR_OUT_OF_MEM; |
89 goto free_f; | 90 goto free_f; |
90 } | 91 } |
91 | 92 |
185 end: | 186 end: |
186 return NULL; | 187 return NULL; |
187 } | 188 } |
188 | 189 |
189 SecureSaveInfo * | 190 SecureSaveInfo * |
190 secure_open(gchar *file_name) | 191 secure_open(const gchar *file_name) |
191 { | 192 { |
192 SecureSaveInfo *ssi; | 193 SecureSaveInfo *ssi; |
193 mode_t saved_mask; | 194 mode_t saved_mask; |
194 #ifdef CONFIG_OS_WIN32 | 195 #ifdef CONFIG_OS_WIN32 |
195 /* There is neither S_IRWXG nor S_IRWXO under crossmingw32-gcc */ | 196 /* There is neither S_IRWXG nor S_IRWXO under crossmingw32-gcc */ |