This repository was archived by the owner on Oct 11, 2022. It is now read-only.
forked from nickelsworth/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0068.pas
More file actions
58 lines (52 loc) · 1.91 KB
/
Copy path0068.pas
File metadata and controls
58 lines (52 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
Erik Appeldoorn
I've made a programm which erases a file absolutely and completely. Even when
it is undeleted it containes nothing.. So far so good.. But when I make a
sector-dump of the disk, it appears that there is still some text on the disk.
I don't get it. Nowhere in my programm I allocated text to memory, but the same
three sentences apear four times in the sector-dump. In the original file the
sentences begin at sentence number 1103. In the sector-dump the four blocks
appear at numbers 72 & 130 & 188 & 248. The totall dump is 251 sentences.
The floppy was newly formatted. What could be happening? Here's part of the
code.
}
var ZapFile:File;
ZapFileName:String;
ZapFilePos:Longint;
Buffer:array [1..406] of byte;
NumWritten, BufferSize, NumRead: word;
Procedure deleting(ZapFileName:string);
begin
Buffersize:=SizeOf(Buffer);
Assign(ZapFile,ZapFileName);
{$I-}
Reset(ZapFile,1);
{$I+}
repeat
ZapFilePos:=FilePos(ZapFile);
BlockRead(ZapFile,Buffer,BufferSize,NumRead);
FillChar(Buffer,BufferSize,#255);
Seek(ZapFile,ZapFilePos);
BlockWrite(ZapFile,Buffer,NumRead,NumWritten);
until (NumRead=0) or (NumWritten<>NumRead);
close(ZapFile);
Erase(ZapFile);
end;
{
Jan Doggen
I only had time to take a quick look; here are my suggestions:
- forget the reads
- make a CONST buffer, fill it with garbage or zeroes
(*in* the proc, so that it takes only stack space)
- FS := FileSize(ZapFile)
NrBlocks := FS DIV BufferSize
LastBlockSize := FS MOD BufferSize
For i:=1 to nrblocks blockwrite
If lastblocksize<>0 write that amount (never mind that the buffer is
larger)
close the file
- forget the $I. You don't query IOResult after $I, so all subsequent
I/O (on *all* files) goes wrong until you do. RTM.
- Instaed of this, use a FileExist function before you call your
proc.
}