Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: azdesign on August 28, 2012, 08:15:12 pm

Title: File access restriction while attempting to delete a file in-game
Post by: azdesign on August 28, 2012, 08:15:12 pm
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

-- EDIT

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.
Title: Re: File access restriction while attempting to delete a file in-game
Post by: ForeverZer0 on August 28, 2012, 11:30:03 pm
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:
File.open('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?
Title: Re: File access restriction while attempting to delete a file in-game
Post by: azdesign on August 29, 2012, 01:19:52 am
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

---EDIT---

: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:
Title: Re: File access restriction while attempting to delete a file in-game
Post by: Blizzard on August 29, 2012, 03:01:12 am
Keep in mind that the changes won't be visible until you restart the game.
Title: Re: File access restriction while attempting to delete a file in-game
Post by: azdesign on August 29, 2012, 03:24:55 am
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