Add error log when using --rm-all-app-profile option (#493)
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / tpatool.cc
index fd0e2bb..8256890 100644 (file)
 #include <iostream>
 
 #include "utils.h"
-
-const char* __RUNTIME_DIR = "/usr/share/dotnet.tizen/netcoreapp";
-const char* __TIZENFX_DIR = "/usr/share/dotnet.tizen/framework";
-const char* __TIZENFX_REF_DIR = "/usr/share/dotnet.tizen/framework/ref";
-const char* __PLATFORM_TPA_CACHE = "/usr/share/dotnet.tizen/lib/platform_tpa_cache";
+#include "path_manager.h"
+#include "log.h"
 
 int main(int argc, char* argv[])
 {
-    std::string tpaList;
-    std::vector<std::string> tpaDir;
-
-    tpaDir.push_back(__RUNTIME_DIR);
-    tpaDir.push_back(__TIZENFX_DIR);
-    tpaDir.push_back(__TIZENFX_REF_DIR);
-
-    assembliesInDirectory(tpaDir, tpaList);
-
-    std::ofstream out(__PLATFORM_TPA_CACHE);
-    out << tpaList;
-    out.close();
-
-    return 0;
+       PathManager* __pm = nullptr;
+       try {
+               __pm = new PathManager();
+       }  catch (const std::exception& e) {
+               _SERR("Failed to create PathManager");
+               return -1;
+       }
+
+       std::string tpaList;
+       addAssembliesFromDirectories(__pm->getPlatformAssembliesPaths(), tpaList);
+
+       if (!isSymlinkFile(PLATFORM_TPA_CACHE)) {
+               std::ofstream out(PLATFORM_TPA_CACHE);
+               out << tpaList;
+               out.close();
+       } else {
+               _SERR("Failed to create platform_tpa_cache. Symbolic link is detected");
+               return -1;
+       }
+
+       delete(__pm);
+       __pm = nullptr;
+
+       return 0;
 }
-