author | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-20 01:35:01 (UTC) |
commit | 876e1a4724a7bd75dc642e295de354241096e028 (patch) (side-by-side diff) | |
tree | a37c5dcc9d78e04bb6b859ab89d8cf81e6745087 /noncore/apps/opie-reader/Filedata.h | |
parent | 5fd6636ba3d94b48dd543887316c47c5388a43c2 (diff) | |
download | opie-876e1a4724a7bd75dc642e295de354241096e028.zip opie-876e1a4724a7bd75dc642e295de354241096e028.tar.gz opie-876e1a4724a7bd75dc642e295de354241096e028.tar.bz2 |
update - sorry it took so long. hope this works correctly
Diffstat (limited to 'noncore/apps/opie-reader/Filedata.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Filedata.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/Filedata.h b/noncore/apps/opie-reader/Filedata.h new file mode 100644 index 0000000..f920238 --- a/dev/null +++ b/noncore/apps/opie-reader/Filedata.h @@ -0,0 +1,51 @@ +#ifndef __FILEDATA_H +#define __FILEDATA_H + +#include <time.h> + +class CFiledata +{ + unsigned char* data; + bool m_own; + public: + CFiledata(tchar* d) + { + data = (unsigned char*)d; + m_own = false; + } + CFiledata(time_t dt, tchar* nm) + { + int nlen = ustrlen(nm)+1; + data = new unsigned char[sizeof(time_t)+sizeof(tchar)*nlen]; + *((time_t *)data) = dt; + memcpy(data+sizeof(time_t), nm, sizeof(tchar)*nlen); + m_own = true; + } + ~CFiledata() + { + if (m_own && data != NULL) + { + delete [] data; + qDebug("~Filedata: deleting"); + } + else + { + qDebug("~Filedata: not deleting"); + } + } + tchar* name() const { return (tchar*)(data+sizeof(time_t)); } + time_t date() { return *((time_t *)data); } + void setdate(time_t _t) { *((time_t *)data) = _t; } + unsigned char* content() { return data; } + size_t length() const { return sizeof(time_t)+sizeof(tchar)*(ustrlen(name())+1); } + bool operator==(const CFiledata& rhs) + { + return ((length() == rhs.length()) && (memcmp(data, rhs.data, length()) == 0)); + } + bool samename(const CFiledata& rhs) + { + return (ustrcmp((tchar *)(data+sizeof(time_t)),(tchar *)(rhs.data+sizeof(time_t))) == 0); + } +}; + +#endif |