Why do saves/ video files get corrupted?

461 views

So when a save file is corrupted, what is the reasoning behind it? Is it a software issue or hardware? Im guessing there are an unknown number of reasons, but it always made me think why.

In: 11

5 Answers

Anonymous 0 Comments

Any file on a computer can become corrupt, but in general files that are getting written to frequently are more susceptible. And anything that interrupts that file writing is just asking for it to be bork. Turning your game console off in the middle of a checkpoint or a gamesave is a great example. There’s all sorts of low level filesystem safeguards to minimize this, but nothing is perfect.

An example: storage is divided into small logical units called blocks. How big they are depends on OS and filesystem, but lets say they’re 1k or 1024 bytes. You create a new empty game save and you haven’t done anything yet, so the first few bytes are some file header stuff (what game, your user name), some bytes that represent your starting inventory and your location and then some bytes that mark end of file. This doesn’t take anywhere close to 1024 bytes so the “end of file” is well before the end of the block.

For error correction usually some checksum on all the data in the file is calculated and also written to the end of the file. If the contents of the file are read and don’t match the checksum, then its “corrupt”.

When your gamesave extends past the space in a single block, the last few bytes of that block are a pointer to the next block in the file aka “continued … over there -> block123” and over in block123 the bytes of game data continue. Rinse and repeat.

Now lets say either a software bug or a hardware issue (power button, power goes off) right when we’re modifying the gamesave. Maybe you just picked up some loot so we have to extend the file by a block. Its just allocated the new block and has written the pointer to it at the end of the old block, but hasn’t written any content in the new block yet. When the file is read again, there’s no content, no checksum, no end of file in the last block. Gamesave corrupt.

There’s numerous ways the game or the operating system or the hardware/power/user can mess up the writing of a file, this is just one possible way.

You are viewing 1 out of 5 answers, click here to view all answers.