简体   繁体   中英

How to undo os.unlink() in Python?

I understand os.unlink() is like os.remove() in python as pointed out here. My question is: does it actually remove the file itself? My guess is not. Can I then undo this action?

Unlink / remove and more other functions that delete file usually delete only the file system information not the content itself. This is done for performance considerations. But that means that the space occupied by the content is free to be written over, so if you want to recover try and don't write too much to that partition (if it's a HDD) or the disk itself (if it's a SSD or flash based storage)/

That the way the recovery programs are able to recover a lot of files. Depending of the file system (if it journaled aka saves what operations have been made) you can recover more or less information about the file.

In some cases (special programs / settings or other situations i might not think about now) the content is written over for security pourpuses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM