Changeset 1378


Ignore:
Timestamp:
Oct 29, 2011, 7:53:11 PM (6 years ago)
Author:
joerg
Message:

fixed program updater

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/de/endrullis/utils/ProgramUpdater.java

    r1376 r1378  
    2626public class ProgramUpdater extends JFrame implements ActionListener {
    2727  public static final String VERSIONS_FILE_NAME = "versions.xml";
     28
     29  private File destinationDir = new File(System.getProperty("user.dir"));
     30  private boolean destinationWritable = false;
    2831  private static File updateDir = null;
    2932
     
    7376    pack();
    7477    setLocationRelativeTo(null);
     78
     79    // test for writing rights in the destination directory
     80    try {
     81      File file = new File(destinationDir, "test");
     82      if(file.createNewFile() || file.canWrite()) destinationWritable = true;
     83      file.delete();
     84    } catch (Throwable e) {}
    7585  }
    7686
     
    98108  public boolean performUpdate(boolean confirmation) throws IOException {
    99109    // create update dir
    100     updateDir = FileUtil.createTempDirectory("update");
     110    if(destinationWritable) {
     111      updateDir = new File("update");
     112    } else {
     113      updateDir = FileUtil.createTempDirectory("update");
     114    }
     115    if(!updateDir.exists()) updateDir.mkdir();
    101116
    102117    setAlwaysOnTop(true);
     
    246261    if (!updateDir.isDirectory()) return false;
    247262
    248     File destinationDir = new File(System.getProperty("user.dir"));
    249 
    250     // test for writing rights
    251     boolean writable = false;
    252     try {
    253       File file = new File(destinationDir, "test");
    254       if(file.createNewFile() || file.canWrite()) writable = true;
    255       file.delete();
    256     } catch (Throwable e) {}
    257 
    258263    boolean success = true;
    259264
     
    268273
    269274    // move files in update dir to .
    270     if(writable) {
     275    if(destinationWritable) {
    271276      File[] files2move = updateDir.listFiles();
    272277      for (File file : files2move) {
  • trunk/src/jlatexeditor/codehelper/ScriptingSupport.java

    r1376 r1378  
    149149        } else {
    150150          writer.println("main = tree \"" + content.replace('\n', ' ').replaceAll("\"", "\\\"") + "\"");
    151           System.err.println(scriptDir);
    152151        }
    153152        writer.close();
Note: See TracChangeset for help on using the changeset viewer.