adds file mode to fileinfo property

Tue, 12 Mar 2019 09:35:04 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 12 Mar 2019 09:35:04 +0100
changeset 519
ac5ac55b1b2e
parent 518
cca3e7aa30ed
child 520
da2b0cc44e4f

adds file mode to fileinfo property

dav/finfo.c file | annotate | diff | comparison | revisions
--- a/dav/finfo.c	Sat Mar 09 16:29:59 2019 +0100
+++ b/dav/finfo.c	Tue Mar 12 09:35:04 2019 +0100
@@ -75,19 +75,13 @@
     return resource_set_finfo_s(&s, res, finfo);
 }
 
-static int buf_write_date(UcxBuffer *buf, time_t t) {
-    struct tm *date = gmtime(&t);
-    char str[32];
-    size_t len = strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT", date);
-    return ucx_buffer_write(str, 1, len, buf);
-}
-
 int resource_set_finfo_s(struct stat *s, DavResource *res, uint32_t finfo) {
     if(finfo == 0) {
         return 0;
     }
     
     DavXmlNode *content = NULL;
+    DavXmlNode *last = NULL;
     
     if(finfo & FINFO_DATE == FINFO_DATE) {
         char str[32];
@@ -95,13 +89,23 @@
         strftime(str, 32, "%a, %d %b %Y %H:%M:%S GMT", date);
         DavXmlNode *mtime = dav_xml_createnode_with_text(DAV_NS, "mtime", str);
         content = mtime;
+        last = mtime;
     }
 #ifndef _WIN32
     if(finfo & FINFO_OWNER == FINFO_OWNER) {
         // TODO
     }
     if(finfo & FINFO_MODE == FINFO_MODE) {
-        // TODO
+        mode_t mode = s->st_mode & 07777;
+        char str[32];
+        snprintf(str, 32, "%o", (int)mode);
+        DavXmlNode *xmode = dav_xml_createnode_with_text(DAV_NS, "mode", str);
+        if(last) {
+            last->next = xmode;
+        } else {
+            content = xmode;
+        }
+        last = xmode;
     }
 #endif
     

mercurial