summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-12-22 19:54:31 +0100
committerMax Kellermann <max@musicpd.org>2019-12-22 19:54:31 +0100
commit7bfe6a33043fee920703a06ff0b38d049b4b4647 (patch)
tree98fa47ab711f1870ed6883216ddcabfce5e71405 /test
parent9a577f8060413f7d5d2b557f7067dad4bceeeb36 (diff)
test/run_storage: add command "stat"
Diffstat (limited to 'test')
-rw-r--r--test/run_storage.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/run_storage.cxx b/test/run_storage.cxx
index 9db2215f4..e668c7347 100644
--- a/test/run_storage.cxx
+++ b/test/run_storage.cxx
@@ -90,6 +90,29 @@ Ls(Storage &storage, const char *path)
return EXIT_SUCCESS;
}
+static int
+Stat(Storage &storage, const char *path)
+{
+ const auto info = storage.GetInfo(path, false);
+ switch (info.type) {
+ case StorageFileInfo::Type::OTHER:
+ printf("other\n");
+ break;
+
+ case StorageFileInfo::Type::REGULAR:
+ printf("regular\n");
+ break;
+
+ case StorageFileInfo::Type::DIRECTORY:
+ printf("directory\n");
+ break;
+ }
+
+ printf("size: %llu\n", (unsigned long long)info.size);
+
+ return EXIT_SUCCESS;
+}
+
int
main(int argc, char **argv)
try {
@@ -117,6 +140,18 @@ try {
storage_uri);
return Ls(*storage, path);
+ } else if (strcmp(command, "stat") == 0) {
+ if (argc != 4) {
+ fprintf(stderr, "Usage: run_storage stat URI PATH\n");
+ return EXIT_FAILURE;
+ }
+
+ const char *const path = argv[3];
+
+ auto storage = MakeStorage(io_thread.GetEventLoop(),
+ storage_uri);
+
+ return Stat(*storage, path);
} else {
fprintf(stderr, "Unknown command\n");
return EXIT_FAILURE;