Fix file key generation
[platform/core/appfw/tizen-theme-manager.git] / src / theme_plugin / theme_info_builder.cc
index 4edab18..b634553 100644 (file)
@@ -15,12 +15,7 @@ namespace bf = boost::filesystem;
 
 namespace {
 
-const char kThemeFilesPrefix[] = "/theme/files";
-
-bool StartsWith(const std::string& str, const std::string& substr) {
-  return str.length() >= substr.length() &&
-      std::equal(substr.begin(), substr.end(), str.begin());
-}
+const char kThemeFilesPrefix[] = "/theme/files/";
 
 }  // namespace
 
@@ -50,34 +45,13 @@ loader::ThemeInfo ThemeInfoBuilder::Build() {
 void ThemeInfoBuilder::GenerateFileKey(const std::string& root) {
   for (bf::recursive_directory_iterator it(root);
       it != bf::recursive_directory_iterator(); ++it) {
-    if (!bf::is_regular_file(it->path()))
-      continue;
-
-    if (!StartsWith(it->path().string(), root))
+    if (!bf::is_directory(it->path()))
       continue;
 
-    // root.size() -1 to remove trailing '/' charater
-    std::string filepath = it->path().string().substr(root.size() - 1);
+    std::string filepath = it->path().string().substr(root.size());
     std::string key = kThemeFilesPrefix + filepath;
-    bundle_.Add(key, it->path().string());
-  }
-
-  GenerateFileKeyWithoutExtension();
-}
-
-void ThemeInfoBuilder::GenerateFileKeyWithoutExtension() {
-  std::vector<tizen_base::Bundle::KeyInfo> keyinfos = bundle_.GetKeys();
-  for (const auto& keyinfo : keyinfos) {
-    std::string key = keyinfo.GetName();
-    if (!StartsWith(key, kThemeFilesPrefix))
-      continue;
-
-    size_t dot_pos = key.find_last_of(".");
-    if (dot_pos == std::string::npos)
-      continue;
-
-    std::string newkey = key.substr(0, dot_pos);
-    bundle_.Add(newkey, bundle_.GetString(key));
+    std::string val = "shared/res/" + filepath;
+    bundle_.Add(key, val);
   }
 }