61
Programmers corner / Possible bug with add context menu when select files with same name
« on: May 14, 2009, 12:15:06 PM »
error resolved by modificate the code
now there is no sharing filename with ''on 'computer' " and the warning make his come back
BUG if you answer yes on the warning, the name is incremented
Quote
function Tmainfrm.addFilesFromString(files:string; under:Ttreenode=NIL):Tfile;
......
var
f: Tfile;
kind, s, fn, fntemp: string; //mod by mars
doubles: TStringDynArray;
res: integer;
.........
// warn upon double filenames
doubles:=NIL;
s:=files;
while s > '' do
begin
fn:=chopLine(s);
if isExtension(fn, '.lnk')
or directoryExists(fn) and fileExists(fn+'\target.lnk')
then
begin
fntemp:=resolveLnk(fn);
files:=xtpl(files,[fn,fntemp]);
fn:=fntemp;
end;
if (length(fn) = 3) and (fn[2] = ':') then fn:=fn[1]+fn[2] // unit root folder
else fn:=ExtractFileName(fn);
if existsNodeWithName(fn, under) then
if addString(fn, doubles) > MAX_DUPE then
break;
end;
now there is no sharing filename with ''on 'computer' " and the warning make his come back
BUG if you answer yes on the warning, the name is incremented