Introduction
Introduction Statistics Contact Development Disclaimer Help
thumanreadable filemodes (code from sbase ls) - stagit - static git page genera…
git clone git://src.adamsgaard.dk/stagit
Log
Files
Refs
README
LICENSE
---
commit 3da41fa5dde944cd00171d384ce30c20fbb0c5a0
parent a7dd8c5f08f3e5c30cafdd8bcb4cc3f344e2d5cd
Author: Hiltjo Posthuma <[email protected]>
Date: Sat, 26 Dec 2015 12:57:14 +0100
humanreadable filemodes (code from sbase ls)
Diffstat:
M urmoms.c | 44 +++++++++++++++++++++++++++++…
1 file changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/urmoms.c b/urmoms.c
t@@ -633,6 +633,48 @@ writeblob(git_object *obj, const char *filename, git_off_…
return 0;
}
+const char *
+filemode(git_filemode_t m)
+{
+ static char mode[11];
+
+ memset(mode, '-', sizeof(mode) - 1);
+ mode[10] = '\0';
+
+ if (S_ISREG(m))
+ mode[0] = '-';
+ else if (S_ISBLK(m))
+ mode[0] = 'b';
+ else if (S_ISCHR(m))
+ mode[0] = 'c';
+ else if (S_ISDIR(m))
+ mode[0] = 'd';
+ else if (S_ISFIFO(m))
+ mode[0] = 'p';
+ else if (S_ISLNK(m))
+ mode[0] = 'l';
+ else if (S_ISSOCK(m))
+ mode[0] = 's';
+ else
+ mode[0] = '?';
+
+ if (m & S_IRUSR) mode[1] = 'r';
+ if (m & S_IWUSR) mode[2] = 'w';
+ if (m & S_IXUSR) mode[3] = 'x';
+ if (m & S_IRGRP) mode[4] = 'r';
+ if (m & S_IWGRP) mode[5] = 'w';
+ if (m & S_IXGRP) mode[6] = 'x';
+ if (m & S_IROTH) mode[7] = 'r';
+ if (m & S_IWOTH) mode[8] = 'w';
+ if (m & S_IXOTH) mode[9] = 'x';
+
+ if (m & S_ISUID) mode[3] = (mode[3] == 'x') ? 's' : 'S';
+ if (m & S_ISGID) mode[6] = (mode[6] == 'x') ? 's' : 'S';
+ if (m & S_ISVTX) mode[9] = (mode[9] == 'x') ? 't' : 'T';
+
+ return mode;
+}
+
int
writefilestree(FILE *fp, git_tree *tree, const char *path)
{
t@@ -673,7 +715,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
filesize = git_blob_rawsize((git_blob *)obj);
fputs("<tr><td>", fp);
- fprintf(fp, "%u", git_tree_entry_filemode_raw(entry));
+ fprintf(fp, "%s", filemode(git_tree_entry_filemode(entry)));
fprintf(fp, "</td><td><a href=\"%sfile/", relpath);
xmlencode(fp, filename, strlen(filename));
fputs(".html\">", fp);
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.