'
' Example script for 2BrightSparks SyncBackPro V8 that uses NTFS
' compression on the copy of a file.
'
' SBLang=Basic
'
' http://www.2BrightSparks.com/
'

'
' This is a runtime script 
'
Function Description(ByRef ScriptType)
  Description = "NTFS compresses copies of a file"
  ScriptType = SCRIPTTYPE_RUN
End Function

'
' This function compresses the copy of a file.
'
' Note this function is not called if it is a simulation.
'
Sub RunAfterCopyFile(ToLeft, Filename, Failed)
  ' If the copy failed then dont even try
  If Failed then
    SBRunning.DebugOut(Filename, "Failed", 1)
    Exit Sub
  End If

  ' Only compress the copy if the original was compressed
  Attrs = SBRunning.GetFileAttrs(Filename, not ToLeft)
  if Attrs >= 0 then
    if (Attrs and 2048) = 0 then
      Exit Sub
    End If
  End If

  ' Get the full filename
  If ToLeft then
    FullName = SBRunning.LeftFolder & Filename
  Else
    FullName = SBRunning.RightFolder & Filename
  End If

  ' Compress it
  ErrorMsg = SBSystem.CompressFile(FullName)
  if ErrorMsg <> "" then
    SBRunning.NotCriticalError(Filename, "Could not compress: " & ErrorMsg)
  End If
End Sub
