@echo off

"%CODEQL_EXTRACTOR_CPP_ROOT%/tools/%CODEQL_PLATFORM%/cpp-telemetry"

IF "%CODEQL_EXTRACTOR_CPP_TRAP_CACHING%"=="true" (
  IF "%CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_WRITE%"=="true" (
    REM Cache write. Copying tarballs into the cache.
    IF "%CODEQL_EXTRACTOR_CPP_TRAP_DIR%"=="" SET CODEQL_EXTRACTOR_CPP_TRAP_DIR=.
    IF "%CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_DIR%"=="" SET CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_DIR=.
    robocopy /s "%CODEQL_EXTRACTOR_CPP_TRAP_DIR%/tarballs" "%CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_DIR%/tarballs"
    IF errorlevel 1 SET ERRORLEVEL=0
  ) ELSE IF "%CODEQL_EXTRACTOR_CPP_OPTION_TRAP_CACHE_WRITE%"=="false" (
    REM Cache read. Generating manifests for cached TRAP files.
    "%CODEQL_EXTRACTOR_CPP_ROOT%/tools/%CODEQL_PLATFORM%/trap-cache-reader"
  )
)
