public TCL.CompletionCode CmdProc(Interp interp, TclObject[] argv) { if (argv.Length != 1) { throw new TclNumArgsException(interp, 1, argv, null); } // Get the name of the working dir. string dirName = interp.getWorkingDir().ToString(); // Java File Object methods use backslashes on Windows. // Convert them to forward slashes before returning the dirName to Tcl. if (JACL.PLATFORM == JACL.PLATFORM_WINDOWS) { dirName = dirName.Replace('\\', '/'); } interp.SetResult(dirName); return TCL.CompletionCode.RETURN; }
private System.Diagnostics.Process execReflection(Interp interp, TclObject[] argv, int first, int last) { string[] strv = new string[last - first]; for (int i = first, j = 0; i < last; j++, i++) { strv[j] = argv[i].ToString(); } Object[] methodArgs = new Object[3]; methodArgs[0] = strv; // exec command arguments methodArgs[1] = null; // inherit all environment variables methodArgs[2] = interp.getWorkingDir(); try { return (System.Diagnostics.Process)execMethod.Invoke(System.Diagnostics.Process.GetCurrentProcess(), (System.Object[])methodArgs); } catch (System.UnauthorizedAccessException ex) { throw new TclRuntimeError("IllegalAccessException in execReflection"); } catch (System.ArgumentException ex) { throw new TclRuntimeError("IllegalArgumentException in execReflection"); } catch (System.Reflection.TargetInvocationException ex) { System.Exception t = ex.GetBaseException(); if (t is System.ApplicationException) { throw (System.ApplicationException)t; } else if (t is IOException) { throw (IOException)t; } else { throw new TclRuntimeError("unexected exception in execReflection"); } } }
private System.Diagnostics.Process execWin(Interp interp, TclObject[] argv, int first, int last) { StringBuilder sb = new StringBuilder(); for (int i = (first + 1); i < last; i++) { sb.Append('"'); sb.Append(escapeWinString(argv[i].ToString())); sb.Append('"'); sb.Append(' '); } Process proc = new Process(); proc.StartInfo.UseShellExecute = false; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.RedirectStandardError = true; proc.StartInfo.RedirectStandardInput = true; proc.StartInfo.WorkingDirectory = interp.getWorkingDir().FullName; proc.StartInfo.FileName = argv[first].ToString(); proc.StartInfo.Arguments = sb.ToString(); return proc; }