Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Filedata.h

Go to the documentation of this file.
00001 #ifndef __FILEDATA_H
00002 #define __FILEDATA_H
00003 
00004 #include <time.h>
00005 
00006 class CFiledata
00007 {
00008     unsigned char* data;
00009     bool m_own;
00010  public:
00011     CFiledata(tchar* d)
00012         {
00013             data = (unsigned char*)d;
00014             m_own = false;
00015         }
00016     CFiledata(time_t dt, tchar* nm)
00017         {
00018             int nlen = ustrlen(nm)+1;
00019             data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen];
00020             *((time_t *)data) = dt;
00021             memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen);
00022             m_own = true;
00023         }
00024     ~CFiledata()
00025         {
00026             if (m_own && data != NULL)
00027                 {
00028                     delete [] data;
00029 //              qDebug("~Filedata: deleting");
00030                 }
00031             else
00032             {
00033 //              qDebug("~Filedata: not deleting");
00034             }
00035         }
00036     tchar* name() const { return (tchar*)(data+sizeof(time_t)); }
00037     time_t date() { return *((time_t *)data); }
00038     void setdate(time_t _t) { *((time_t *)data) = _t; }
00039     unsigned char* content() { return data; }
00040     size_t length() const { return sizeof(time_t)+sizeof(tchar)*(ustrlen(name())+1); }
00041     bool operator==(const CFiledata& rhs)
00042         {
00043             return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0));
00044         }
00045     bool samename(const CFiledata& rhs)
00046         {
00047             return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0);
00048         }
00049 };
00050 
00051 #endif

Generated on Sat Nov 5 16:16:55 2005 for OPIE by  doxygen 1.4.2