Преглед изворни кода

absolutizing temp dir path.

When File.getTempFile() fails, workaround temp dir
is relative, which messes up the zip resource copying.
tags/V1_1_0
wisberg пре 21 година
родитељ
комит
93fdea6a04
1 измењених фајлова са 26 додато и 9 уклоњено
  1. 26
    9
      build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java

+ 26
- 9
build/src/org/aspectj/internal/tools/ant/taskdefs/AJInstaller.java Прегледај датотеку

static final String MAIN_CLASS = "$installer$.org.aspectj.Main"; static final String MAIN_CLASS = "$installer$.org.aspectj.Main";
static final String CONTENTS_FILE = "$installer$/org/aspectj/resources/contents.txt"; static final String CONTENTS_FILE = "$installer$/org/aspectj/resources/contents.txt";
private String htmlSrc; private String htmlSrc;
public void setHtmlSrc(String v) { htmlSrc = v; } public void setHtmlSrc(String v) { htmlSrc = v; }


private String resourcesSrc; private String resourcesSrc;
protected void finishZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException { protected void finishZipOutputStream(ZipOutputStream zOut) throws IOException, BuildException {
writeContents(zOut); writeContents(zOut);
writeManifest(zOut); writeManifest(zOut);
File tmpDirF = File.createTempFile("tgz", ".di");
File tmpDir = new File(tmpDirF.getAbsolutePath() + "r");
tmpDirF.delete();
String tmp = tmpDir.getAbsolutePath();
File tempDir = setupTempDir();
String tmp = tempDir.getAbsolutePath();


// installer class files // installer class files
Expand expand = new Expand(); Expand expand = new Expand();
cd.execute(); cd.execute();
// now move these files into the jar // now move these files into the jar
setBasedir(tmp); setBasedir(tmp);
writeFiles(zOut, getFiles(tmpDir));
writeFiles(zOut, getFiles(tempDir));
// and delete the tmp dir // and delete the tmp dir
Delete dt = (Delete)project.createTask("delete"); Delete dt = (Delete)project.createTask("delete");
if (null == dt) { if (null == dt) {
dt = new Delete(); dt = new Delete();
dt.setProject(getProject()); dt.setProject(getProject());
} }
dt.setDir(new File(tmp));
dt.setDir(tempDir);
dt.execute(); dt.execute();
tempDir = null;
} }


static final char NEWLINE = '\n'; static final char NEWLINE = '\n';
fIn.close(); fIn.close();
} }
} }

private File setupTempDir() throws BuildException {
File tmpDirF = null;
File tmpDir = null;
try {
tmpDirF = File.createTempFile("tgz", ".di");
tmpDir = new File(tmpDirF.getParentFile(), "AJInstaller");
tmpDirF.delete();
} catch (IOException e) {
// retrying below
}
if (null == tmpDir || !tmpDir.mkdirs()) {
tmpDir = new File("AJInstaller.finishZipOutputStream.tmp");
if (!tmpDir.mkdirs()) {
throw new BuildException("unable to make temp dir");
}
}
return tmpDir;
}
public void execute() throws BuildException { public void execute() throws BuildException {
if (installerClassJar == null) { if (installerClassJar == null) {
throw new BuildException("installerClassJar attribute must be set!"); throw new BuildException("installerClassJar attribute must be set!");
initZipOutputStream(zOut); initZipOutputStream(zOut);
writeDirs(zOut, dirs); writeDirs(zOut, dirs);
writeFiles(zOut, files); writeFiles(zOut, files);
finishZipOutputStream(zOut);
finishZipOutputStream(zOut); // deletes temp dir
} catch (IOException ioe) { } catch (IOException ioe) {
String msg = "Problem creating " + archiveType + " " + ioe.getMessage(); String msg = "Problem creating " + archiveType + " " + ioe.getMessage();
throw new BuildException(msg, ioe, location); throw new BuildException(msg, ioe, location);

Loading…
Откажи
Сачувај