Changeset 2635


Ignore:
Timestamp:
24/02/2010 20:12:00 (2 years ago)
Author:
chris
Message:

Add method to get updated modification time of
BackupClientFileAttributes?.

Add listing of attribute modification time to bbackupquery "list -t"
command.

Location:
box/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupquery/BackupQueries.cpp

    r2625 r2635  
    436436} 
    437437 
     438static std::string GetTimeString(BackupStoreDirectory::Entry& en, 
     439        bool useLocalTime) 
     440{ 
     441        std::ostringstream out; 
     442        out << BoxTimeToISO8601String(en.GetModificationTime(), useLocalTime); 
     443 
     444        if(en.HasAttributes()) 
     445        { 
     446                const StreamableMemBlock &storeAttr(en.GetAttributes()); 
     447                BackupClientFileAttributes attr(storeAttr); 
     448                out << "~" << BoxTimeToISO8601String(attr.GetModificationTime(), 
     449                        useLocalTime); 
     450        } 
     451         
     452        return out.str(); 
     453} 
    438454 
    439455// -------------------------------------------------------------------------- 
     
    535551                { 
    536552                        // Show UTC times... 
    537                         std::string time = BoxTimeToISO8601String( 
    538                                 en->GetModificationTime(), false); 
    539                         printf("%s ", time.c_str()); 
     553                        printf("%s ", GetTimeString(*en, false).c_str()); 
    540554                } 
    541555 
     
    543557                { 
    544558                        // Show local times... 
    545                         std::string time = BoxTimeToISO8601String( 
    546                                 en->GetModificationTime(), true); 
    547                         printf("%s ", time.c_str()); 
     559                        printf("%s ", GetTimeString(*en, true).c_str()); 
    548560                } 
    549561                 
  • box/trunk/lib/backupclient/BackupClientFileAttributes.cpp

    r2633 r2635  
    648648} 
    649649 
     650// -------------------------------------------------------------------------- 
     651// 
     652// Function 
     653//              Name:    BackupClientFileAttributes::GetModificationTime() 
     654//              Purpose: Returns the modification time embedded in the 
     655//                       attributes. 
     656//              Created: 2010/02/24 
     657// 
     658// -------------------------------------------------------------------------- 
     659box_time_t BackupClientFileAttributes::GetModificationTime() const 
     660{ 
     661        // Got something loaded 
     662        if(GetSize() <= 0) 
     663        { 
     664                THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); 
     665        } 
     666         
     667        // Make sure there are clear attributes to use 
     668        EnsureClearAvailable(); 
     669        ASSERT(mpClearAttributes != 0); 
     670 
     671        // Check if the decrypted attributes are small enough, and the type of attributes stored 
     672        if(mpClearAttributes->GetSize() < (int)sizeof(int32_t)) 
     673        { 
     674                THROW_EXCEPTION(BackupStoreException, AttributesNotUnderstood); 
     675        } 
     676        int32_t *type = (int32_t*)mpClearAttributes->GetBuffer(); 
     677        ASSERT(type != 0); 
     678        if(ntohl(*type) != ATTRIBUTETYPE_GENERIC_UNIX) 
     679        { 
     680                // Don't know what to do with these 
     681                THROW_EXCEPTION(BackupStoreException, AttributesNotUnderstood); 
     682        } 
     683         
     684        // Check there is enough space for an attributes block 
     685        if(mpClearAttributes->GetSize() < (int)sizeof(attr_StreamFormat)) 
     686        { 
     687                // Too small 
     688                THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); 
     689        } 
     690 
     691        // Get pointer to structure 
     692        attr_StreamFormat *pattr = (attr_StreamFormat*)mpClearAttributes->GetBuffer(); 
     693 
     694        return box_ntoh64(pattr->ModificationTime); 
     695} 
    650696 
    651697// -------------------------------------------------------------------------- 
  • box/trunk/lib/backupclient/BackupClientFileAttributes.h

    r2460 r2635  
    4848        void WriteAttributes(const char *Filename,  
    4949                bool MakeUserWritable = false) const; 
    50  
     50        box_time_t GetModificationTime() const; 
     51         
    5152        bool IsSymLink() const; 
    5253 
Note: See TracChangeset for help on using the changeset viewer.