//Faza X: Actualizare programe

NewMsg() 

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

// -------------------------------------------------
PutMsg("VERIF:upd")
xx_exepathW := h_OsPath("INS\SALA_U_7.40A1\EXE\WIN")
xx_exepathL := h_OsPath("INS\SALA_U_7.40A1\EXE\LIN")
#IF !(h_FileEx(h_AddPath("HSALAR74",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("WSALAR74",    xx_exepathL)) .AND. ;
      h_FileEx(h_AddPath("HSALAR74.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 :={"HSALAR74","HSALAR74","HSALAR74.EXE","WSALAR74"}   
    xx_t :={"HSALAR",  "HSALAR74","HSALAR74.EXE","WSALAR74"}
#ELSE
    xx_s :={"HSALAR74.EXE","HSALAR74.EXE"}   
    xx_t :={"HSALAR.EXE",  "HSALAR74.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()


