3,7 → 3,7 |
(************************************************) |
(* OIDPLUS.PAS *) |
(* Author: Daniel Marschall *) |
(* Revision: 2022-02-15 *) |
(* Revision: 2022-02-14 *) |
(* License: Apache 2.0 *) |
(* This file contains: *) |
(* - "OIDplus for DOS" program *) |
21,7 → 21,7 |
Dos, Crt, StrList, VtsFuncs, VtsCui, OidFile, OidUtils; |
|
const |
VERSIONINFO = 'Revision: 2022-02-15'; |
VERSIONINFO = 'Revision: 2022-02-14'; |
DEFAULT_STATUSBAR = '(C)2020-2022 ViaThinkSoft. Licensed under the terms of the Apache 2.0 license.'; |
TITLEBAR_LEFT_TEXT = 'OIDplus'; |
DISKIO_SOUND_DEBUGGING = false; |
36,8 → 36,6 |
TREEVIEW_INDENT = 0; |
TREEVIEW_INCLUDE_DESC = true; |
TREEVIEW_WIDTH = 80; |
OID_EXTENSION = '.OID'; |
TREEVIEW_FILENAME = 'OIDTREE.TXT'; |
|
procedure _Pause; |
var |
282,7 → 280,7 |
begin |
(* Put all found files into a list *) |
CreateList(list); |
FindFirst(RepeatStr('?',8)+OID_EXTENSION, Archive, DirInfo); |
FindFirst('????????.OID', Archive, DirInfo); |
while DosError = 0 do |
begin |
sId := Copy(DirInfo.Name, 1, 8); |
391,7 → 389,7 |
AsnEditor(newOID) and |
DescEditor(newOID) then |
begin |
newfilename := newOID^.FileId + OID_EXTENSION; |
newfilename := newOID^.FileId + '.OID'; |
if _WriteOidFile(newfilename, newOID, true) then |
begin |
(* Add link to original file and enable the saving of it *) |
410,12 → 408,11 |
begin |
for i := 0 to ListCount(oid^.SubIds)-1 do |
begin |
filenameChild := FileIdPart(ListGetElement(oid^.SubIds, i)) + OID_EXTENSION; |
filenameChild := FileIdPart(ListGetElement(oid^.SubIds, i)) + '.OID'; |
if FileExists(filenameChild) then |
begin |
CreateOidDef(childOID); |
if _ReadOidFile(filenameChild, childOID, false) and |
(childOID^.Parent = oid^.FileId + oid^.DotNotation) then |
if _ReadOidFile(filenameChild, childOID, false) then |
begin |
DeleteChildrenRecursive(childOID); |
end; |
437,7 → 434,7 |
|
(* Remove forward reference in parent OID *) |
(* (this is the most important part) *) |
filenameParent := FileIdPart(selfOID^.Parent) + OID_EXTENSION; |
filenameParent := FileIdPart(selfOID^.Parent) + '.OID'; |
if FileExists(filenameParent) then |
begin |
CreateOidDef(parentOID); |
452,7 → 449,7 |
end; |
|
(* Delete own file *) |
filenameSelf := selfOID^.FileId + OID_EXTENSION; |
filenameSelf := selfOID^.FileId + '.OID'; |
if FileExists(filenameSelf) then |
begin |
DeleteFile(filenameSelf); |
572,7 → 569,7 |
|
(* Now prepare the menu entries *) |
|
CreateList(subsel); (* Contains the human-readable OID name *) |
CreateList(subsel); (* Contains the human readable OID name *) |
CreateList(subfiles); (* Contains the file name *) |
|
if oid^.Parent = '' then |
587,27 → 584,21 |
if (oid^.Parent <> '') and not isRoot then |
begin |
sTmp := oid^.Parent; |
subfile := FileIdPart(sTmp) + OID_EXTENSION; |
subfile := FileIdPart(sTmp) + '.OID'; |
if FileExists(subfile) then |
begin |
CreateOidDef(tmpOID); |
if not _ReadOidFile(subfile, tmpOID, true) then |
begin |
if _ReadOidFile(subfile, tmpOID, true) then |
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID)) |
else |
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + ' (READ ERROR)'); |
ListAppend(subfiles, 'ERROR: '+subfile+' Read error or file invalid'); |
end |
else |
begin |
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID)); |
ListAppend(subfiles, subfile); |
end; |
FreeOidDef(tmpOID); |
end |
else |
begin |
ListAppend(subsel, 'Go to parent ' + DotNotationPart(sTmp) + ' (FILE NOT FOUND)'); |
ListAppend(subfiles, 'ERROR: File '+subfile+' was not found'); |
end; |
ListAppend(subfiles, subfile); |
end; |
|
if isRoot then |
620,32 → 611,21 |
for i := 0 to ListCount(oid^.SubIds)-1 do |
begin |
sTmp := ListGetElement(oid^.SubIds, i); |
subfile := FileIdPart(sTmp) + OID_EXTENSION; |
subfile := FileIdPart(sTmp) + '.OID'; |
if FileExists(subfile) then |
begin |
CreateOidDef(tmpOID); |
if not _ReadOidFile(subfile, tmpOID, true) then |
begin |
if _ReadOidFile(subfile, tmpOID, true) then |
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID)) |
else |
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + ' (READ ERROR)'); |
ListAppend(subfiles, 'ERROR: Read error at file '+subfile+', or file is invalid.'); |
end |
else if tmpOID^.Parent <> oid^.FileId + oid^.DotNotation then |
begin |
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + ' (BAD BACKREF)'); |
ListAppend(subfiles, 'ERROR: File '+subfile+' has a wrong back-reference.'); |
end |
else |
begin |
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + _ShowASNIds(tmpOID)); |
ListAppend(subfiles, subfile); |
end; |
FreeOidDef(tmpOID); |
end |
else |
begin |
ListAppend(subsel, 'Go to child ' + DotNotationPart(sTmp) + ' (FILE NOT FOUND)'); |
ListAppend(subfiles, 'ERROR: File '+subfile+' was not found'); |
end; |
ListAppend(subfiles, subfile); |
end; |
|
if oid^.DotNotation <> '' then |
703,7 → 683,7 |
begin |
if _DeleteConfirmation then |
begin |
sTmp := FileIdPart(oid^.Parent) + OID_EXTENSION; |
sTmp := FileIdPart(oid^.Parent) + '.OID'; |
DeleteOidRecursive(oid); |
if FileExists(sTmp) then |
begin |
711,7 → 691,7 |
end |
else |
begin |
ShowMessage('Parent file ' + sTmp + ' was not found', 'ERROR', true); |
ShowMessage('Parent file ' + sTmp + ' not found', 'ERROR', true); |
_Pause; |
exitRequest := true; |
end; |
724,17 → 704,15 |
else |
begin |
(* Normal OID *) |
(* Above we already checked if the files are valild and existing *) |
sTmp := ListGetElement(subfiles, subselres); |
if Copy(sTmp, 1, Length('ERROR: ')) = 'ERROR: ' then |
if FileExists(sTmp) then |
begin |
Delete(sTmp, 1, Length('ERROR: ')); |
ShowMessage(sTmp, 'ERROR', true); |
_Pause; |
filename := sTmp; |
end |
else |
begin |
filename := sTmp; |
ShowMessage('File ' + sTmp + ' not found', 'ERROR', true); |
_Pause; |
end; |
end; |
FreeList(subsel); |
766,7 → 744,7 |
var |
rootFile: string; |
begin |
rootFile := ZeroPad(0, 8) + OID_EXTENSION; |
rootFile := ZeroPad(0, 8) + '.OID'; |
_GetRootFile := rootFile; |
if not FileExists(rootFile) then |
begin |
833,7 → 811,10 |
begin |
if (sTmp[i]=#13) or (sTmp[i]=#10) then sTmp[i] := ' '; |
end; |
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH); |
if Length(sTmp) > TREEVIEW_WIDTH then |
begin |
sTmp := Copy(sTmp, 1, TREEVIEW_WIDTH-3) + '...'; |
end; |
_GetTreeViewLine := sTmp; |
end; |
|
853,26 → 834,19 |
begin |
sTmp := ListGetElement(oid^.SubIds, i); |
CreateOidDef(suboid); |
childFilename := FileIdPart(sTmp) + OID_EXTENSION; |
childFilename := FileIdPart(sTmp) + '.OID'; |
if not FileExists(childFilename) then |
begin |
sTmp := 'ERROR: MISSING ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!'; |
sTmp := 'ERROR: ' + childFilename + ' FILE MISSING (CONTAINS ' + DotNotationPart(sTmp) + ')!'; |
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH); |
WriteLn(F, sTmp); |
end |
else if not _ReadOidFile(childFilename, suboid, false) then |
begin |
sTmp := 'ERROR: READ ERROR AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!'; |
sTmp := 'ERROR: ' + childFilename + ' READ ERROR (CONTAINS ' + DotNotationPart(sTmp) + ')!'; |
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH); |
WriteLn(F, sTmp); |
end |
else if suboid^.Parent <> oid^.FileId + oid^.DotNotation then |
begin |
(* This can happen if a file is missing, and then another OID gets this filename since the number seems to be free *) |
sTmp := 'ERROR: BAD BACKREF AT ' + childFilename + ' (SHALL CONTAIN ' + DotNotationPart(sTmp) + ')!'; |
sTmp := TrimLineToWidth(sTmp, TREEVIEW_WIDTH); |
WriteLn(F, sTmp); |
end |
else |
begin |
_RecTreeExport(suboid, F, indent+1); |
900,7 → 874,7 |
Exit; |
end; |
|
Assign(F, TREEVIEW_FILENAME); |
Assign(F, 'OIDTREE.TXT'); |
{$I-} |
Rewrite(F); |
{$I+} |
907,7 → 881,7 |
if IoResult <> 0 then |
begin |
(* Can happen if disk is read-only (Runtime Error 150) *) |
ShowMessage('Cannot open '+TREEVIEW_FILENAME+' for writing.', 'ERROR', true); |
ShowMessage('Cannot open OIDTREE.TXT for writing.', 'ERROR', true); |
_Pause; |
DrawStatusBar(DEFAULT_STATUSBAR); |
Exit; |
927,7 → 901,7 |
DrawStatusBar(DEFAULT_STATUSBAR); |
if res then |
begin |
ShowMessage('TreeView successfully exported as '+TREEVIEW_FILENAME, 'TREEVIEW EXPORT', true); |
ShowMessage('TreeView successfully exported as OIDTREE.TXT', 'TREEVIEW EXPORT', true); |
_Pause; |
end; |
end; |