File access restriction while attempting to delete a file in-game

Started by azdesign, August 28, 2012, 08:15:12 pm

Previous topic - Next topic


I need to change the value of Game.ini in-game, this way, I should create script to create temporary file to store whatever changes I want, then delete the Game.ini, then rename my temporary file as Game.ini, and in the end, restart the game.

Error while deleting 'Game.ini', permission denied. This game with its windows-only platform renders the chmod useless. I tried chmod 0666,0777 against the file, none works. Or, is this file locked by the game while the game is running ? Is there is a way to unlock it ? Thanks in advance  :D


Yes, the file was locked while the game is running, is there is any alternate way ? The goal is to change the Game.ini based on what we choose in-game after the game restart. The scenario is, I need my script to change the title and library used depending of what language I choose. Before I choose last resort by telling user to delete game.ini and rename game.ini.bak into game.ini manually :facepalm: after the game terminated.
~ Check out my deviantart ~


No, the file isn't locked, and you can write to it while the game is playing.

Are you sure you its not just set as readonly, as I suggested in the other topic to keep the library from changing?
I did a simple:'Game.ini', 'wb') {|f| f.write('some text') }

It did just that. The file became a document with only the text: "some text". I never closed the game. It remained after the game was closed. Are you running from the editor, or launching the Game.exe directly?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.


No, it wasn't set as read only. I ran the game, while running, attempt to delete the Game.ini via windows explorer, error appeared : "The action can't be completed because the file is open in RGSS Player". Close the game, delete it again, it works. So, yes, in my case, it's locked  :???:. Im using windows 7 64bit with standard UAC setting


:O.o: Deleting it throws file access exception while rewriting it as you did, was okay, so I changed the algorithm not to use temporary/backup files, instead, rewrite it directly. Well, my question has answered but still, why I cannot delete it If I can change its value that's all. I assume there are "locked for delete", "locked for edit"  :wacko: oh well, Thanks  :haha:
~ Check out my deviantart ~


Keep in mind that the changes won't be visible until you restart the game.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS

Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.


Of course, I will put a print "Please restart the game for the changes to be applied", let the player use this chance to save, then exit
~ Check out my deviantart ~