File: utf8process.xml

package info (click to toggle)
lazarus 4.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276,392 kB
  • sloc: pascal: 2,344,754; xml: 509,184; makefile: 355,815; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (382 lines) | stat: -rw-r--r-- 14,053 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<?xml version="1.0" encoding="UTF-8"?>
<!--

Documentation for LCL (Lazarus Component Library) and LazUtils (Lazarus 
Utilities) are published under the Creative Commons Attribution-ShareAlike 4.0 
International public license.

https://creativecommons.org/licenses/by-sa/4.0/legalcode.txt
https://gitlab.com/freepascal.org/lazarus/lazarus/-/blob/main/docs/cc-by-sa-4-0.txt

Copyright (c) 1997-2025, by the Lazarus Development Team.

-->
<fpdoc-descriptions>
<package name="lazutils">
<!--
====================================================================
UTF8Process
====================================================================
-->
<module name="UTF8Process">
<short>
Implements a version of the FCL TProcess component that allows UTF-8-encoded 
arguments.
</short>
<descr>
<p>
<file>utf8process.pp</file> implements the <var>TProcessUTF8</var> component 
which provides a TProcess descendant that allows UTF-8-encoded values in its 
properties. The TProcessUTF8 component is added to the <b>System</b> tab in 
the Lazarus IDE Component Palette.
</p>
<p>
<file>utf8process.pp</file> is part of the <file>LazUtils</file> package.
</p>
</descr>

<!-- unresolved external references -->
<element name="Classes"/>
<element name="SysUtils"/>
<element name="Process"/>
<element name="pipes"/>
<element name="FileUtil"/>
<element name="LazFileUtils"/>
<element name="LazUTF8"/>
<element name="LazUtilsStrConsts"/>

<element name="SNoCommandLine">
<descr>
<p>
Exception message raised when a process has no executable or command-line. 
Present for the Microsoft Windows platform.
</p>
</descr>
</element>

<element name="SErrCannotExecute">
<descr>
<p>
Exception message raised when a process cannot be created for the executable 
or command-line. Present for the Microsoft Windows platform.
</p>
</descr>
</element>

<element name="TProcessUTF8">
<short>
Implements a version of the FCL TProcess that allows UTF-8-encoded arguments.
</short>
<descr>
<p>
<var>TProcessUTF8</var> is a <var>TProcess</var> descendant which implements 
a version of TProcess that accepts and processes UTF-8-encoded arguments. It 
includes a <var>ParseCmdLine</var> method used to separate a command line 
into the <var>Executable</var> name and <var>Parameters</var> used in the 
class instance.
</p>
<p>
The TProcessUTF8 interface includes additional methods for the Microsoft 
Windows platform. An overridden <var>Execute</var> method is provided, and 
protected methods to assign IDs and Handles for the process and its thread. 
These methods handle Windows-specific nuances required for the CreateProcessW 
API. This includes security and thread attributes, pipe creation, and any 
quoting required for file names or parameters with space characters.
</p>
<p>
TProcessUTF8 is used in the implementation of the Lazarus IDE and related 
tools like the Debugger, HTML Help viewer, external tools, and the FP Doc 
Editor. Use TAsyncProcess for a process which receives asynchronous 
notifications during process execution.
</p>
</descr>
<seealso>
<link id="#fcl.process.TProcess">TProcess</link>
<link id="#lcl.asyncprocess.TAsyncProcess">TAsyncProcess</link>
</seealso>
</element>

<element name="TProcessUTF8.SetProcessHandle">
<short>Updates the process handle for the class instance.</short>
<descr>
<p>
Raises an Exception if the ProcessHandle property cannot be set to the value 
specified in aProcessHandle.
</p>
</descr>
<seealso>
<link id="#fcl.process.TProcess.ProcessHandle">TProcess.ProcessHandle</link>
</seealso>
</element>
<element name="TProcessUTF8.SetProcessHandle.aProcessHandle">
<short>Process handle assigned to the ancestor class.</short>
</element>

<element name="TProcessUTF8.SetThreadHandle">
<short>Sets ThreadHandle to the specified value.</short>
<descr/>
<seealso/>
</element>
<element name="TProcessUTF8.SetThreadHandle.aThreadHandle">
<short>Thread handle assigned to the ancestor class.</short>
</element>

<element name="TProcessUTF8.SetProcessID">
<short>Sets ProcessID to the specified value.</short>
<descr/>
<seealso/>
</element>
<element name="TProcessUTF8.SetProcessID.aProcessID">
<short>Process ID assigned to the ancestor class.</short>
</element>

<element name="TProcessUTF8.Execute">
<short>Starts execution of the process.</short>
<descr>
<p>
<var>Execute</var> is an overridden method in <var>TProcessUTF8</var>, and is 
defined only for the Microsoft Windows platforms where poDetached in not 
available as a process option. Execute handles the nuances of configuring and 
executing a call to CreateProcessW in the Windows API.
</p>
<p>
The values in <var>ApplicationName</var>, <var>CommandLine</var>, and 
<var>Executable</var> are checked to ensure that they contain non-empty 
values. An <var>EProcess</var> exception is raised if any of these properties 
contain an empty string (<b>''</b>).
</p>
<p>
<var>UTF8Decode</var> is called to convert the property values to Unicode 
strings, and ultimately the WideStr values passed to CreateProcessW. 
Additional quoting may be applied to the values when the path to the file or 
arguments contain a Space character. UTF8Decode is also called for the value 
in the <var>CurrentDirectory</var> property. <var>StringsToWChars</var> is 
called to convert values in <var>Environment</var>.
</p>
<p>
Execute initializes the creation flags, process attributes, thread 
attributes, and start-up information required for the CreateProcessW API 
call. Values in the <var>Options</var> property determine whether 
<var>CreatePipes</var> is called for the handles in the start-up information.
</p>
<p>
Execute raises an EProcess exception if the CreateProcessW API call returns 
<b>False</b>. Otherwise, the values in <var>ProcessID</var>, 
<var>ProcessHandle</var>, and <var>ThreadHandle</var> are assigned for the 
current class instance.
</p>
<p>
When Options contains the value <var>poUsePipes</var>, the process will 
redirect information on the standard input, output, and error handles 
allocated in start-up information. Use the THandleStream instances used in 
the Input, Output, and StdErr properties to access values for the API call.
</p>
<p>
Executes sets the value in <var>Running</var> to <b>True</b>, and frees 
memory allocated to the pointer for the <var>Environment</var> in the process.
</p>
<p>
At run-time, Execute calls <var>WaitOnExit</var> to detect completion of the 
process and to set values in the <var>ExitStatus</var> and 
<var>ExitCode</var> properties. This occurs when <var>poWaitOnExit</var> is 
included in the Options for the process, and <var>poRunSuspended</var> is 
<b>not</b> included in the Options. WaitOnExit is never called at design-time 
to prevent hanging the IDE.
</p>
<p>
Please note: The overridden Execute method in TProcessUTF8 does not call the 
inherited method.
</p>
</descr>
<seealso>
<link id="TProcessUTF8.ParseCmdLine"/>
<link id="#fcl.process.TProcess.Executable">TProcess.Executable</link>
<link id="#fcl.process.TProcess.Parameters">TProcess.Parameters</link>
<link id="#fcl.process.TProcess.CommandLine">TProcess.CommandLine</link>
<link id="#fcl.process.TProcess.Environment">TProcess.Environment</link>
<link id="#fcl.process.TProcess.Execute">TProcess.Execute</link>
<link id="#fcl.process.TProcess.Options">TProcess.Options</link>
<link id="#fcl.process.TProcess.Input">TProcess.Input</link>
<link id="#fcl.process.TProcess.Output">TProcess.Output</link>
</seealso>
</element>

<element name="TProcessUTF8.ParseCmdLine">
<short>
Separates values in the CommandLine argument into the Executable and 
Parameters properties.
</short>
<descr>
<p>
<var>ParseCmdLine</var> is used to separate the values in the CmdLine 
argument into the values used for the Executable and Parameters properties.
</p>
<p>
<var>ReadBackSlash</var> indicates if the <b>BackSlash</b> character 
(<b>\</b>) is used to quote a character value in the command line. The 
default value for the argument is <b>False</b>.
</p>
<p>
ParseCmdLine creates an internal <var>TStringList</var> instance used to 
store values returned from the <var>SplitCmdLineParams</var> routine in 
<file>lazfileutils.pas</file>. The first value in the string list (when 
present) is stored in the <var>Executable</var> property. The remaining 
values are stored in the <var>Parameters</var> property.
</p>
<p>
ParseCmdLine is provided as a convenience method. The same result can be 
achieved by setting the values in the Executable and Parameters properties 
directly.
</p>
</descr>
<seealso>
<link id="#lazutils.lazfileutils.SplitCmdLineParams">SplitCmdLineParams</link>
<link id="#fcl.process.TProcess.Executable">TProcess.Executable</link>
<link id="#fcl.process.TProcess.Parameters">TProcess.Parameters</link>
</seealso>
</element>
<element name="TProcessUTF8.ParseCmdLine.CmdLine">
<short>Command line examined and parsed in the method.</short>
</element>
<element name="TProcessUTF8.ParseCmdLine.ReadBackslash">
<short>
When <b>True</b>, the BackSlash character is used to quote character values.
</short>
</element>

<element name="RunCmdFromPath">
<short>Executes a command found in the current PATH environment.</short>
<descr>
<p>
<var>RunCmdFromPath</var> is used to execute a command which can be found in 
the current <var>PATH</var> environment. For example, the following locates 
and executes the <b>/bin/ls -l /home</b> command:
</p>
<code>
            RunCmdFromPath('ls', '-l /home');
</code>
<p>
An exception is raised if the program file cannot be located, or cannot be 
executed.
</p>
<p>
RunCmdFromPath creates and configures a <var>TProcessUTF8</var> instance 
which is used to execute the program file. <var>ProgramFilename</var> 
contains the qualified executable file name for the process. If the argument 
contains a <b>Space</b> (<b>' '</b>), it is surrounded by <b>Quotation 
Mark</b> (<b>"</b>) characters before it is assigned to the class instance. 
<var>CmdLineParameters</var> contains optional parameters values for the 
executable file. It is assumed that parameter values with embedded spaces are 
already quoted when passed to the routine. CmdLineParameters is included in 
the class instance when the value is not an empty string (<b>''</b>).
</p>
<p>
RunCmdFromPath calls the <var>Execute</var> method in the TProcessUTF8 
instance to execute the specified program file name with the specified 
parameter values.
</p>
</descr>
<errors>
<dl>
<dt>EFOpenError</dt>
<dd>
Raised with the message in lrsProgramFileNotFound or lrsCanNotExecute.
</dd>
</dl>
</errors>
<!--
===========================================
Uncomment when the target version is known.
===========================================
<version>
Modified in LazUtils version 2.3.0 to wait for process exit during execution.
</version>
-->
<seealso>
<!-- not an error: {$IFDEF UseTProcessW} -->
<!-- link id="TProcessUTF8.Execute"/ -->
<link id="#fcl.process.TProcess.Execute">TProcess.Execute</link>
<link id="#fcl.process.TProcess.CommandLine">TProcess.CommandLine</link>
<link id="#fcl.process.TProcess.Executable">TProcess.Executable</link>
<link id="#fcl.process.TProcess.Parameters">TProcess.Parameters</link>
<link id="#fcl.process.TProcess.Environment">TProcess.Environment</link>
</seealso>
</element>
<element name="RunCmdFromPath.ProgramFilename">
<short>Path and name for the program executed.</short>
</element>
<element name="RunCmdFromPath.CmdLineParameters">
<short>Command line parameters for the program.</short>
</element>

<element name="FindFilenameOfCmd">
<short>Gets the full path for the specified executable file.</short>
<descr>
<p>
<var>FindFilenameOfCmd</var> is a <var>String</var> function used to get the 
full path for the executable file specified in the <var>ProgramFilename</var> 
argument. FindFilenameOfCmd calls the <var>FilenameIsAbsolute</var> routine 
to determine if a relative path in ProgramFilename needs to be resolved. 
<var>FindDefaultExecutablePath</var> is called to search the <b>PATH</b> 
environment when path information is not used in ProgramFilename.
</p>
<p>
The return value contains the absolute path and file name. If the file does 
not exist on the local file system, the return value is an empty string ('').
</p>
</descr>
<seealso>
<link id="#lazutils.lazfileutils.FilenameIsAbsolute">FilenameIsAbsolute</link>
<link id="#lazutils.lazfileutils.CleanAndExpandFilename">CleanAndExpandFilename</link>
<link id="#lazutils.fileutil.FindDefaultExecutablePath">FindDefaultExecutablePath</link>
</seealso>
</element>
<element name="FindFilenameOfCmd.Result">
<short>
Absolute path to the requested program file, or an empty string.
</short>
</element>
<element name="FindFilenameOfCmd.ProgramFilename">
<short>Program file examined in the method.</short>
</element>

<element name="GetSystemThreadCount">
<short>Gets the number of threads available on the system.</short>
<descr>
<p>
<var>GetSystemThreadCount</var> is an <var>Integer</var> function used to get 
the number of threads on the system. The implementation for 
GetSystemThreadCount is platform- and/or OS-specific. For the Windows 
environment, the total number of processors available (including logical 
hyperthreaded processors) are returned using the GetProcessAffinityMask API. 
When GetProcessAffinityMask is unavailable, the total number of processors 
from GetSystemInfo is used. For UNIX-like environments, either the sysconf or 
the fpsysctl function is used. For other environments, the return value is 
always <b>1</b>.
</p>
</descr>
<seealso/>
</element>
<element name="GetSystemThreadCount.Result">
<short>The number of threads on the system.</short>
</element>

<element name="Register">
<short>Registers components for use in the Lazarus IDE.</short>
<descr>
<p>
<var>Register</var> is a procedure used to make components in the unit 
available for use in the Lazarus IDE. Register calls 
<var>RegisterComponents</var> to make the <var>TProcessUTF8</var> available 
on the <b>System</b> tab.
</p>
</descr>
<seealso>
<link id="TProcessUTF8"/>
</seealso>
</element>

</module>
<!-- UTF8Process -->
</package>
</fpdoc-descriptions>