/* UnInstaller v1.0 by Panokostas Dimitris */

Options Results
addlib("libs:rexxsupport.library", 0, -30, 34)
addlib("libs:rexxreqtools.library", 0, -30, 0)
NL='0a'x
rtezrequest("Καλώς ήλθατε στον UnInstaller v1.0." || NL ||,
             "Δημιουργία του Πανοκώστα Δημήτρη στο 1997","Συνέχεια")
rtezrequest("Πρέπει να οριστεί ένα Installer logfile","Επιλογή logfile | Ακύρωση")
if rtresult=0 then call Finished
logfile=rtfilerequest(, , "Επιλέξτε ένα Installer logfile", ,)
if logfile="" then call Finished
open(1,logfile,"R")
i=0;d=0
do until eof(1)
  OneLine=ReadLN(1)
  If Index(OneLine,"Αντιγραφή")>0 then do
    i=i+1
    InstFileTmp=substr(OneLine,pos('"',OneLine),(pos('"',OneLine,(pos('"',OneLine)+1)))-(pos('"',OneLine)-1))
    InstPath=Strip(substr(OneLine,pos("στο",OneLine)+4),,".")
    If LastPos("/",InstFileTmp)>0 then InstFile=SubStr(InstFileTmp,LastPos("/",InstFileTmp)+1)
    If LastPos(":",InstFileTmp)>0 then InstFile=SubStr(InstFileTmp,LastPos(":",InstFileTmp)+1)
    If LastPos(":",InstFileTmp)=0 then InstFile=InstFileTmp
    If Right(InstPath,2)~='/"' & Right(InstPath,2)~=':"' then InstPath=Strip(InstPath,,'"')||"/"
    InstFull.I=strip(InstPath,,'"')||strip(InstFile,,'"')
  end
    If Index(OneLine,"Δημιουργία καινούργιου συρταριού")>0 then do
    d=d+1
    InstDrawer.d=strip(substr(OneLine,pos('"',OneLine),(pos('"',OneLine,(pos('"',OneLine)+1)))-(pos('"',OneLine)-1)),,'"')
  end
end
If I>0 then
  do j=1 to i
        rtezrequest("Διαγραφή αυτού του αρχείου;" || NL ||,
                    InstFull.j,"Ακύρωση | Ναι | Όχι | Διαγραφή Όλων")

  if rtresult=1 then call Finished
  if rtresult=0 then rtezrequest("Είστε σίγουρος για αυτό;","Ναι | Όχι")
        if rtresult=1 then do
          j=i
          call DeleteAll
          call DrawerCleanUp
        end
  if rtresult=2 then do
        if exists(InstFull.j) then delete(InstFull.j)
  end
  if rtresult=3 then noop
end
Call DrawerCleanUp

DrawerCleanUp:
If D>0 then
  do j=1 to d
        rtezrequest("Διαγραφή αυτού του καταλόγου;" || NL ||,
                    InstDrawer.j,"Ακύρωση | Ναι | Όχι | Διαγραφή Όλων")

  if rtresult=1 then call Finished
  if rtresult=0 then rtezrequest("Είστε σίγουρος για αυτό;","Ναι | Όχι")
        if rtresult=1 then do
          j=d
          call DeleteAllDrawers
          call Finished
        end
  if rtresult=2 then do
        if exists(InstDrawer.j) then delete(InstDrawer.j)
        if exists(InstDrawer.j||".info") then delete(InstDrawer.j||".info")
  end
  if rtresult=3 then noop
end
Call Finished

Finished:
rtezrequest("Τέλος Εργασίας!")
exit

DeleteAll:
do j=1 to i
        if exists(instfull.j) then delete(InstFull.j)
end

DeleteAllDrawers:
do j=1 to d
        if exists(InstDrawer.j) then delete(InstDrawer.j)
        if exists(InstDrawer.j||".info") then delete(InstDrawer.j||".info")
end
