SecureErase (delete file)

function SecureErase(what: string, passes: number): boolean;

This function tries to delete the what file from the local file-system using a secure erasure algorithm. This means that the file will be overwritten with crypto-secure pseudo-random data before it’s actually deleted from the storage medium, in order to make it unrecoverable. For this reason, depending on the size of the file, this function may take a while to complete.

The second parameter passes is optional, and specifies how many times the file needs to be overwritten with crypto-secure pseudo-random data before the actual deletion occurs. If left unspecified, the file will be overwritten only once and then deleted.

This function accepts the following parameters:

Parameter Type Requirement Explanation
what string required must be a valid and existing file in a local file system
passes number optional the number of times the file should be overwritten with random data before its actual deletion, if this parameter is not specified the file will be overwritten once

Possible return values:

Value Explanation
true the function succeeded: the file was deleted
true the function failed: the file was not deleted

Example (Windows file system, no optional parameter)

{
  if (SecureErase('C:\\Data\\SomeFile.docx')) {
    // ...
  }
}

Example (Linux file system, with optional parameter)

{
  if (SecureErase('/home/someuser/data/SomeFile.pdf')) {
    // ...
  }
}