wasCSharpSQLite – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | #undef DEBUG |
2 | /* |
||
3 | * Env.java -- |
||
4 | * |
||
5 | * This class is used to create and manage the environment array |
||
6 | * used by the Tcl interpreter. |
||
7 | * |
||
8 | * Copyright (c) 1997 Sun Microsystems, Inc. |
||
9 | * |
||
10 | * See the file "license.terms" for information on usage and redistribution |
||
11 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
||
12 | * |
||
13 | * Included in SQLite3 port to C# for use in testharness only; 2008 Noah B Hart |
||
14 | * |
||
15 | * RCS @(#) $Id: Env.java,v 1.2 1999/08/07 05:46:26 mo Exp $ |
||
16 | */ |
||
17 | using System; |
||
18 | using System.Collections; |
||
19 | |||
20 | namespace tcl.lang |
||
21 | { |
||
22 | |||
23 | /// <summary> This class manages the environment array for Tcl interpreters.</summary> |
||
24 | |||
25 | class Env |
||
26 | { |
||
27 | |||
28 | /* |
||
29 | *---------------------------------------------------------------------- |
||
30 | * |
||
31 | * initialize -- |
||
32 | * |
||
33 | * This method is called to initialize an interpreter with it's |
||
34 | * initial values for the env array. |
||
35 | * |
||
36 | * Results: |
||
37 | * None. |
||
38 | * |
||
39 | * Side effects: |
||
40 | * The env array in the interpreter is created and populated. |
||
41 | * |
||
42 | *---------------------------------------------------------------------- |
||
43 | */ |
||
44 | |||
45 | internal static void initialize( Interp interp ) |
||
46 | { |
||
47 | // For a few standrad environment vairables that Tcl users |
||
48 | // often assume aways exist (even if they shouldn't), we will |
||
49 | // try to create those expected variables with the common unix |
||
50 | // names. |
||
51 | |||
52 | try |
||
53 | { |
||
54 | interp.setVar( "env", "HOME", System.Environment.CurrentDirectory, TCL.VarFlag.GLOBAL_ONLY ); |
||
55 | } |
||
56 | catch ( TclException e ) |
||
57 | { |
||
58 | // Ignore errors. |
||
59 | } |
||
60 | |||
61 | try |
||
62 | { |
||
63 | interp.setVar( "env", "USER", System.Environment.UserName, TCL.VarFlag.GLOBAL_ONLY ); |
||
64 | } |
||
65 | catch ( TclException e ) |
||
66 | { |
||
67 | // Ignore errors. |
||
68 | } |
||
69 | |||
70 | // Now we will populate the rest of the env array with the |
||
71 | // properties recieved from the System classes. This makes for |
||
72 | // a nice shortcut for getting to these useful values. |
||
73 | |||
74 | try |
||
75 | { |
||
76 | |||
77 | |||
78 | for ( IDictionaryEnumerator search = System.Environment.GetEnvironmentVariables().GetEnumerator(); search.MoveNext(); ) |
||
79 | { |
||
80 | interp.setVar( "env", search.Key.ToString(), search.Value.ToString(), TCL.VarFlag.GLOBAL_ONLY ); |
||
81 | } |
||
82 | } |
||
83 | catch ( System.Security.SecurityException e2 ) |
||
84 | { |
||
85 | // We are inside a browser and we can't access the list of |
||
86 | // property names. That's fine. Life goes on .... |
||
87 | } |
||
88 | catch ( System.Exception e3 ) |
||
89 | { |
||
90 | // We are inside a browser and we can't access the list of |
||
91 | // property names. That's fine. Life goes on .... |
||
92 | |||
93 | System.Diagnostics.Debug.WriteLine( "Exception while initializing env array" ); |
||
94 | System.Diagnostics.Debug.WriteLine( e3 ); |
||
95 | System.Diagnostics.Debug.WriteLine( "" ); |
||
96 | } |
||
97 | } |
||
98 | } // end Env |
||
99 | } |