src/server/plugins/postgresql/vfs.c

branch
webdav
changeset 304
33911d44111d
parent 298
8f5c556120a5
child 305
4db64fe30588
equal deleted inserted replaced
303:ad9ba51c8634 304:33911d44111d
285 WSBool iscol = iscollection[0] == 't' ? TRUE : FALSE; 285 WSBool iscol = iscollection[0] == 't' ? TRUE : FALSE;
286 if(iscol) { 286 if(iscol) {
287 s->st_mode |= 0x4000; 287 s->st_mode |= 0x4000;
288 } 288 }
289 } 289 }
290 // TODO: lastmodified, creationdate 290 s->st_mtime = pg_convert_timestamp(lastmodified);
291 // set some test values != 0
292 s->st_mtime = time(NULL);
293 291
294 if(contentlength) { 292 if(contentlength) {
295 int64_t len; 293 int64_t len;
296 if(util_strtoint(contentlength, &len)) { 294 if(util_strtoint(contentlength, &len)) {
297 s->st_size = len; 295 s->st_size = len;
861 pool_free(pool, pgfile); 859 pool_free(pool, pgfile);
862 pool_free(pool, pg->file); 860 pool_free(pool, pg->file);
863 pool_free(pool, pg); 861 pool_free(pool, pg);
864 pool_free(pool, dir); 862 pool_free(pool, dir);
865 } 863 }
864
865 time_t pg_convert_timestamp(const char *timestamp) {
866 // TODO: this is a very basic implementation that needs some work
867 // format yyyy-mm-dd HH:MM:SS
868
869 size_t len = timestamp ? strlen(timestamp) : 0;
870 if(len < 19) {
871 return 0;
872 } else if(len > 63) {
873 return 0;
874 }
875
876 char buf[64];
877 memcpy(buf, timestamp, len);
878
879 char *year_str = buf;
880 year_str[4] = '\0';
881
882 char *month_str = buf + 5;
883 month_str[2] = '\0';
884
885 char *day_str = buf + 8;
886 day_str[2] = '\0';
887
888 char *hour_str = buf + 11;
889 hour_str[2] = '\0';
890
891 char *minute_str = buf + 14;
892 minute_str[2] = '\0';
893
894 char *second_str = buf + 17;
895 second_str[2] = '\0';
896
897 struct tm tm;
898 memset(&tm, 0, sizeof(struct tm));
899 tm.tm_year = atoi(year_str) - 1900;
900 tm.tm_mon = atoi(month_str) - 1;
901 tm.tm_mday = atoi(day_str);
902 tm.tm_hour = atoi(hour_str);
903 tm.tm_min = atoi(minute_str);
904 tm.tm_sec = atoi(second_str);
905
906 #ifdef __FreeBSD__
907 return timelocal(&tm);
908 #else
909 return mktime(&tparts) - timezone;
910 #endif
911 }

mercurial