本文整理汇总了C#中tcl.lang.Interp.getWorkingDir方法的典型用法代码示例。如果您正苦于以下问题:C# Interp.getWorkingDir方法的具体用法?C# Interp.getWorkingDir怎么用?C# Interp.getWorkingDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tcl.lang.Interp
的用法示例。
在下文中一共展示了Interp.getWorkingDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdProc
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;
}
示例2: execReflection
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();
}
System.Object[] methodArgs = new System.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 System.IO.IOException )
{
throw (System.IO.IOException)t;
}
else
{
throw new TclRuntimeError( "unexected exception in execReflection" );
}
}
}
示例3: execWin
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( ' ' );
}
System.Diagnostics.Process proc = new System.Diagnostics.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;
}
示例4: getNewFileObj
internal static FileInfo getNewFileObj( Interp interp, string fileName )
{
fileName = translateFileName( interp, fileName );
System.Diagnostics.Debug.WriteLine( "File name is \"" + fileName + "\"" );
switch ( getPathType( fileName ) )
{
case PATH_RELATIVE:
if ( fileName == ":memory:" )
return null;
System.Diagnostics.Debug.WriteLine( "File name is PATH_RELATIVE" );
return new FileInfo( interp.getWorkingDir().FullName + "\\" + fileName );
case PATH_VOLUME_RELATIVE:
System.Diagnostics.Debug.WriteLine( "File name is PATH_VOLUME_RELATIVE" );
// Something is very wrong if interp.getWorkingDir()
// does not start with C: or another drive letter
string cwd = interp.getWorkingDir().ToString();
int index = beginsWithLetterColon( cwd );
if ( index == 0 )
{
throw new TclRuntimeError( "interp working directory \"" + cwd + "\" does not start with a drive letter" );
}
// We can not use the joinPath() method because joing("D:/", "/f.txt")
// returns "/f.txt" for some wacky reason. Just do it ourselves.
StringBuilder buff = new StringBuilder();
buff.Append( cwd.Substring( 0, ( 2 ) - ( 0 ) ) );
buff.Append( '\\' );
for ( int i = 0; i < fileName.Length; i++ )
{
if ( fileName[i] != '\\' )
{
// Once we skip all the \ characters at the front
// append the rest of the fileName onto the buffer
buff.Append( fileName.Substring( i ) );
break;
}
}
fileName = buff.ToString();
System.Diagnostics.Debug.WriteLine( "After PATH_VOLUME_RELATIVE join \"" + fileName + "\"" );
return new FileInfo( fileName );
case PATH_ABSOLUTE:
System.Diagnostics.Debug.WriteLine( "File name is PATH_ABSOLUTE" );
return new FileInfo( fileName );
default:
throw new TclRuntimeError( "type for fileName \"" + fileName + "\" not matched in case statement" );
}
}
示例5: createAbsoluteFileObj
private static FileInfo createAbsoluteFileObj( Interp interp, string fileName )
{
if ( fileName.Equals( "" ) )
{
return ( interp.getWorkingDir() );
}
if ( ( JACL.PLATFORM == JACL.PLATFORM_WINDOWS ) && ( fileName.Length >= 2 ) && ( fileName[1] == ':' ) )
{
string tmp = null;
if ( fileName.Length == 2 )
{
tmp = fileName.Substring( 0, ( 2 ) - ( 0 ) ) + '\\';
}
else if ( fileName[2] != '\\' )
{
tmp = fileName.Substring( 0, ( 2 ) - ( 0 ) ) + '\\' + fileName.Substring( 2 );
}
if ( (System.Object)tmp != null )
{
return FileUtil.getNewFileObj( interp, tmp );
}
}
return FileUtil.getNewFileObj( interp, fileName );
}
示例6: addFileToResult
private static void addFileToResult( Interp interp, string fileName, string separators, TclObject resultList )
{
string prettyFileName = fileName;
int prettyLen = fileName.Length;
// Java IO reuqires Windows volumes [A-Za-z]: to be followed by '\\'.
if ( ( JACL.PLATFORM == JACL.PLATFORM_WINDOWS ) && ( prettyLen >= 2 ) && ( fileName[1] == ':' ) )
{
if ( prettyLen == 2 )
{
fileName = fileName + '\\';
}
else if ( fileName[2] != '\\' )
{
fileName = fileName.Substring( 0, ( 2 ) - ( 0 ) ) + '\\' + fileName.Substring( 2 );
}
}
TclObject[] arrayObj = TclList.getElements( interp, FileUtil.splitAndTranslate( interp, fileName ) );
fileName = FileUtil.joinPath( interp, arrayObj, 0, arrayObj.Length );
FileInfo f;
if ( FileUtil.getPathType( fileName ) == FileUtil.PATH_ABSOLUTE )
{
f = FileUtil.getNewFileObj( interp, fileName );
}
else
{
f = new FileInfo( interp.getWorkingDir().FullName + "\\" + fileName );
}
// If the last character is a spearator, make sure the file is an
// existing directory, otherwise check that the file exists.
if ( ( prettyLen > 0 ) && ( separators.IndexOf( (System.Char)prettyFileName[prettyLen - 1] ) != -1 ) )
{
if ( Directory.Exists( f.FullName ) )
{
TclList.append( interp, resultList, TclString.newInstance( prettyFileName ) );
}
}
else
{
bool tmpBool;
if ( File.Exists( f.FullName ) )
tmpBool = true;
else
tmpBool = Directory.Exists( f.FullName );
if ( tmpBool )
{
TclList.append( interp, resultList, TclString.newInstance( prettyFileName ) );
}
}
}