Added the code for recursively deleting the existing folder, so that's
working as well. Thanks for your response, Don.

Cheers,
Raju

Here's the code:
Index: SWF9External.java
===================================================================
--- SWF9External.java    (revision 9325)
+++ SWF9External.java    (working copy)
@@ -110,6 +110,23 @@
   }
 
   /**
+   * Delete a dir with all files
+   */
+  private boolean deleteDir(File dir) {
+    if (dir.isDirectory()) {
+      String[] children = dir.list();
+      for (int i=0; i<children.length; i++) {
+        boolean success = deleteDir(new File(dir, children[i]));
+        if (!success) {
+          return false;
+        }
+      }
+    }
+    // The directory is now empty so delete it
+    return dir.delete();
+  }
+   
+  /**
    * Create a temporary work directory for compilation
    * and return a File for it.
    * @throw CompilerError when directory creation fails
@@ -120,12 +137,24 @@
     // cleanup on error, and on success too.
 
     File f = null;
+    // Raju: Need to be able to configure the tmp folder for the AS3 code
+    // That way I can use a FlexBuilder project to debug the generated AS3
code
+    String customFolder = System.getProperty("as3tmpfolder");
     try {
-      String tmpdirstr = System.getProperty("java.io.tmpdir");
-      String swf9tmpdirstr = tmpdirstr + File.separator + WORK_DIR_PARENT;
-      (new File(swf9tmpdirstr)).mkdirs();
-        
-      f = File.createTempFile(WORK_DIR_PREFIX, "", new
File(swf9tmpdirstr));
+      String swf9tmpdirstr = null;
+      // check if the custom folder exists
+      if (customFolder != null) {
+        System.out.println("Using custom folder " + customFolder + " for
temporary AS3 files");
+        swf9tmpdirstr = customFolder + File.separator + "src";
+        f = new File(swf9tmpdirstr);
+        if (f.exists()) deleteDir(f);
+        f.mkdirs();
+      } else {
+          String tmpdirstr = System.getProperty("java.io.tmpdir");
+          swf9tmpdirstr = tmpdirstr + File.separator + WORK_DIR_PARENT;
+        (new File(swf9tmpdirstr)).mkdirs();
+        f = File.createTempFile(WORK_DIR_PREFIX, "", new
File(swf9tmpdirstr));
+      }
       if (!f.delete())
         throw new CompilerError("getCompilationWorkDir: temp file does not
exist");
       if (!f.mkdir())




Am 25.05.2008 2:08 Uhr schrieb "Donald Anderson" unter <[EMAIL PROTECTED]>:

> Raju,
> 
> There isn't any way to do this short of changing the code.
> You can change the Java temp folder via modifying the property
> java.io.tmpdir, but I know that's not what you're asking.
> You want to get rid of the variable part of the name, right?
> 
> As long as you realize that setting a fixed temporary name
> will give strange behavior when running under a server:
> imagine two simultaneous requests trying to do compilations using the
> same directory.  In your case, you need to make sure you are
> not running multiple lzc's at the same time to the same folder.
> 
> - Don
> 
> On May 24, 2008, at 7:22 PM, Raju Bitter wrote:
> 
>> Hi all,
>> 
>> I'm playing around with the SWF9 runtime. Is there an easy way to
>> change the
>> location where the generated AS3 files are stored? Right now it's
>> the Java
>> temp folder and then subfolder lzswf9/{generatedFolderName}.
>> The relevant Java file is
>> http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/server/src/org/openla
>> szlo/sc/SWF9External.java
>> 
>> For testing it sometimes would be good to re-use to be able to
>> configure the
>> folder name. What I'd like to do is to run the lzc command out of an
>> Ant
>> script and be able to generate the AS source into my src folder
>> within the
>> project.
>> 
>> I'll probably do a change to the code locally to be able to pass a
>> property
>> into the server using the -D option for Java, e.g.
>> -Das3tmpfolder={someFolderName}
>> 
>> Thanks,
>> Raju
>> 
>> 
> 
> 
> --
> 
> Don Anderson
> Java/C/C++, Berkeley DB, systems consultant
> 
> voice: 617-547-7881
> email: [EMAIL PROTECTED]
> www: http://www.ddanderson.com
> 
> 
> 
> 


Reply via email to