VirtualBox

Changeset 71261 in vbox


Ignore:
Timestamp:
Mar 7, 2018 2:55:23 PM (7 years ago)
Author:
vboxsync
Message:

Guest Control: Implemented support for IGuestFsObjInfo::[accessTime,birthTime,changeTime,modificationTime].

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r66857 r71261  
    55
    66/*
    7  * Copyright (C) 2011-2017 Oracle Corporation
     7 * Copyright (C) 2011-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    635635struct GuestFsObjData
    636636{
    637     /** Helper function to extract the data from
    638      *  a certin VBoxService tool's guest stream block. */
     637    /** @name Helper functions to extract the data from a certin VBoxService tool's guest stream block.
     638     * @{ */
    639639    int FromLs(const GuestProcessStreamBlock &strmBlk);
    640640    int FromMkTemp(const GuestProcessStreamBlock &strmBlk);
    641641    int FromStat(const GuestProcessStreamBlock &strmBlk);
     642    /** @}  */
     643
     644    /** @name Static helper functions to work with time from stream block keys.
     645     * @{ */
     646    static PRTTIMESPEC TimeSpecFromKey(const GuestProcessStreamBlock &strmBlk, const Utf8Str &strKey, PRTTIMESPEC pTimeSpec);
     647    static int64_t UnixEpochNsFromKey(const GuestProcessStreamBlock &strmBlk, const Utf8Str &strKey);
     648    /** @}  */
    642649
    643650    int64_t              mAccessTime;
  • trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp

    r67914 r71261  
    55
    66/*
    7  * Copyright (C) 2011-2017 Oracle Corporation
     7 * Copyright (C) 2011-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3636# include <iprt/file.h>
    3737#endif /* DEBUG */
    38 
     38#include <iprt/time.h>
    3939
    4040
     
    102102}
    103103
     104/**
     105 * Extracts the timespec from a given stream block key.
     106 *
     107 * @return Pointer to handed-in timespec, or NULL if invalid / not found.
     108 * @param  strmBlk              Stream block to extract timespec from.
     109 * @param  strKey               Key to get timespec for.
     110 * @param  pTimeSpec            Where to store the extracted timespec.
     111 */
     112/* static */
     113PRTTIMESPEC GuestFsObjData::TimeSpecFromKey(const GuestProcessStreamBlock &strmBlk, const Utf8Str &strKey, PRTTIMESPEC pTimeSpec)
     114{
     115    AssertPtrReturn(pTimeSpec, NULL);
     116
     117    Utf8Str strTime = strmBlk.GetString(strKey.c_str());
     118    if (strTime.isEmpty())
     119        return NULL;
     120
     121    if (!RTTimeSpecFromString(pTimeSpec, strTime.c_str()))
     122        return NULL;
     123
     124    return pTimeSpec;
     125}
     126
     127/**
     128 * Extracts the in nanoseconds relative from Unix epoch for a given stream block key.
     129 *
     130 * @return Nanoseconds relative from Unix epoch, or 0 if invalid / not found.
     131 * @param  strmBlk              Stream block to extract nanoseconds from.
     132 * @param  strKey               Key to get nanoseconds for.
     133 */
     134/* static */
     135int64_t GuestFsObjData::UnixEpochNsFromKey(const GuestProcessStreamBlock &strmBlk, const Utf8Str &strKey)
     136{
     137    RTTIMESPEC TimeSpec;
     138    if (!GuestFsObjData::TimeSpecFromKey(strmBlk, strKey, &TimeSpec))
     139        return 0;
     140
     141    return TimeSpec.i64NanosecondsRelativeToUnixEpoch;
     142}
     143
    104144int GuestFsObjData::FromStat(const GuestProcessStreamBlock &strmBlk)
    105145{
     
    125165        else if (strType.equalsIgnoreCase("d"))
    126166            mType = FsObjType_Directory;
    127         /** @todo Add more types! */
    128         else
     167        else /** @todo Add more types! */
    129168            mType = FsObjType_Unknown;
     169        /* Dates. */
     170        mAccessTime       = GuestFsObjData::UnixEpochNsFromKey(strmBlk, "st_atime");
     171        mBirthTime        = GuestFsObjData::UnixEpochNsFromKey(strmBlk, "st_birthtime");
     172        mChangeTime       = GuestFsObjData::UnixEpochNsFromKey(strmBlk, "st_ctime");
     173        mModificationTime = GuestFsObjData::UnixEpochNsFromKey(strmBlk, "st_mtime");
    130174        /* Object size. */
    131175        rc = strmBlk.GetInt64Ex("st_size", &mObjectSize);
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