1

As a newbie I used my original.cpp file as a template for a different project and somehow I managed to lose it. (I normally use CodeBlocks and I am not very familiar with VS) I have the .../Release/original.obj and the .../Release/vc100.pdb files and obviously the *.manifest and *.exe files. Is there any way I can recover my original code? fwiw it is mainly math functions that is a pain to rewrite but maybe recoverable? Thanks.

  • 1
    If you lose source code it is Game Over in C++. There is nothing that can reconstruct C++ code from an .obj file. Having the .pdb available may give you symbolic information, but the code structure is lost. When writing C++ make sure you **never** lose your source code. As mentioned above, an SCM is mandatory. – IInspectable Nov 16 '13 at 17:45

1 Answers1

1

Your options are most likely limited.

The best option is to try to recover the original file itself. Did you copy it to a new location and then delete the original? If so, there is a chance that the raw data might still be written to the hard drive and you can try an undelete tool such as Recuva (google "undelete" for plenty of alternatives). Be aware that as you continue to use the same disk, the chance of recovery goes down, because you are constantly exposed to the risk that new data is written to the same blocks. This includes installing and using the undelete tool, so the recommended practice for recovering a file is to turn the machine off as soon as you realise (ideally by cutting the power), and boot/undelete from another disk/machine to access the drive.

Failing that, you can try to decompile the object file. This will not replicate your original code, but with some (most likely: a lot of) effort you could reverse engineer and restore it manually, particularly if the code is still fresh in your mind. Have a look at this question.

For your future projects, I highly recommend using a version control system such as Git. Being able to recover from accidental overwrites like this is just one of the many benefits it provides.

Community
  • 1
  • 1
JBentley
  • 6,099
  • 5
  • 37
  • 72