Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/flexstor/common/util/WinProcess.java


1   /*
2    * WinProcess.java
3    *
4    * Copyright $Date: 2003/08/11 02:22:31 $ FLEXSTOR.net Inc.
5    *
6    * This work is licensed for use and distribution under license terms found at
7    * http://www.flexstor.org/license.html
8    *
9    */
10  
11  package com.flexstor.common.util;
12  
13  import java.io.DataOutputStream;
14  import java.io.File;
15  import java.io.FileOutputStream;
16  import java.io.IOException;
17  
18  public class WinProcess
19     extends FlexProcess
20  {
21     protected WinProcess(String sExecName, String[] saArguments, String[] saServerNames )
22     {
23        super(sExecName, saArguments, saServerNames);
24     }
25     
26     protected void prepareArguments()
27        throws IOException
28     {
29        for (int i = 0; i < saArguments.length; i++)
30        {
31           Diagnostic.trace(Diagnostic.CAT_PROCESS, "arg before filter= " + saArguments[i]);
32           // make UNC path
33           if (saServerNames.length > 0)    // no server names = no localization
34           {
35              saArguments[i] = java.io.File.separator + java.io.File.separator 
36                             + saServerNames[i] 
37                             + saArguments[i];
38              saArguments[i] = saArguments[i].replace('/', java.io.File.separatorChar); // put in platform delimiters
39           }
40           Diagnostic.trace(Diagnostic.CAT_PROCESS, "arg after  filter= " + saArguments[i]);
41        }
42        // in command mode do not write arguments to file!
43        if (!bCommand && (new File(sExecName).exists()))
44        {
45           File f = new File(getTempFileName());
46           Diagnostic.trace(Diagnostic.CAT_PROCESS, "Writing temp file to: " + f.getAbsolutePath());
47           DataOutputStream dos = new DataOutputStream(new FileOutputStream(f));
48  
49           for (int i = 0; i < saArguments.length; i++)
50           {
51              dos.writeBytes(saArguments[i]);
52              dos.writeBytes(LINE_FEED);
53           }
54           dos.close();
55        }
56     }
57     
58  }  //WinProcess