Vale, ya lo he conseguido, pongo la solución por si alguien necesita también algo parecido:
La estructura que contiene la lista de directorios es:
Código Delphi
[-]
type
Tdirectorio = record
nombre: widestring;
path:widestring;
anterior: longword;
path_completo: widestring;
end;
var
iso_for:record
tabla_path:array of Tdirectorio;
tabla_path_num:longword;
num_directoriosANSI: longword;
directoriosANSI: array of Tdirectorio;
end;
Y la solución para extraterlo:
Código Delphi
[-]
ISO_for.tabla_path_num:=1;
setlength(ISO_for.tabla_path,ISO_for.tabla_path_num);
ISO_for.tabla_path[ISO_for.tabla_path_num-1].anterior:=1;
ISO_for.tabla_path[ISO_for.tabla_path_num-1].path_completo:='\';
ISO_for.tabla_path[ISO_for.tabla_path_num-1].nombre:='\';
for a := 0 to iso_for.num_directoriosANSI - 1 do
begin
st:=iso_for.directoriosANSI[a].nombre;
if st[1]<>'\' then st:='\'+st;
st2:='';
for b := length(st) downto 1 do
begin
if (st[b]='\') then
begin
st2:=Copy(st, 0, b);
result:=false;
for c := 0 to ISO_for.tabla_path_num - 1 do
begin
if uppercase(st2)=uppercase(ISO_for.tabla_path[c].path_completo) then
begin
result:=true;
break;
end;
end;
if result then
else
begin
inc(ISO_for.tabla_path_num);
setlength(ISO_for.tabla_path,ISO_for.tabla_path_num);
ISO_for.tabla_path[ISO_for.tabla_path_num-1].path_completo:=st2;
for c := length(st2) downto 0 do
begin
if ((st2[c]='\')and(c<>Length(st2)))or(c=0) then
begin
if c=0 then
begin
ISO_for.tabla_path[ISO_for.tabla_path_num-1].anterior:=1;
ISO_for.tabla_path[ISO_for.tabla_path_num-1].nombre:=copy(st2,c,Length(st2));
end
else
begin
ISO_for.tabla_path[ISO_for.tabla_path_num-1].nombre:=copy(st2,c+1,Length(st2));
end;
break;
end;
end;
end;
st2:=st2+'\';
end;
end;
end;
for b := 1 to ISO_for.tabla_path_num - 1 do
begin
st2:=iso_for.tabla_path[b].path_completo;
for c := length(st2) downto 0 do
begin
if ((st2[c]='\')and(c<>Length(st2)))or(c=0) then
begin
if c=0 then
begin
iso_for.tabla_path[b].anterior:=1;
end
else
begin
st2:=Copy(st2,0,c);
for a := 0 to ISO_for.tabla_path_num - 1 do
begin
if UpperCase(st2)=UpperCase(iso_for.tabla_path[a].path_completo) then
begin
iso_for.tabla_path[b].anterior:=a;
Break;
end;
end;
end;
break;
end;
end;
end;