Interpreter not deleting files when asked to?

I’m largely talking to David, who just helped me out in my other topic.

I was trying to work out why certain status file configuration commands weren’t working in my game (basically, they try to delete files the game has previously created) or worked erratically. What I found was that WinGlulxe and WinGit would not delete files the game created through them, when asked by the game, though Gargoyle would delete the files the game created through it.

The delete function is defined like this:

To delete (filename - external file):
(- FileIO_DeleteSavedGame({filename}); -).

and the similar read function works fine:

(- FileIO_LoadSavedGame({filename}); -).

as does write:

(- FileIO_WriteSavedGame({filename}); -).

So I have a definition:

The file of flagstatus is called “flagstatus”.

Then later, during runtime:

delete file of flagstatus.

I don’t know that the files were in controversial places, permission wise. For instance, moving things to the desktop often solves permission problems, rather than creates them (again, this is in Windows XP). However, if I place the gblorb on the desktop and run it in Glulxe/Git, files are created on the desktop, and can be updated there by Writing, but not deleted when the game issues the delete command.

I tried making a folder on the desktop, putting the game in there, letting the files be created in there, but Git/Glulxe would not delete them when the game was run from that folder, either. Again, Gargoyle did.

Is Gargoyle being cavalier or permissions-disrespectful? Do Glulxe/Git expect the files to be in particular places, or dislike this delete command? Or something else?

Thanks.

-Wade

Are those the functions from Kerkerkruip Permadeath or Erik Temple’s Roguelike save & restore? Is it displaying an error message, or does it act like it deleted the file, but it hasn’t actually been deleted?

My guess would be that the file usages don’t line up. We ran into a similar problem with Kerkerkruip before: github.com/i7/kerkerkruip/issues/113

As Dannii notes, those I6 functions presumably come from an extension, so it might also depend on whether they’re right. If you put together a simple example (or even just a compiled Blorb file that shows the problem) I’ll have a look.

The code does come from Erik Temple, and probably from one or both of those extensions, though I forget which one as he helped me out with this manually back when I was putting it together.

I’ll see if I can fix it with Dannii’s observation from above and then report back.

Re: what it’s doing, there are never any error messages. It just carries on as if it has deleted the file, though it hasn’t.

I notice it does delete saved game files when asked, just not regular data files.

-Wade

I’d recommend copying Kerkerkruip’s current versions of those functions. Note that you’d need to say that your external file “is a save file”.

Dannii, it seems clear to me that my problem is along the lines you described and involves filetypes -whether the file is a binary save file, or whether it’s a file with table content generated by the regular read, write, append commands.

What I have not been able to work out, from looking at Kerk permadeath and Kerk persistent data, is how to delete a regular table file. I don’t see that Kerk ever tries to do this?

I also experimented with adding in the Kerk flexible ‘existence’ code (IE one can use a single ‘if (blah) exists’ phrase to check for the existence of either a binary or regular file) but without my able to delete a regular file yet, I can’t really tell if it’s working.

Could you please show me how to delete a regular table file generated by I7?

The following is what I’ve used to date, and only works on binary files (in up to date interpreters):

[code]To delete (filename - external file):
(- FileIO_DeleteSavedGame({filename}); -).

[ FileIO_DeleteSavedGame extf struc fref res;
if ((extf < 1) || (extf > NO_EXTERNAL_FILES))
return FileIO_Error(extf, “tried to access a non-file”);
struc = TableOfExternalFiles–>extf;
fref = glk_fileref_create_by_name(fileusage_SavedGame + fileusage_BinaryMode, Glulx_ChangeAnyToCString(struc–>AUXF_FILENAME), 0);
if (fref == 0) rfalse;
if (glk_fileref_does_file_exist(fref)) {
res = glk_fileref_delete_file(fref);
if (res ~= 0)
CarryOutActivity( (+ failing to delete a saved game +) );
}
glk_fileref_destroy(fref);
];[/code]
-Wade

Oh, I missed your addendum post. Will simply declaring the table type file as a save file do the trick with the new code? Well, I’ll have a go.

EDIT: OK, that did not work. I suppose one can’t define the table files as save files as its a property of external files only.

In turn, the delete phrase only applies to ‘save files’, and if I make it apply to external files in general, the game compiles again, but I’m back to the original problem where table files just aren’t deleted.

-Wade

I’m not at my computer but I’m sure that inform comes with delete phrases for normal text/table/data files.

It doesn’t, actually.

Easy to make one: clone the FileIO_Exists function and change the glk_fileref_does_file_exist() call to glk_fileref_delete_file().

I just read docs 22.10 to 22.14 from cover to cover and there is no mention of delete. Also, the most expected parlance, ‘delete file of (whatever)’ doesn’t compile.

EDIT: Zarf, curse you for posting a solution while I’m typing up my post about how the last solution didn’t work!

-Wade

Oops. I was wrong. I think it would be better for I7 to support all the file types by default.