From 1f980897f6947dd17eaa0190b2c1a23fb700636b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 17 Jul 2019 10:53:22 +0200 Subject: fstree: add support for spaces in filenames This commit adds a mechanism to fstree_from_file to support filenames with spaces in them by quoting the entire string. Quote marks can still be used inside file names by escaping them with a backslash. Back slashes (if that is your thing) can also be escaped. Signed-off-by: David Oberhollenzer --- tests/fstree_from_file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/fstree_from_file.c b/tests/fstree_from_file.c index c5b9b5b..f4fc345 100644 --- a/tests/fstree_from_file.c +++ b/tests/fstree_from_file.c @@ -14,6 +14,8 @@ static const char *testdesc = "nod /chardev 0600 6 7 c 13 37\n" "nod /blkdev 0600 8 9 b 42 21\n" "pipe /pipe 0644 10 11\n" +"dir \"/foo bar\" 0755 0 0\n" +"dir \"/foo bar/ test \\\"/\" 0755 0 0\n" " sock /sock 0555 12 13 "; int main(void) @@ -55,6 +57,20 @@ int main(void) assert(strcmp(n->name, "dir") == 0); assert(n->data.dir->children == NULL); + n = n->next; + assert(n->mode == (S_IFDIR | 0755)); + assert(n->uid == 0); + assert(n->gid == 0); + assert(strcmp(n->name, "foo bar") == 0); + assert(n->data.dir->children != NULL); + + assert(n->data.dir->children->next == NULL); + assert(n->data.dir->children->mode == (S_IFDIR | 0755)); + assert(n->data.dir->children->uid == 0); + assert(n->data.dir->children->gid == 0); + assert(strcmp(n->data.dir->children->name, " test \"") == 0); + assert(n->data.dir->children->data.dir->children == NULL); + n = n->next; assert(n->mode == (S_IFIFO | 0644)); assert(n->uid == 10); -- cgit v1.2.3