1 | |
---|
2 | ////////////////////////////////////////////////////////////////////////////// |
---|
3 | // Parche cuando la consola de windows está bloqueada para su uso. |
---|
4 | ////////////////////////////////////////////////////////////////////////////// |
---|
5 | |
---|
6 | ////////////////////////////////////////////////////////////////////////////// |
---|
7 | // Funciones con problemas cuando la consola de windows está bloqueada |
---|
8 | /* |
---|
9 | WinSystem |
---|
10 | System |
---|
11 | |
---|
12 | OSCmdWait |
---|
13 | OSCmdNoWait |
---|
14 | OSConWait |
---|
15 | OSConNoWait |
---|
16 | |
---|
17 | OSFilCopy |
---|
18 | OSFilMove |
---|
19 | OSDirMake |
---|
20 | OSDirRemove |
---|
21 | OSDirCopy |
---|
22 | OSDirMove |
---|
23 | |
---|
24 | OSSvnInfo |
---|
25 | */ |
---|
26 | |
---|
27 | ////////////////////////////////////////////////////////////////////////////// |
---|
28 | Real Tcl_System(Text command) |
---|
29 | ////////////////////////////////////////////////////////////////////////////// |
---|
30 | { |
---|
31 | Set tev = Tcl_Eval("exec cmd /c "<<command); |
---|
32 | If(tev[2], { |
---|
33 | If(TextLength(tev[1]), { |
---|
34 | WriteLn(Repeat("-", 78)); |
---|
35 | WriteLn(tev[1]); |
---|
36 | WriteLn(Repeat("-", 78)); |
---|
37 | 1}, 1) |
---|
38 | }, { |
---|
39 | WriteLn(tev[1], "E"); |
---|
40 | 0}) |
---|
41 | }; |
---|
42 | Code PutDescription(Description(Code System), Tcl_System); |
---|
43 | Code PutName("System__OLD", System); |
---|
44 | Code PutName("System", Tcl_System); |
---|
45 | Write(I2( |
---|
46 | "The function Real System will be hidden by Real Tcl_System.", |
---|
47 | "La función Real System será ocultada por Real Tcl_System." |
---|
48 | ), "W"); |
---|
49 | |
---|
50 | ////////////////////////////////////////////////////////////////////////////// |
---|
51 | Real Tcl_WinSystem(Text command, Real showMode, Real wait) |
---|
52 | ////////////////////////////////////////////////////////////////////////////// |
---|
53 | { |
---|
54 | Set tev = Tcl_Eval("exec "<<command<<If(wait, "", " &")); |
---|
55 | Real If(showMode, { |
---|
56 | WriteLn("## [WinSystem] Tcl will execute the command, " |
---|
57 | "no console window will be shown."); |
---|
58 | 1}); |
---|
59 | If(tev[2], { |
---|
60 | Real If(showMode & wait, { |
---|
61 | WriteLn(Repeat("-", 78)); |
---|
62 | WriteLn(tev[1]); |
---|
63 | WriteLn(Repeat("-", 78)); |
---|
64 | 1}); |
---|
65 | 1}, { |
---|
66 | WriteLn(tev[1], "E"); |
---|
67 | 0}) |
---|
68 | }; |
---|
69 | Code PutDescription(Tokenizer(Description(Code WinSystem), "\n")[1]<<"\n"<<I2( |
---|
70 | "No console window will be shown.\n" |
---|
71 | "When argument 'showMode' is not zero, the output of the command will be shown.", |
---|
72 | "No se mostrará la ventana de la consola de comandos.\n" |
---|
73 | "Si el argumento 'showMode' no es 0, se mostrará la salida de la ejecución." |
---|
74 | ), Tcl_WinSystem); |
---|
75 | Code PutName("WinSystem__OLD", WinSystem); |
---|
76 | Code PutName("WinSystem", Tcl_WinSystem); |
---|
77 | Write(I2( |
---|
78 | "The function Real WinSystem will be hidden by Real Tcl_WinSystem.\n" |
---|
79 | " Note that now WinSystem requires exactly three arguments.", |
---|
80 | "La función Real WinSystem será ocultada por Real Tcl_WinSystem.\n" |
---|
81 | " Tenga en cuenta que ahora WinSystem requiere exactamente tres argumentos." |
---|
82 | ), "W"); |
---|
83 | |
---|
84 | ////////////////////////////////////////////////////////////////////////////// |
---|
85 | Real OSCmdWait(Text order) |
---|
86 | ////////////////////////////////////////////////////////////////////////////// |
---|
87 | { |
---|
88 | Text OSTrace(3,"OSCmdWait("<<order+")"); |
---|
89 | WinSystem(OSWinCmd+order, 0, 1) |
---|
90 | }; |
---|
91 | Code PutDescription(Description(TolCore::OSCmdWait), OSCmdWait); |
---|
92 | |
---|
93 | |
---|
94 | ////////////////////////////////////////////////////////////////////////////// |
---|
95 | Real OSCmdNoWait(Text order) |
---|
96 | ////////////////////////////////////////////////////////////////////////////// |
---|
97 | { |
---|
98 | Text OSTrace(3,"OSCmdNoWait("<<order+")"); |
---|
99 | WinSystem(OSWinCmd+order, 0, 0) |
---|
100 | }; |
---|
101 | Code PutDescription(Description(TolCore::OSCmdNoWait), OSCmdNoWait); |
---|
102 | |
---|
103 | |
---|
104 | ////////////////////////////////////////////////////////////////////////////// |
---|
105 | Real OSConWait(Text order, Real showMode) |
---|
106 | ////////////////////////////////////////////////////////////////////////////// |
---|
107 | { |
---|
108 | Text OSTrace(3,"OSConWait("<<order+")"); |
---|
109 | WinSystem(OSWinCmd+order, showMode, 1) |
---|
110 | }; |
---|
111 | Code PutDescription(Tokenizer(Description(TolCore::OSConWait), "\n")[1], OSConWait); |
---|
112 | |
---|
113 | |
---|
114 | ////////////////////////////////////////////////////////////////////////////// |
---|
115 | Real OSConNoWait(Text order, Real showMode) |
---|
116 | ////////////////////////////////////////////////////////////////////////////// |
---|
117 | { |
---|
118 | Text OSTrace(3,"OSConNoWait("<<order+")"); |
---|
119 | WinSystem(OSWinCmd+order, showMode, 0) |
---|
120 | }; |
---|
121 | Code PutDescription(Tokenizer(Description(TolCore::OSConNoWait), "\n")[1], OSConNoWait); |
---|
122 | |
---|
123 | ////////////////////////////////////////////////////////////////////////////// |
---|
124 | Real OSFilCopy(Text source, Text target) |
---|
125 | ////////////////////////////////////////////////////////////////////////////// |
---|
126 | { |
---|
127 | //! Las rutas de ser relativas se refieren al directorio de trabajo |
---|
128 | Text spath = Replace(GetAbsolutePath(source), "\\", "/"); |
---|
129 | Text tpath = Replace(GetAbsolutePath(target), "\\", "/"); |
---|
130 | Set eval = Tcl_Eval("file copy -force -- {"<<spath<<"} {"<<tpath<<"}"); |
---|
131 | If(eval[2], 1, { Write(eval[1], "E"); 0 }) |
---|
132 | }; |
---|
133 | Code PutDescription(Description(TolCore::OSFilCopy), OSFilCopy); |
---|
134 | |
---|
135 | ////////////////////////////////////////////////////////////////////////////// |
---|
136 | Real OSFilMove(Text source, Text target) |
---|
137 | ////////////////////////////////////////////////////////////////////////////// |
---|
138 | { |
---|
139 | //! Las rutas de ser relativas se refieren al directorio de trabajo |
---|
140 | Text spath = Replace(GetAbsolutePath(source), "\\", "/"); |
---|
141 | Text tpath = Replace(GetAbsolutePath(target), "\\", "/"); |
---|
142 | Set eval = Tcl_Eval("file rename {"<<spath<<"} {"<<tpath<<"}"); |
---|
143 | If(eval[2], 1, { Write(eval[1], "E"); 0 }) |
---|
144 | }; |
---|
145 | Code PutDescription(Description(TolCore::OSFilMove), OSFilMove); |
---|
146 | |
---|
147 | ////////////////////////////////////////////////////////////////////////////// |
---|
148 | Real OSDirMake(Text directory) |
---|
149 | ////////////////////////////////////////////////////////////////////////////// |
---|
150 | { |
---|
151 | //! Las rutas de ser relativas se refieren al directorio de trabajo |
---|
152 | Text dpath = Replace(GetAbsolutePath(directory), "\\", "/"); |
---|
153 | Set eval = Tcl_Eval("file mkdir {"<<dpath<<"}"); |
---|
154 | If(eval[2], 1, { Write(eval[1], "E"); 0 }) |
---|
155 | }; |
---|
156 | Code PutDescription(Description(TolCore::OSDirMake), OSDirMake); |
---|
157 | |
---|
158 | ////////////////////////////////////////////////////////////////////////////// |
---|
159 | Real OSDirRemove(Text directory) |
---|
160 | ////////////////////////////////////////////////////////////////////////////// |
---|
161 | { |
---|
162 | //! Las rutas de ser relativas se refieren al directorio de trabajo |
---|
163 | Text dpath = Replace(GetAbsolutePath(directory), "\\", "/"); |
---|
164 | Set eval = Tcl_Eval("file delete -force -- {"<<dpath<<"}"); |
---|
165 | If(eval[2], 1, { Write(eval[1], "E"); 0 }) |
---|
166 | }; |
---|
167 | Code PutDescription(Description(TolCore::OSDirRemove), OSDirRemove); |
---|
168 | |
---|
169 | ////////////////////////////////////////////////////////////////////////////// |
---|
170 | Real OSDirCopy(Text source, Text target) |
---|
171 | ////////////////////////////////////////////////////////////////////////////// |
---|
172 | { |
---|
173 | //! Las rutas de ser relativas se refieren al directorio de trabajo |
---|
174 | Text spath = Replace(GetAbsolutePath(source), "\\", "/"); |
---|
175 | Text tpath = Replace(GetAbsolutePath(target), "\\", "/"); |
---|
176 | Set eval = Tcl_Eval("file copy -force -- {"<<spath<<"} {"<<tpath<<"}"); |
---|
177 | If(eval[2], 1, { Write(eval[1], "E"); 0 }) |
---|
178 | }; |
---|
179 | Code PutDescription(Description(TolCore::OSDirCopy), OSDirCopy); |
---|
180 | |
---|
181 | ////////////////////////////////////////////////////////////////////////////// |
---|
182 | Real OSDirMove(Text source, Text target) |
---|
183 | ////////////////////////////////////////////////////////////////////////////// |
---|
184 | { |
---|
185 | //! Las rutas de ser relativas se refieren al directorio de trabajo |
---|
186 | Text spath = Replace(GetAbsolutePath(source), "\\", "/"); |
---|
187 | Text tpath = Replace(GetAbsolutePath(target), "\\", "/"); |
---|
188 | Set eval = Tcl_Eval("file rename {"<<spath<<"} {"<<tpath<<"}"); |
---|
189 | If(eval[2], 1, { Write(eval[1], "E"); 0 }) |
---|
190 | }; |
---|
191 | Code PutDescription(Description(TolCore::OSDirMove), OSDirMove); |
---|
192 | |
---|
193 | ////////////////////////////////////////////////////////////////////////////// |
---|
194 | // Ejemplos: |
---|
195 | // Real WinSystem("cmd /c dir", 0, 1); |
---|