return 0;
}
+float
+rounder(float var)
+{
+ float value = (int)(var * 10 + .5);
+ return (float)value / 10;
+}
+
+const char *
+convertbytes(int bytes)
+{
+ (float)bytes;
+ static char outp[255] = "hi";
+ if (bytes < 1024) sprintf(outp, "%u %s", bytes, "B");
+ else if (bytes < 1048576) sprintf(outp, "%0.1f %s", rounder(bytes/1024.0), "K");
+ else sprintf(outp, "%0.1f %s", rounder(bytes/1048576.0), "M");
+ return outp;
+}
+
int
writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t filesize)
{
writeheader(fp, filename);
fputs("<p> ", fp);
xmlencode(fp, filename, strlen(filename));
- fprintf(fp, " (%juB)", (uintmax_t)filesize);
+ fprintf(fp, " (%s)", convertbytes((int)filesize));
fputs("</p><hr/>", fp);
if (lc > 0)
fprintf(fp, "%dL", lc);
else
- fprintf(fp, "%juB", (uintmax_t)filesize);
+ fprintf(fp, "%s", convertbytes((int)filesize));
fputs("</td></tr>\n", fp);
git_object_free(obj);
} else if (!git_submodule_lookup(&module, repo, entryname)) {