- metadata << "name: " << path << "\n";
- metadata << "mode: " << (stat_buf.st_mode & 07777) << "\n";
- metadata << "atime: " << stat_buf.st_atime << "\n";
- metadata << "ctime: " << stat_buf.st_ctime << "\n";
- metadata << "mtime: " << stat_buf.st_mtime << "\n";
- metadata << "user: " << stat_buf.st_uid << "\n";
- metadata << "group: " << stat_buf.st_gid << "\n";
-
- file_info["mode"] = encode_u16(stat_buf.st_mode & 07777);
- file_info["atime"] = encode_u64(encode_time(stat_buf.st_atime));
- file_info["ctime"] = encode_u64(encode_time(stat_buf.st_ctime));
- file_info["mtime"] = encode_u64(encode_time(stat_buf.st_mtime));
- file_info["user"] = encode_u32(stat_buf.st_uid);
- file_info["group"] = encode_u32(stat_buf.st_gid);
+ metadata << "name: " << uri_encode(path) << "\n";
+
+ file_info["mode"] = encode_int(stat_buf.st_mode & 07777);
+ file_info["mtime"] = encode_int(stat_buf.st_mtime);
+ file_info["user"] = encode_int(stat_buf.st_uid);
+ file_info["group"] = encode_int(stat_buf.st_gid);
+
+ struct passwd *pwd = getpwuid(stat_buf.st_uid);
+ if (pwd != NULL) {
+ file_info["user"] += " (" + uri_encode(pwd->pw_name) + ")";
+ }
+
+ struct group *grp = getgrgid(stat_buf.st_gid);
+ if (pwd != NULL) {
+ file_info["group"] += " (" + uri_encode(grp->gr_name) + ")";
+ }