changeset 323:052dede32761

list files in resource directories
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Jan 2013 16:48:35 +0100
parents 7233461e2f61
children 64925c94825c
files Resources/EmbedResources.py
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/EmbedResources.py	Mon Jan 07 15:33:53 2013 +0100
+++ b/Resources/EmbedResources.py	Mon Jan 07 16:48:35 2013 +0100
@@ -123,6 +123,7 @@
 #pragma once
 
 #include <string>
+#include <list>
 
 namespace Orthanc
 {
@@ -167,6 +168,8 @@
     const void* GetDirectoryResourceBuffer(DirectoryResourceId id, const char* path);
     size_t GetDirectoryResourceSize(DirectoryResourceId id, const char* path);
     void GetDirectoryResource(std::string& result, DirectoryResourceId id, const char* path);
+
+    void ListResources(std::list<std::string>& result, DirectoryResourceId id);
   }
 }
 """)
@@ -328,6 +331,35 @@
 
 
 #####################################################################
+## List the resources in a directory
+#####################################################################
+
+cpp.write("""
+    void ListResources(std::list<std::string>& result, DirectoryResourceId id)
+    {
+      result.clear();
+
+      switch (id)
+      {
+""")
+
+for name in resources:
+    if resources[name]['Type'] == 'Directory':
+        cpp.write('      case %s:\n' % name)
+        for path in sorted(resources[name]['Files']):
+            cpp.write('        result.push_back("%s");\n' % path)
+        cpp.write('        break;\n\n')
+
+cpp.write("""      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+      }
+    }
+""")
+
+
+
+
+#####################################################################
 ## Write the convenience wrappers in .cpp
 #####################################################################