29 #include <sys/types.h>
57 char * fname = va_arg(*params,
char*);
60 this->nfname = va_arg(*params,
size_t);
62 strncpy(this->fname, fname, 2048);
63 this->fname[2048] =
'\0';
66 (
unsigned char *)this->fname,
69 if (-1 == access(this->fname, R_OK)) {
72 this->handle = open(this->fname, O_RDONLY);
73 fstat(this->handle, &st);
76 tmp = localtime(&(st.st_mtime));
77 this->netag = strftime(this->etag,
sizeof(this->etag),
"%s", tmp);
83 this->
size = st.st_size;
85 ext = strrchr(this->fname,
'.');
90 this->mime_type =
"application/octet-stream";
93 if (NULL != this->mime_type) {
94 this->nmime_type = strlen(this->mime_type);
101 NULL, this->
size, PROT_READ, MAP_PRIVATE, this->handle, 0);
103 if (MAP_FAILED == this->data) {
117 if (MAP_FAILED != this->data && NULL != this->data) {
118 munmap(this->data, this->
size);
121 if (0 < this->handle) {
INIT_IFACE(Class, assetCtor, assetDtor, NULL)
static int assetCtor(void *_this, va_list *params)
unsigned long sdbm(const unsigned char *, size_t)
static unsigned long assetGetHash(void *_this)
char * getMimeType(const char *, size_t)
size_t rfc1123Gmt(char *, size_t, const time_t *)
static void assetHandleDouble(void *_this, void *_doub)
static void assetDtor(void *_this)
CREATE_CLASS(Asset, NULL, IFACE(Class), IFACE(Hashable))