File Shredder
File Shredder
Just a quick question about file handling. Let's say I have a file that is exactly 5 MB long. If I open this file with Purebasic, but overwrite the file with random 1's and 0's exactly 5 MB long, is it overwriting the file in the exact same place on the drive? Or, does the OS delete the first file and save the second file in an arbitrary place? In effect, I'm wondering if I can write a file shredder in Purebasic.
Re: File Shredder
I doubt you can guarantee that it would write to the same physical location an HDD will try to write to the same location but there are cases where it won't and there's no control over that.
As for SSD I'd be even more dubious that it would write to the same location.
As for SSD I'd be even more dubious that it would write to the same location.
Re: File Shredder
Gotcha. I was a bit doubtful myself but was curious. Thank you for your response.
Re: File Shredder
Shredders work as Lowlewel programs with HDD sector access.
But it does not help with SSD's because they decide for themselves in which segment, to protect the SSD, the sector writes.
But it does not help with SSD's because they decide for themselves in which segment, to protect the SSD, the sector writes.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: File Shredder
Writing a block to an flash memory (SSD) does not overwrite the old block. That's because all recent SSDs use something called "wear leveling".
To write a block to an SSD, you need to erase it first, and then you can write the new data. But erasing is an operation that can only be executed a limited number of times; each time you do an erase, you "weaken" the hardware, until the block cannot be properly erased anymore.
I cannot remember how many cycles a modern flash has.
The "flash memory controller" will take care of these bad sectors.
You could try to do that with an old USB Pen Drive and destroy it.
To write a block to an SSD, you need to erase it first, and then you can write the new data. But erasing is an operation that can only be executed a limited number of times; each time you do an erase, you "weaken" the hardware, until the block cannot be properly erased anymore.
I cannot remember how many cycles a modern flash has.
The "flash memory controller" will take care of these bad sectors.
You could try to do that with an old USB Pen Drive and destroy it.
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
- NicTheQuick
- Addict
- Posts: 1504
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: File Shredder
First of all, this has to do with the file system. Some file systems use copy-on-write, which means that new data is always written to a new location. The existing data blocks are retained until there is no more space for new data or as long as they are part of a snapshot. A good example of this is ZFS.
On the other hand, as already mentioned, this is also hardware-dependent. SSDs use wear-leveling, which ensures that all flash cells in the SSD are used equally. However, if an SSD is encrypted, it is possible to permanently delete data simply by erasing data and using a TRIM command. Normally, however, the operating system takes care of this.
On the other hand, as already mentioned, this is also hardware-dependent. SSDs use wear-leveling, which ensures that all flash cells in the SSD are used equally. However, if an SSD is encrypted, it is possible to permanently delete data simply by erasing data and using a TRIM command. Normally, however, the operating system takes care of this.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.