I have written a small utility that reports any filenames that are too long for a CD (64 characters.) It displays the length and name of any filename that is too long or if all the filenames are legal, it reports the length of the longest name.
This program compiles and runs properly with the Win32 version of the compiler (1.0.6) but fails to run when compiled and run under OS/2. The same program compiles and runs properly when compiled with Virtual Pascal.
Program CheckCDName;
Uses SysUtils;
Var
Sr : TSearchRec;
SCode : Integer;
ErrCount : Integer;
SMask : String;
MaxLen : Integer;
Function Plural(Count : Integer; Singular, Plurals : String) : String;
Begin
If Count = 1 Then Plural := Singular Else Plural := Plurals;
End; { Plural }
Begin
Assign(Output, '');
rewrite(Output);
If (ParamCount = 0) Then SMask := '*'
Else SMask := ParamStr(1);
ErrCount := 0;
MaxLen := 0;
{WriteLn('Searching on : ', SMask);}
SCode := FindFirst(SMask, faAnyFile, Sr);
{WriteLn('SCode : ', SCode);}
While (SCode = 0) Do
Begin
{WriteLn(Sr.Name);}
If (Length(Sr.Name) > MaxLen) then MaxLen := Length(Sr.Name);
If (Length(Sr.Name) > 64) Then
Begin
WriteLn(Length(Sr.Name):3, ' ', Sr.Name);
Inc(ErrCount);
End;
SCode := FindNext(Sr);
{WriteLn('SCode : ', SCode);}
End;
FindClose(Sr);
If (ErrCount = 0) Then WriteLn('No invalid names (', MaxLen, ')')
Else WriteLn(ErrCount, ' Invalid ', Plural(ErrCount, 'name',
'names'));
Close(Output);
End.The output with debug statements is :
Searching on : *
SCode : -87
No invalid names (0)
With the debugging write statements uncommented, the result from the FindFirst was always -87. Is this a FindFirst bug or am I missing something?
Cheers
Rolf Grunsky
