Author Topic: File access restriction while attempting to delete a file in-game  (Read 1080 times)

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
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.
« Last Edit: August 29, 2012, 02:32:45 AM by azdesign »
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline ForeverZer0

  • CP's Pedophile
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3255
  • LV: 298
  • Gender: Male
  • Remember you are unique, just like everyone else.
    • View Profile
Re: File access restriction while attempting to delete a file in-game
« Reply #1 on: August 29, 2012, 05:30:03 AM »
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:
Code: [Select]
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?
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.

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: File access restriction while attempting to delete a file in-game
« Reply #2 on: August 29, 2012, 07: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:
« Last Edit: August 29, 2012, 07:32:09 AM by azdesign »
~ Check out my deviantart http://my-az-design.deviantart.com/ ~

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20016
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: File access restriction while attempting to delete a file in-game
« Reply #3 on: August 29, 2012, 09:01:12 AM »
Keep in mind that the changes won't be visible until you restart the game.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


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

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

Offline azdesign

  • Awakened Visionist
  • **
  • Posts: 64
  • LV: 2
  • Gender: Male
    • View Profile
Re: File access restriction while attempting to delete a file in-game
« Reply #4 on: August 29, 2012, 09: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
~ Check out my deviantart http://my-az-design.deviantart.com/ ~