![]() |
#21 |
Veteran
Join Date: Apr 2007
Posts: 1,950
Donated: $40
![]() |
We already write to savefile.new, then move savefile to savefile.old, then move savefile.new to savefile, then delete savefile.(old|new), checking for errors and issues at each step. Windows is just an arse.
__________________
takkaria whispers something about options. -more- |
![]() |
![]() |
![]() |
#22 |
Knight
Join Date: Aug 2009
Posts: 670
![]() |
Without use of fsync() this did not help, atleast with ext4 filesystem, allmost any system crash or power down results in broken savefile. I never had any problems under windows.
|
![]() |
![]() |
![]() |
#23 | |
Angband Devteam member
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 42
Posts: 1,516
![]() |
Quote:
http://en.wikipedia.org/wiki/Ext4 |
|
![]() |
![]() |
![]() |
#24 |
Swordsman
Join Date: Feb 2010
Posts: 405
![]() |
The 2-tier approach I'm suggesting would use 2 completely separate *files*. So if I'm using Tiburon as my character, the level-switched save might be Tiburon.level, while the user-invoked or game-exit save might be Tiburon. That way, no matter what happens, you have 1 file that is no more than a single level old, which is safe.
|
![]() |
![]() |
![]() |
#25 | |
Prophet
Join Date: Apr 2007
Location: Seattle, WA
Posts: 6,726
Donated: $40
![]() |
Quote:
Before renaming the file, force a disk sync--standard practice for editor apps and databases. For a panic save file, it's a good idea to reopen it and verifying that it is valid before renaming. |
|
![]() |
![]() |
![]() |
#26 | |
Adept
Join Date: Jul 2009
Posts: 137
![]() |
Quote:
![]() |
|
![]() |
![]() |
![]() |
#27 |
Prophet
Join Date: Dec 2009
Posts: 9,022
![]() |
This sounds basically like what I suggested, right? Validate save, if it's good, replace old save with it, otherwise, use old save.
|
![]() |
![]() |
![]() |
#28 |
Swordsman
Join Date: Feb 2010
Posts: 405
![]() |
I still see some issues...
First, some of this tends to be OS-specific, or at least the calls to implement the disk sync, are likely to be OS-specific. Second, it still feels like the process that Pete/Derakon are mentioning, is potentially subject to crashes at the wrong time. It might be *safer*...but it's not safe. |
![]() |
![]() |
![]() |
#29 |
Apprentice
Join Date: Jan 2008
Location: Finland
Age: 44
Posts: 55
![]() |
|
![]() |
![]() |
![]() |
#30 |
Prophet
Join Date: Dec 2009
Posts: 9,022
![]() |
Tiburon: to my knowledge, moving a file is an atomic operation on all filesystems -- that is to say, it either succeeds, or it doesn't happen at all. So if you have two files "goodsave" and "panicsave" and you try to move panicsave over goodsave (having previously validated panicsave is a valid savefile), then there's nothing, that will corrupt panicsave that wouldn't also screw over your entire hard drive (i.e. catastrophic hardware failure).
Writing a file isn't an atomic operation, which is why panicsaves are not reliable in the first place. |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Great" drops replaced by "good" drops in vaults: bug or feature? | PowerWyrm | Vanilla | 14 | February 27, 2010 15:54 |
Feature request: make "summon unique" do nothing when there are no uniques | bron | Vanilla | 11 | December 22, 2009 16:25 |
Feature request: change "Purification and Healing" prayer book. | bron | Vanilla | 1 | December 18, 2009 23:19 |
"repeat" Command just little bit "smarter" | ClaytonAguiar | Vanilla | 8 | June 17, 2009 15:01 |
Roguelike idea from "Lost Magic" DS game - Mr. @ teaches typing! | ekolis | Idle chatter | 10 | October 19, 2007 03:25 |