VirtualBox

Changeset 84763 in vbox


Ignore:
Timestamp:
Jun 10, 2020 3:28:53 PM (4 years ago)
Author:
vboxsync
Message:

Validation Kit/TXS: Added support for creating (packing) files / directories on the guest.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/TestExecServ/TestExecService.cpp

    r84683 r84763  
    821821
    822822    RTStrFree(pszExpanded);
     823    return rc;
     824}
     825
     826/**
     827 * Packs a tar file / directory.
     828 *
     829 * @returns IPRT status code from send.
     830 * @param   pPktHdr             The pack file packet.
     831 */
     832static int txsDoPackFile(PCTXSPKTHDR pPktHdr)
     833{
     834    int rc;
     835    char *pszFile = NULL;
     836    char *pszSource = NULL;
     837
     838    /* Packet cursor. */
     839    const char *pch = (const char *)(pPktHdr + 1);
     840
     841    if (txsIsStringValid(pPktHdr, "file", pch, &pszFile, &pch, &rc))
     842    {
     843        if (txsIsStringValid(pPktHdr, "source", pch, &pszSource, &pch, &rc))
     844        {
     845            char *pszSuff = RTPathSuffix(pszFile);
     846
     847            const char *apszArgs[7];
     848            unsigned cArgs = 0;
     849
     850            apszArgs[cArgs++] = "RTTar";
     851            apszArgs[cArgs++] = "--create";
     852
     853            apszArgs[cArgs++] = "--file";
     854            apszArgs[cArgs++] = pszFile;
     855
     856            if (   pszSuff
     857                && (   !RTStrICmp(pszSuff, ".gz")
     858                    || !RTStrICmp(pszSuff, ".tgz")))
     859                apszArgs[cArgs++] = "--gzip";
     860
     861            apszArgs[cArgs++] = pszSource;
     862
     863            RTEXITCODE rcExit = RTZipTarCmd(cArgs, (char **)apszArgs);
     864            if (rcExit != RTEXITCODE_SUCCESS)
     865                rc = VERR_GENERAL_FAILURE; /** @todo proper return code. */
     866            else
     867                rc = VINF_SUCCESS;
     868
     869            rc = txsReplyRC(pPktHdr, rc, "RTZipTarCmd(\"%s\",\"%s\")",
     870                            pszFile, pszSource);
     871
     872            RTStrFree(pszSource);
     873        }
     874        RTStrFree(pszFile);
     875    }
     876
    823877    return rc;
    824878}
     
    30093063        else if (txsIsSameOpcode(pPktHdr, "GET FILE"))
    30103064            rc = txsDoGetFile(pPktHdr);
     3065        else if (txsIsSameOpcode(pPktHdr, "PKFILE"))
     3066            rc = txsDoPackFile(pPktHdr);
    30113067        else if (txsIsSameOpcode(pPktHdr, "UNPKFILE"))
    30123068            rc = txsDoUnpackFile(pPktHdr);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette