diff --git a/src/protocol/fsp/fsp.c b/src/protocol/fsp/fsp.c
index d18f33b9f..b887ebbf7 100644
--- a/src/protocol/fsp/fsp.c
+++ b/src/protocol/fsp/fsp.c
@@ -81,6 +81,18 @@ compare(FSP_RDENTRY *a, FSP_RDENTRY *b)
return strcmp(a->name, b->name);
}
+static void
+display_entry(FSP_RDENTRY *fentry, unsigned char dircolor[])
+{
+ printf("%10d\t", fentry->size,
+ fentry->name, fentry->type == FSP_RDTYPE_DIR ? "/" : "");
+ if (fentry->type == FSP_RDTYPE_DIR && *dircolor)
+ printf("", dircolor);
+ printf("%s", fentry->name);
+ if (fentry->type == FSP_RDTYPE_DIR && *dircolor)
+ printf("");
+ puts("");
+}
static void
sort_and_display_entries(FSP_DIR *dir, unsigned char dircolor[])
@@ -106,14 +118,7 @@ sort_and_display_entries(FSP_DIR *dir, unsigned char dircolor[])
(int (*)(const void *, const void *)) compare);
for (i = 0; i < size; i++) {
- printf("%10d\t", table[i].size, table[i].name,
- table[i].type == FSP_RDTYPE_DIR ? "/" : "");
- if (table[i].type == FSP_RDTYPE_DIR && *dircolor)
- printf("", dircolor);
- printf("%s", table[i].name);
- if (table[i].type == FSP_RDTYPE_DIR && *dircolor)
- printf("");
- puts("");
+ display_entry(&table[i], dircolor);
}
}
@@ -153,14 +158,7 @@ fsp_directory(FSP_SESSION *ses, struct uri *uri)
while (!fsp_readdir_native(dir, &fentry, &fresult)) {
if (!fresult) break;
- printf("%10d\t", fentry.size,
- fentry.name, fentry.type == FSP_RDTYPE_DIR ? "/" : "");
- if (fentry.type == FSP_RDTYPE_DIR && *dircolor)
- printf("", dircolor);
- printf("%s", fentry.name);
- if (fentry.type == FSP_RDTYPE_DIR && *dircolor)
- printf("");
- puts("");
+ display_entry(&fentry, dircolor);
}
fsp_closedir(dir);
}