Thread: File deletion

  1. #1
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005

    File deletion

    I was just watching an uninstaller run today (uninstalling WindowBlinds, trial period was over and I didn't think much of it anyway) and got to thinking, how are files actually physically erased from disk?

    I'm not talking about any particular OS here.

    So would I be right in thinking the file is overwritten with 0's? Or is the process dependant on the file system being used? Or the OS?

    Just curious.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Nah, mostly it's just by removing the directory entry from the file system.
    Actually, it's more like just set a specific bit in the directory entry which means 'deleted'.

    File recovery firms make use of this to recover the contents of files you've deleted by mistake.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Newport, South Wales, UK
    The file system is just another database, and like other databases, when you "delete" something, all you're doing is detaching it from a data structure. It's still physically there until something writes over it (now that it's a "free" block).

    P.S. Wouldn't it be cool to be able to run SQL queries on a file system?

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Secure deletion programs overwrite the file with garbage before deleting it so data recovery programs can't recover the file.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Join Date
    May 2004
    So what is the difference between a quick format and a regular (slow) format? I would guess that a slow format would "zero" out the file system.

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Newport, South Wales, UK
    Yes, although a slow format is more about verifying sectors. Touch every part of the volume to be erased and if the hardware comes back with an error at any point you've saved some heartache.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  4. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM