CompareFiles/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: CompareFiles/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Das Unterprogramm prüft, ob beide Dateien identisch sind. | |
| 2 | + | ||
| 3 | + | Mit dem Unterprogramm können sowohl Binär- als auch Textdateien verglichen werden. | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | uses | |
| 7 | + | FileUtil, ...; | |
| 8 | + | ||
| 9 | + | ... | |
| 10 | + | ||
| 11 | + | function funDateienSindGleich(const conStrDateiname1, conStrDateiname2: string): boolean; | |
| 12 | + | var | |
| 13 | + | txtDatei1: file of char; | |
| 14 | + | txtDatei2: file of char; | |
| 15 | + | chrZeichen1: char; | |
| 16 | + | chrZeichen2: char; | |
| 17 | + | blnDateienSindGleich: boolean = True; | |
| 18 | + | ||
| 19 | + | begin | |
| 20 | + | ||
| 21 | + | Result := False; | |
| 22 | + | ||
| 23 | + | // Wenn beiden Dateien eine unterschiedliche Grösse haben, | |
| 24 | + | // dann beende das Unterprogramm | |
| 25 | + | if FileSize(conStrDateiname1) <> FileSize(conStrDateiname2) then | |
| 26 | + | exit; | |
| 27 | + | ||
| 28 | + | AssignFile(txtDatei1, UTF8ToSys(conStrDateiname1)); | |
| 29 | + | Reset(txtDatei1); | |
| 30 | + | ||
| 31 | + | AssignFile(txtDatei2, UTF8ToSys(conStrDateiname2)); | |
| 32 | + | Reset(txtDatei2); | |
| 33 | + | ||
| 34 | + | while (not EOF(txtDatei1)) or (not EOF(txtDatei2)) do | |
| 35 | + | begin | |
| 36 | + | Read(txtDatei1, chrZeichen1); | |
| 37 | + | Read(txtDatei2, chrZeichen2); | |
| 38 | + | // Wenn beide Zeichen unterschiedlich sind, | |
| 39 | + | // dann beende die Schleife | |
| 40 | + | if chrZeichen1 <> chrZeichen2 then | |
| 41 | + | begin | |
| 42 | + | blnDateienSindGleich := False; | |
| 43 | + | break; | |
| 44 | + | end; | |
| 45 | + | end; | |
| 46 | + | ||
| 47 | + | CloseFile(txtDatei1); | |
| 48 | + | CloseFile(txtDatei2); | |
| 49 | + | ||
| 50 | + | Result := blnDateienSindGleich; | |
| 51 | + | ||
| 52 | + | end; | |
| 53 | + | ``` | |
| 54 | + | ||
| 55 | + | Aufruf unter Windows: | |
| 56 | + | ||
| 57 | + | ``` pascal | |
| 58 | + | ||
| 59 | + | ... | |
| 60 | + | ||
| 61 | + | if funDateienSindGleich('E:\Test.txt', 'E:\Test1.txt') then | |
| 62 | + | ... | |
| 63 | + | ||
| 64 | + | ... | |
| 65 | + | ``` | |
| 66 | + | ||
| 67 | + | Aufruf unter Linux: | |
| 68 | + | ||
| 69 | + | ``` pascal | |
| 70 | + | ||
| 71 | + | ... | |
| 72 | + | ||
| 73 | + | if funDateienSindGleich('/home/user/Test.txt', '/home/user/Test1.txt') then | |
| 74 | + | ... | |
| 75 | + | ||
| 76 | + | ... | |
| 77 | + | ``` | |
| 78 | + | ||
| 79 | + | --- | |
| 80 | + | *From the Free Pascal wiki, page "CompareFiles/de", as it stood on 2020-02-11 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
