OSDN Git Service

一時ファイルについて、
authoryuki <yuki@c066991c-cf13-ec4a-a49a-846e61667af5>
Fri, 22 Jan 2010 08:57:46 +0000 (08:57 +0000)
committeryuki <yuki@c066991c-cf13-ec4a-a49a-846e61667af5>
Fri, 22 Jan 2010 08:57:46 +0000 (08:57 +0000)
1.tmpディレクトリ以下に作成するよう変更
2.ユニーク名を設定するよう変更(同時に実行した場合、従来は同名のテンポラリファイルで処理しようとしていたため、うまくいかない)

git-svn-id: http://192.168.11.7/svn/saccubus/trunk@345 c066991c-cf13-ec4a-a49a-846e61667af5

frontend/src/saccubus/converter/FfmpegCommand.java

index c56cc48..e2071fb 100644 (file)
@@ -21,9 +21,9 @@ import yukihane.swf.Cws2Fws;
  */
 public class FfmpegCommand extends AbstractCommand {
 
  */
 public class FfmpegCommand extends AbstractCommand {
 
-    private final File commentMiddleFile = new File("./vhook.tmp");
-    private final File tcommMiddleFile = new File("./tcomment.tmp");
-    private static final String TMP_CWS = "fws_tmp.swf";
+    private final File commentMiddleFile;
+    private final File tcommMiddleFile;
+    private final File TMP_CWS;
     private final File commentFile;
     private final File tcommFile;
     private final File videoFile;
     private final File commentFile;
     private final File tcommFile;
     private final File videoFile;
@@ -31,7 +31,7 @@ public class FfmpegCommand extends AbstractCommand {
     private final Ffmpeg ffmpeg;
 
     FfmpegCommand(TextProgressListener listener, ConvertStopFlag flag, File commentFile, File tcommFile,
     private final Ffmpeg ffmpeg;
 
     FfmpegCommand(TextProgressListener listener, ConvertStopFlag flag, File commentFile, File tcommFile,
-            File videoFile, File convertedVideoFile, Ffmpeg ffmpeg) {
+            File videoFile, File convertedVideoFile, Ffmpeg ffmpeg) throws IOException {
         super(listener, flag);
         this.commentFile = commentFile;
         this.tcommFile = tcommFile;
         super(listener, flag);
         this.commentFile = commentFile;
         this.tcommFile = tcommFile;
@@ -39,6 +39,10 @@ public class FfmpegCommand extends AbstractCommand {
         this.convertedVideoFile = convertedVideoFile;
         this.ffmpeg = ffmpeg;
 
         this.convertedVideoFile = convertedVideoFile;
         this.ffmpeg = ffmpeg;
 
+        File tmpDir = new File("tmp");
+        commentMiddleFile = File.createTempFile("vhk", ".tmp", tmpDir);
+        tcommMiddleFile = File.createTempFile("tcom", ".tmp", tmpDir);
+        TMP_CWS = File.createTempFile("cws", ".swf", tmpDir);
     }
 
     public boolean execute() throws InterruptedException, IOException {
     }
 
     public boolean execute() throws InterruptedException, IOException {
@@ -51,6 +55,9 @@ public class FfmpegCommand extends AbstractCommand {
             if (tcommMiddleFile.exists()) {
                 tcommMiddleFile.delete();
             }
             if (tcommMiddleFile.exists()) {
                 tcommMiddleFile.delete();
             }
+            if (TMP_CWS.exists()) {
+                TMP_CWS.delete();
+            }
         }
     }
 
         }
     }
 
@@ -89,7 +96,7 @@ public class FfmpegCommand extends AbstractCommand {
 
     private int converting_video(File videoFile, File convertedVideoFile, boolean addComment, String vhook_path,
             boolean addTcomment, String tcommPath, FfmpegOption ov) throws InterruptedException, IOException {
 
     private int converting_video(File videoFile, File convertedVideoFile, boolean addComment, String vhook_path,
             boolean addTcomment, String tcommPath, FfmpegOption ov) throws InterruptedException, IOException {
-        File fwsFile = Cws2Fws.createFws(videoFile, new File(TMP_CWS));
+        File fwsFile = Cws2Fws.createFws(videoFile, TMP_CWS);
 
         StringBuffer sb = new StringBuffer();
         sb.append("\"");
 
         StringBuffer sb = new StringBuffer();
         sb.append("\"");