Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make document_rename_file() return a gboolean; Abort save if rename fails #1180

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
if (doc->file_name != NULL)
{
if (rename_file)
{
document_rename_file(doc, utf8_filename);
}
if (! document_rename_file(doc, utf8_filename))
return FALSE;

if (doc->tm_file)
{
/* create a new tm_source_file object otherwise tagmanager won't work correctly */
Expand Down
4 changes: 3 additions & 1 deletion src/document.c
Original file line number Diff line number Diff line change
Expand Up @@ -1736,10 +1736,11 @@ static void replace_header_filename(GeanyDocument *doc)
* @param doc The current document which should be renamed.
* @param new_filename The new filename in UTF-8 encoding.
*
* @return @c TRUE if file was renamed or @c FALSE otherwise.
* @since 0.16
**/
GEANY_API_SYMBOL
void document_rename_file(GeanyDocument *doc, const gchar *new_filename)
gboolean document_rename_file(GeanyDocument *doc, const gchar *new_filename)
{
gchar *old_locale_filename = utils_get_locale_from_utf8(doc->file_name);
gchar *new_locale_filename = utils_get_locale_from_utf8(new_filename);
Expand All @@ -1757,6 +1758,7 @@ void document_rename_file(GeanyDocument *doc, const gchar *new_filename)
}
g_free(old_locale_filename);
g_free(new_locale_filename);
return (result == 0);
}


Expand Down
2 changes: 1 addition & 1 deletion src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ GeanyDocument *document_index(gint idx);

gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname);

void document_rename_file(GeanyDocument *doc, const gchar *new_filename);
gboolean document_rename_file(GeanyDocument *doc, const gchar *new_filename);

const GdkColor *document_get_status_color(GeanyDocument *doc);

Expand Down