VirtualBox

Changeset 34052 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Nov 13, 2010 1:29:03 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67734
Message:

tar: fixed bugs, listing output is identical to gnutar (when using --utc).

Location:
trunk/src/VBox/Runtime/common/zip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/zip/tarcmd.cpp

    r34046 r34052  
    5151#define RTZIPTARCMD_OPT_OWNER       1001
    5252#define RTZIPTARCMD_OPT_GROUP       1002
    53 #define RTZIPTARCMD_OPT_PREFIX      1003
     53#define RTZIPTARCMD_OPT_UTC         1003
     54#define RTZIPTARCMD_OPT_PREFIX      1004
    5455
    5556
     
    8687    /** The group ID to set when unpacking if pszGroup is not NULL. */
    8788    RTGID           gidGroup;
     89    /** Display the modification times in UTC instead of local time. */
     90    bool            fDisplayUtc;
    8891
    8992    /** What to prefix all names with when creating, adding, whatever. */
     
    229232 * @param   hVfsObj             The tar object to display
    230233 * @param   pszName             The name.
     234 * @param   pOpts               The tar options.
    231235 */
    232 static RTEXITCODE rtZipTarCmdDisplayEntryVerbose(RTEXITCODE rcExit, RTVFSOBJ hVfsObj, const char *pszName)
     236static RTEXITCODE rtZipTarCmdDisplayEntryVerbose(RTEXITCODE rcExit, RTVFSOBJ hVfsObj, const char *pszName,
     237                                                 PRTZIPTARCMDOPS pOpts)
    233238{
    234239    /*
     
    309314     * Format the modification time.
    310315     */
    311     char szModTime[32];
    312     RTTIME ModTime;
    313     if (RTTimeExplode(&ModTime, &UnixInfo.ModificationTime) == NULL)
     316    char       szModTime[32];
     317    RTTIME     ModTime;
     318    PRTTIME    pTime;
     319    if (!pOpts->fDisplayUtc)
     320        pTime = RTTimeLocalExplode(&ModTime, &UnixInfo.ModificationTime);
     321    else
     322        pTime = RTTimeExplode(&ModTime, &UnixInfo.ModificationTime);
     323    if (!pTime)
    314324        RT_ZERO(ModTime);
    315325    RTStrPrintf(szModTime, sizeof(szModTime), "%04d-%02u-%02u %02u:%02u",
     
    326336                        + 1
    327337                        + strlen(Group.Attr.u.UnixGroup.szName);
    328     ssize_t cchPad = cchUserGroup + cchSize + 1 < 18
    329                    ? 18 - (cchUserGroup + cchSize + 1)
     338    ssize_t cchPad = cchUserGroup + cchSize + 1 < 19
     339                   ? 19 - (cchUserGroup + cchSize + 1)
    330340                   : 0;
    331341
     
    403413                    RTPrintf("%s\n", pszName);
    404414                else
    405                     rcExit = rtZipTarCmdDisplayEntryVerbose(rcExit, hVfsObj, pszName);
     415                    rcExit = rtZipTarCmdDisplayEntryVerbose(rcExit, hVfsObj, pszName, pOpts);
    406416            }
    407417
     
    466476        { "--owner",                RTZIPTARCMD_OPT_OWNER, RTGETOPT_REQ_STRING },
    467477        { "--group",                RTZIPTARCMD_OPT_GROUP, RTGETOPT_REQ_STRING },
     478        { "--utc",                  RTZIPTARCMD_OPT_UTC,  RTGETOPT_REQ_NOTHING },
    468479
    469480        /* IPRT extensions */
     
    516527
    517528            case 'v':
    518                 Opts.fVerbose = false;
     529                Opts.fVerbose = true;
    519530                break;
    520531
     
    542553                break;
    543554
     555            case RTZIPTARCMD_OPT_UTC:
     556                Opts.fDisplayUtc = true;
     557                break;
    544558
    545559            /* iprt extensions */
  • trunk/src/VBox/Runtime/common/zip/tarvfs.cpp

    r34050 r34052  
    289289        i32Unsigned -= *(unsigned char *)pch;
    290290        i32Signed   -= *(signed   char *)pch;
    291         pch++;
    292291    } while (++pch != pchEnd);
    293292
     
    325324    if (RT_FAILURE(rc))
    326325        return VERR_TAR_BAD_CHKSUM_FIELD;
    327 //    if (   i32ChkSum          != i64HdrChkSum
    328 //        && i32ChkSumSignedAlt != i64HdrChkSum) /** @todo check this */
    329 //        return VERR_TAR_CHKSUM_MISMATCH;
     326    if (   i32ChkSum          != i64HdrChkSum
     327        && i32ChkSumSignedAlt != i64HdrChkSum) /** @todo check this */
     328        return VERR_TAR_CHKSUM_MISMATCH;
    330329
    331330    /*
     
    977976    /*
    978977     * Validate the header and convert to binary object info.
    979      * We pick up the two zero headers in the failure path here.
     978     * We pick up the start of the zero headers here in the failure path.
    980979     */
    981980    rc = rtZipTarHdrValidate(&Hdr);
     
    992991                if (RTVfsIoStrmIsAtEnd(pThis->hVfsIos))
    993992                    return VERR_EOF;
    994                 return VERR_TAR_EOS_MORE_INPUT;
     993
     994                /* Just drain the stream because blocksize may dictate that
     995                   there is a whole bunch of stuff comming up. */
     996                for (uint32_t i = 0; i < _32K / 512; i++)
     997                {
     998                    rc = RTVfsIoStrmRead(pThis->hVfsIos, &Hdr, sizeof(Hdr), true /*fBlocking*/, &cbRead);
     999                    if (rc == VINF_EOF)
     1000                        return VERR_EOF;
     1001                    if (RT_FAILURE(rc))
     1002                        break;
     1003                    Assert(cbRead == sizeof(Hdr));
     1004                }
    9951005            }
    9961006        }
     
    10351045            pIosData->cbFile          = Info.cbObject;
    10361046            pIosData->offFile         = 0;
    1037             pIosData->cbPadding       = 512 - (uint32_t)(Info.cbObject % 512);
     1047            pIosData->cbPadding       = Info.cbAllocated - Info.cbObject;
    10381048            pIosData->fEndOfStream    = false;
    10391049            pIosData->hVfsIos         = pThis->hVfsIos;
Note: See TracChangeset for help on using the changeset viewer.

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