帮助!恢复 Eclipse 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/712505/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Help! Recover Eclipse file
提问by StoneHeart
I'm using eclipse, when i close eclipse, it ask me save a file, I press yes and eclipse shuts down. When I open my computer I see that the drive only has 3 bytes left, and I get a bad feeling. I go to my file and oh my god, it's totally blank, size is 0 byte! :(
我正在使用 eclipse,当我关闭 eclipse 时,它要求我保存文件,我按是,eclipse 关闭。当我打开我的电脑时,我看到驱动器只剩下 3 个字节了,我有一种不好的感觉。我转到我的文件,天哪,它完全是空白的,大小为 0 字节!:(
I need that file back, can a free recovery program can work on this case?
我需要那个文件,免费的恢复程序可以处理这种情况吗?
回答by Newtopian
Sometimes Eclipse keeps the changes it made to the files you edit. Does not always work but it's worth a try :
有时 Eclipse 会保留它对您编辑的文件所做的更改。并不总是有效,但值得一试:
- Find you file in your (package, project, navigator) explorer.
- Right click on your file and look for the menus to compare... (I recommend Compare though in your case it will not matter since the file is now empty)
- Choose Local History... from the sub menu
- 在(包、项目、导航器)资源管理器中找到您的文件。
- 右键单击您的文件并查找要比较的菜单...(我建议比较,尽管在您的情况下这无关紧要,因为文件现在是空的)
- 从子菜单中选择本地历史...
If you are lucky and had been using Eclipse to edit the file you should find a few entries there. Look them up, chances are you will find the content.
如果您很幸运并且一直在使用 Eclipse 来编辑该文件,您应该会在那里找到一些条目。查找它们,您很可能会找到内容。
This has helped me countless times and saved my ass on many occasions. However, every times I resort to it I always feel like hitting my head with a baseball bat for not commiting changes to the source control system earlier.
这对我有无数次帮助,并多次救了我的屁股。然而,每次我诉诸它时,我总是觉得用棒球棒敲我的头,因为我没有更早地对源代码控制系统进行更改。
good luck, if that does not work I fear the SO will not be of much help to you :-(
祝你好运,如果那不起作用,我担心 SO 不会对你有多大帮助:-(
--- EDIT --- Little something that can help make this trick a tad bit more useful.
--- 编辑 --- 一些可以帮助使这个技巧更有用的东西。
you can change the amount of information Eclipse keeps in local history, go to your preferences and then general->Workspace->Local History (Indigo here, may be different on other versions). If you tend to be light headed or burn the midnight oil a bit too much this will help you repair the next day that bug fix you insisted on finishing before going to sleep.
您可以更改 Eclipse 在本地历史记录中保留的信息量,转到您的首选项,然后选择 General->Workspace->Local History(此处为 Indigo,其他版本可能有所不同)。如果您倾向于头昏眼花或开夜车太多,这将帮助您在第二天修复您坚持在睡觉前完成的错误修复。
回答by Joe Koberg
If you know some phrase or uncommon word from your file, you can search the raw sectors of the hard drive for pieces of text. This will turn up the text anywhere it might have been written: as paged out virtual memory, as a stil-existant file (temp file or saved file), or as temporary or saved file that was deleted and the space has not yet been rewritten.
如果您从文件中知道一些短语或不常见的词,您可以在硬盘驱动器的原始扇区中搜索文本片段。这会将文本显示在任何可能已写入的位置:作为调出的虚拟内存、作为 stil-existant 文件(临时文件或保存的文件),或者作为已删除且空间尚未被重写的临时或保存文件.
But it will be slow. And if the file was never written to disk, it will yield nothing. And what it yields may be fragmented or incomplete.
但是会很慢。如果文件从未写入磁盘,则不会产生任何结果。它产生的结果可能是零散的或不完整的。
Boot a Knoppix CD and start grepping! Knoppix is a linux installation that runs from CD, without writing to your hard drive.
启动 Knoppix CD 并开始 grepping!Knoppix 是一种从 CD 运行的 Linux 安装程序,无需写入您的硬盘驱动器。
get knoppix: http://www.kernel.org/pub/dist/knoppix/KNOPPIX_V6.0.1CD-2009-02-08-EN.iso)
Boot it. Start a terminal. Search the hard drive:
$ sudo grep "Four score and seven years" /dev/hda
If it turns up anything, copy and paste to a text editor, and save to usb stick or send it to yourself via web-based email.
获取 knoppix:http://www.kernel.org/pub/dist/knoppix/KNOPPIX_V6.0.1CD-2009-02-08-EN.iso )
启动它。启动终端。搜索硬盘:
$ sudo grep "Four score and seven years" /dev/hda
如果出现任何问题,请复制并粘贴到文本编辑器,然后保存到 U 盘或通过基于网络的电子邮件将其发送给自己。
If you have SCSI or SATA disks, you need to use /dev/sda
instead of /dev/hda
如果您有 SCSI 或 SATA 磁盘,则需要使用/dev/sda
而不是/dev/hda
The other answer is correct, every moment that OS continues running decreases your recovery chances. pull the power and use another computer to prepare the knoppix CD.
另一个答案是正确的,操作系统继续运行的每一刻都会减少您的恢复机会。拔掉电源并使用另一台计算机准备 knoppix CD。
回答by thedz
First, turn off the computer. Every second that it is on and being used at this point reduces the chance you'll recover your file.
首先,关闭计算机。它打开并在此时使用的每一秒都会减少您恢复文件的机会。