X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Ffileref.c;h=24e96eb33cb39a21f625b0f75e5bb4c19543d562;hb=f7db20369cdd1b699742a2037ca3ab99afe47ab2;hp=d0cee0829479ecded8a6ec5b743a5298c4cf3c60;hpb=40cf50b43f824311d7f14893ed1193bb5642741a;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/fileref.c b/libchimara/fileref.c index d0cee08..24e96eb 100644 --- a/libchimara/fileref.c +++ b/libchimara/fileref.c @@ -1,8 +1,10 @@ +#include #include #include #include #include #include +#include #include "fileref.h" #include "magic.h" #include "chimara-glk-private.h" @@ -164,7 +166,7 @@ glk_fileref_create_temp(glui32 usage, glui32 rock) * Chimara * * Chimara uses a GtkFileChooserDialog. The default + * linkend="GtkFileChooserDialog">GtkFileChooserDialog. The default * starting location for the dialog may be set with glkunix_set_base_file(). * * @@ -196,10 +198,10 @@ glk_fileref_create_temp(glui32 usage, glui32 rock) * open the file. * * - * It is possible that the prompt or file tool will have a - * cancel option. If the player chooses this, - * glk_fileref_create_by_prompt() will return %NULL. This is a major reason - * why you should make sure the return value is valid before you use it. + * It is likely that the prompt or file tool will have a cancel + * option. If the player chooses this, glk_fileref_create_by_prompt() will + * return %NULL. This is a major reason why you should make sure the return + * value is valid before you use it. * * * Returns: A new fileref, or #NULL if the fileref creation failed or the @@ -411,14 +413,23 @@ glk_fileref_destroy(frefid_t fref) * @fref: A refrence to the file to delete. * * Deletes the file referred to by @fref. It does not destroy @fref itself. + * + * You should only call this with a fileref that refers to an existing file. */ void glk_fileref_delete_file(frefid_t fref) { VALID_FILEREF(fref, return); if( glk_fileref_does_file_exist(fref) ) + { if(g_unlink(fref->filename) == -1) IO_WARNING( "Error deleting file", fref->filename, g_strerror(errno) ); + } + else + { + ILLEGAL(_("Tried to delete a fileref that does not refer to an existing file.")); + } + } /**