Exemplo n.º 1
0
 public static void createDirectories() {
   final String[] dirs = {
     Paths.getHomeDirectory(),
     Paths.getLogsDirectory(),
     Paths.getCacheDirectory(),
     Paths.getSettingsDirectory(),
     Paths.getScriptsDirectory(),
     Paths.getScriptsSourcesDirectory(),
     Paths.getScriptsPrecompiledDirectory(),
     Paths.getScriptsNetworkDirectory(),
   };
   for (final String name : dirs) {
     final File dir = new File(name);
     if (!dir.isDirectory()) {
       dir.mkdirs();
     }
   }
   if (Configuration.getCurrentOperatingSystem() == Configuration.OperatingSystem.WINDOWS) {
     try {
       Runtime.getRuntime()
           .exec(
               "attrib +H \""
                   + new File(Paths.getScriptsNetworkDirectory()).getAbsolutePath()
                   + "\"");
     } catch (final IOException ignored) {
     }
   }
 }
Exemplo n.º 2
0
 public static void registerLogging() {
   final Properties logging = new Properties();
   final String logFormatter = LogFormatter.class.getCanonicalName();
   final String fileHandler = FileHandler.class.getCanonicalName();
   logging.setProperty(
       "handlers", TextAreaLogHandler.class.getCanonicalName() + "," + fileHandler);
   logging.setProperty(".level", "INFO");
   logging.setProperty(SystemConsoleHandler.class.getCanonicalName() + ".formatter", logFormatter);
   logging.setProperty(fileHandler + ".formatter", logFormatter);
   logging.setProperty(TextAreaLogHandler.class.getCanonicalName() + ".formatter", logFormatter);
   logging.setProperty(
       fileHandler + ".pattern", Paths.getLogsDirectory() + File.separator + "%u.%g.log");
   logging.setProperty(fileHandler + ".count", "10");
   final ByteArrayOutputStream logout = new ByteArrayOutputStream();
   try {
     logging.store(logout, "");
     LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(logout.toByteArray()));
   } catch (final Exception ignored) {
   }
 }