//Faza X: Actualizare programe

NewMsg() 

// -------------------------------------------------
h_OpenOut(MemoRead(homepath+"__MY_LOG.TXT"),.T.)

// -------------------------------------------------
PutMsg("VERIF:upd")
xx_exepathW := h_OsPath("INS\MARF_U_8.90A1\EXE\WIN")
xx_exepathL := h_OsPath("INS\MARF_U_8.90A1\EXE\LIN")
#IF !(h_FileEx(h_AddPath("HMARFA89",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("HMARFO89",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("HMARFS89",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("HMARFU89",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("HMARFT45",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("HMARFA89.EXE",xx_exepathW)) .AND. ;
      h_FileEx(h_AddPath("HMARFO89.EXE",xx_exepathW)) .AND. ;
      h_FileEx(h_AddPath("HMARFS89.EXE",xx_exepathW)) .AND. ;
      h_FileEx(h_AddPath("HMARFU89.EXE",xx_exepathW)) .AND. ;
      h_FileEx(h_AddPath("HMARFT45.EXE",xx_exepathW)))
      h_PutLine("*** Eroare despachetare update!")
      Abandon("C")
#ENDIF  
xx_os := h_Os("l")
PutMsg("Actualizare programe")

xx_s    := NIL
xx_t    := NIL
xx_exepathX := NIL
#IF "linux" $ xx_os
    xx_s :={"HMARFA89","HMARFA89","HMARFO89","HMARFO89","HMARFS89","HMARFS89","HMARFU89","HMARFU89","HMARFT45","HMARFT45","HMARFT45.EXE","WMARFT45"}   
    xx_t :={"HMARFA",  "HMARFA89","HMARFO",  "HMARFO89","HMARFS",  "HMARFS89","HMARFU",  "HMARFU89","HMARFT",  "HMARFT45","HMARFT45.EXE","WMARFT45"}
#ELSE
    xx_s :={"HMARFA89.EXE","HMARFA89.EXE","HMARFO89.EXE","HMARFO89.EXE","HMARFS89.EXE","HMARFS89.EXE","HMARFU89.EXE","HMARFU89.EXE","HMARFT45.EXE","HMARFT45.EXE"}   
    xx_t :={"HMARFA.EXE",  "HMARFA89.EXE","HMARFO.EXE",  "HMARFO89.EXE","HMARFS.EXE",  "HMARFS89.EXE","HMARFU.EXE",  "HMARFU89.EXE","HMARFT.EXE",  "HMARFT45.EXE"}
#ENDIF

xx_j      :=1
xx_lErr   :=.F.
xx_lFirst :=.T.
#WHILE xx_j<=Len(xx_s)
    xx_sFisDep := xx_t[xx_j]
    xx_sLocFile:= h_AddPath(xx_s[xx_j],IIF(h_FileExt(xx_s[xx_j])="EXE",xx_exepathW,xx_exepathL))
   //Verificare daca trebuie copiat
    lCopy:=.f.
    aDs   := Directory(xx_sLocFile)
    aDd   := Directory(xx_sFisDep)
    #IF Len(aDd)=0
        //Fisierul destinatie nu exista 
        #IF h_FDExist(xx_sFisDep)="D"
            #IF xx_lFirst 
                xx_lFirst := .F.
                h_PutLine("")
                h_PutLine("Actualizare porograme: ")
            #ENDIF
            h_PutLine("**  Actualizare nereusita "+xx_sFisDep+" Exista catalog cu acelasi nume!")
        #ELSE
            lCopy := .t.
        #ENDIF
    #ELSEIF (Len(aDd)=1) .AND. (DtoS(aDd[1,3])+aDd[1,4]) < (DtoS(aDs[1,3])+aDs[1,4])
        //Fisierul destinatie este mai veche decat cel de referinta 
        lCopy := .t.
    #ENDIF
    #IF (lCopy == .t.)
        #IF xx_lFirst 
            xx_lFirst := .F.
            h_PutLine("")
            h_PutLine("Actualizare porograme: ")
        #ENDIF
        #IF h_SafeErase(xx_sFisDep) .AND.                     ;
            (IIf("windows"$Lower(h_Build()),                  ;
                 h_CopyFile(xx_sLocFile,xx_sFisDep),          ;
                 (h_Dos("cp -p "+xx_sLocFile+" "+xx_sFisDep), ;
                  (h_FileEx(xx_sFisDep) .AND. h_HFDAttrib(xx_sFisDep)))))
            h_PutLine("    Actualizat "+xx_sFisDep)
        #ELSE
            h_PutLine("*** Eroare, actualizare nereusita: "+xx_sFisDep+" Reluati!")
            xx_lErr := .T.
        #ENDIF
    #ENDIF
    xx_j:=xx_j+1    
#ENDDO 

// -------------------------------------------------

#IF !xx_lFirst
    h_PutLine("")
#ENDIF

h_CloseOut("")

// -------------------------------------------------

// h_MesHlp("Terminat", 0)
EndMsg()


