From 8b07e93282404be3cef79660e3fbea7bd79fca15 Mon Sep 17 00:00:00 2001 From: "shingil.kang" Date: Tue, 12 Nov 2013 21:43:01 +0900 Subject: [PATCH] CLI : Fixed a bug where error occurs when loading built-in templates. fixed the error related with index when reloading built-in templates. Change-Id: Id69960d9b253898b1885d4d5a797e415038e7a27 Signed-off-by: shingil.kang --- .../org/tizen/ncli/ide/shell/CreateProjectCLI.java | 4 +- .../ide/subcommands/CreateProjectCommandData.java | 2 +- .../ide/subcommands/CreateWebProjectCommand.java | 93 ++++++++++++---------- 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/CreateProjectCLI.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/CreateProjectCLI.java index be096d4..c77563e 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/CreateProjectCLI.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/CreateProjectCLI.java @@ -25,6 +25,8 @@ */ package org.tizen.ncli.ide.shell; +import java.io.File; + import org.kohsuke.args4j.Option; import org.kohsuke.args4j.spi.StringOptionHandler; import org.slf4j.Logger; @@ -45,7 +47,7 @@ public class CreateProjectCLI extends AbstractCLI @Option(name = "-n", aliases = "--name", required = true, usage = "Specify template name") private String projectName; - @Option(name = "-out", aliases = {"--output"} ,handler=StringOptionHandler.class, usage = "Specify output directory name") + @Option(name = "-out", aliases = {"--output"}, handler=StringOptionHandler.class, usage = "Specify output directory name") public String outputName; /* diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateProjectCommandData.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateProjectCommandData.java index 9474ef1..0c1f1c6 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateProjectCommandData.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateProjectCommandData.java @@ -58,7 +58,7 @@ public class CreateProjectCommandData private TizenAppType appType; private String projectName; - private String outputName = System.getProperty("user.dir") + File.separator; + private String outputName = System.getProperty("user.dir"); private static TizenAppTemplate tizenAppTemplate; diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateWebProjectCommand.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateWebProjectCommand.java index c0f1392..642a722 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateWebProjectCommand.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/CreateWebProjectCommand.java @@ -501,8 +501,6 @@ public class CreateWebProjectCommand extends AbstractSubCommand 0) - { // write contents of 'is' to 'fos' - fos.write(is.read()); + return templateLibPath; + } + else + { + destDirFile.mkdir(); + } + + templateLibPath = destDirPath + File.separator + WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER + File.separator; + + try + { + JarFile jar = new JarFile(jarPath); + Enumeration enum2 = jar.entries(); + while (enum2.hasMoreElements()) + { + JarEntry file = (JarEntry) enum2.nextElement(); + File f = new File(destDirPath + File.separator + file.getName()); + if (file.isDirectory()) + { // if its a directory, create it + f.mkdir(); + continue; + } + InputStream is = jar.getInputStream(file); // get the input + // stream + FileOutputStream fos = new FileOutputStream(f); + while (is.available() > 0) + { // write contents of 'is' to 'fos' + fos.write(is.read()); + } + fos.close(); + is.close(); } - fos.close(); - is.close(); + } catch (FileNotFoundException e) + { + logger.error(e.getMessage()); + } catch (IOException e) + { + logger.error(e.getMessage()); } - } catch (FileNotFoundException e) - { - logger.error(e.getMessage()); - } catch (IOException e) - { - logger.error(e.getMessage()); } + return templateLibPath; } } -- 2.7.4