dos.tex 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \chapter{The DOS unit.}
  22. \FPCexampledir{dosex}
  23. This chapter describes the \var{DOS} unit for Free pascal, both under
  24. \dos, \ostwo, \windows and \linux.
  25. The unit was first written for \dos by Florian kl\"ampfl. It was ported to
  26. \linux by Mark May\footnote{Current e-mail address \textsf{[email protected]}},
  27. and enhanced by Micha\"el Van Canneyt. The \amiga version was ported by
  28. Nils Sjoholm.
  29. Under non-\dos systems, some of the functionality is lost, as it is either impossible
  30. or meaningless to implement it. Other than that, the functionality for all
  31. operating systems is the same.
  32. This chapter is divided in three sections:
  33. \begin{itemize}
  34. \item The first section lists the pre-defined constants, types and variables.
  35. \item The second section gives an overview of all functions available,
  36. grouped by category.
  37. \item The third section describes the functions which appear in the
  38. interface part of the DOS unit.
  39. \end{itemize}
  40. \section{Types, Variables, Constants}
  41. \subsection {Constants}
  42. The DOS unit implements the following constants:
  43. \begin{verbatim}
  44. {Bitmasks for CPU Flags}
  45. fcarry = $0001;
  46. fparity = $0004;
  47. fauxiliary = $0010;
  48. fzero = $0040;
  49. fsign = $0080;
  50. foverflow = $0800;
  51. {Bitmasks for file attribute}
  52. readonly = $01;
  53. hidden = $02;
  54. sysfile = $04;
  55. volumeid = $08;
  56. directory = $10;
  57. archive = $20;
  58. anyfile = $3F;
  59. fmclosed = $D7B0;
  60. fminput = $D7B1;
  61. fmoutput = $D7B2;
  62. fminout = $D7B3;
  63. \end{verbatim}
  64. \subsection{Types}
  65. The following string types are defined for easy handling of
  66. filenames :
  67. \begin{verbatim}
  68. ComStr = String[255]; { For command-lines }
  69. PathStr = String[255]; { For full path for file names }
  70. DirStr = String[255]; { For Directory and (DOS) drive string }
  71. NameStr = String[255]; { For Name of file }
  72. ExtStr = String[255]; { For Extension of file }
  73. \end{verbatim}
  74. \begin{verbatim}
  75. SearchRec = Packed Record
  76. Fill : array[1..21] of byte;
  77. { Fill replaced with declarations below, for Linux}
  78. Attr : Byte; {attribute of found file}
  79. Time : LongInt; {last modify date of found file}
  80. Size : LongInt; {file size of found file}
  81. Reserved : Word; {future use}
  82. Name : String[255]; {name of found file}
  83. SearchSpec: String[255]; {search pattern}
  84. NamePos: Word; {end of path, start of name position}
  85. End;
  86. \end{verbatim}
  87. Under \linux, the \var{Fill} array is replaced with the following:
  88. \begin{verbatim}
  89. SearchNum: LongInt; {to track which search this is}
  90. SearchPos: LongInt; {directory position}
  91. DirPtr: LongInt; {directory pointer for reading directory}
  92. SearchType: Byte; {0=normal, 1=open will close}
  93. SearchAttr: Byte; {attribute we are searching for}
  94. Fill: Array[1..07] of Byte; {future use}
  95. \end{verbatim}
  96. This is because the searching meachanism on Unix systems is substantially
  97. different from \dos's, and the calls have to be mimicked.
  98. \begin{verbatim}
  99. const
  100. filerecnamelength = 255;
  101. type
  102. FileRec = Packed Record
  103. Handle,
  104. Mode,
  105. RecSize : longint;
  106. _private : array[1..32] of byte;
  107. UserData : array[1..16] of byte;
  108. name : array[0..filerecnamelength] of char;
  109. End;
  110. \end{verbatim}
  111. \var{FileRec} is used for internal representation of typed and untyped files.
  112. Text files are handled by the following types :
  113. \begin{verbatim}
  114. const
  115. TextRecNameLength = 256;
  116. TextRecBufSize = 256;
  117. type
  118. TextBuf = array[0..TextRecBufSize-1] of char;
  119. TextRec = Packed Record
  120. Handle,
  121. Mode,
  122. bufsize,
  123. _private,
  124. bufpos,
  125. bufend : longint;
  126. bufptr : ^textbuf;
  127. openfunc,
  128. inoutfunc,
  129. flushfunc,
  130. closefunc : pointer;
  131. UserData : array[1..16] of byte;
  132. name : array[0..textrecnamelength-1] of char;
  133. buffer : textbuf;
  134. End;
  135. \end{verbatim}
  136. Remark that this is not binary compatible with the Turbo Pascal definition
  137. of \var{TextRec}, since the sizes of the different fields are different.
  138. \begin{verbatim}
  139. Registers = record
  140. case i : integer of
  141. 0 : (ax,f1,bx,f2,cx,f3,dx,f4,bp,f5,si,
  142. f51,di,f6,ds,f7,es,f8,flags,fs,gs : word);
  143. 1 : (al,ah,f9,f10,bl,bh,f11,f12,
  144. cl,ch,f13,f14,dl,dh : byte);
  145. 2 : (eax, ebx, ecx, edx, ebp, esi, edi : longint);
  146. End;
  147. \end{verbatim}
  148. The \var{registers} type is used in the \var{MSDos} call.
  149. \begin{verbatim}
  150. DateTime = record
  151. Year: Word;
  152. Month: Word;
  153. Day: Word;
  154. Hour: Word;
  155. Min: Word;
  156. Sec: word;
  157. End;
  158. \end{verbatim}
  159. The \var{DateTime} type is used in \seep{PackTime} and \seep{UnPackTime} for
  160. setting/reading file times with \seep{GetFTime} and \seep{SetFTime}.
  161. \subsection{Variables}
  162. \begin{verbatim}
  163. DosError : integer;
  164. \end{verbatim}
  165. The \var{DosError} variable is used by the procedures in the \dos unit to
  166. report errors. It can have the following values :
  167. \begin{center}
  168. \begin{tabular}{cl}
  169. 2 & File not found. \\
  170. 3 & path not found. \\
  171. 5 & Access denied. \\
  172. 6 & Invalid handle. \\
  173. 8 & Not enough memory. \\
  174. 10 & Invalid environment. \\
  175. 11 & Invalid format. \\
  176. 18 & No more files.
  177. \end{tabular}
  178. \end{center}
  179. Other values are possible, but are not documented.
  180. %\begin{verbatim}
  181. % drivestr : array [0..26] of pchar;
  182. %\end{verbatim}
  183. %This variable is defined in the \linux version of the \dos unit. It is used
  184. %in the \seef{DiskFree} and \seef{DiskSize} calls.
  185. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  186. % Functions and procedures by category
  187. \section{Function list by category}
  188. What follows is a listing of the available functions, grouped by category.
  189. For each function there is a reference to the page where you can find the
  190. function.
  191. \subsection{File handling}
  192. Routines to handle files on disk.
  193. \begin{funclist}
  194. \funcrefl{FExpand}{Dos:FExpand}{Expand filename to full path}
  195. \procref{FindClose}{Close finfirst/findnext session}
  196. \procref{FindFirst}{Start find of file}
  197. \procref{FindNext}{Find next file}
  198. \funcrefl{FSearch}{Dos:FSearch}{Search for file in a path}
  199. \procref{FSplit}{Split filename in parts}
  200. \procref{GetFAttr}{Return file attributes}
  201. \procref{GetFTime}{Return file time}
  202. \funcref{GetLongName}{Convert short filename to long filename}
  203. \funcref{GetShortName}{Convert long filename to short filename}
  204. \procref{SetFAttr}{Set file attributes}
  205. \procref{SetFTime}{Set file time}
  206. \end{funclist}
  207. \subsection{Directory and disk handling}
  208. Routines to handle disk information.
  209. \begin{funclist}
  210. \procref{AddDisk}{Add disk to list of disks}
  211. \funcref{DiskFree}{Return size of free disk space}
  212. \funcref{DiskSize}{Return total disk size}
  213. \end{funclist}
  214. \subsection{Process handling}
  215. Functions to handle process information and starting new processes.
  216. \begin{funclist}
  217. \funcref{DosExitCode}{Exit code of last executed program}
  218. \funcref{EnvCount}{Return number of environment variables}
  219. \funcref{EnvStr}{Return environment string pair}
  220. \procref{Exec}{Execute program}
  221. \funcrefl{GetEnv}{Dos:GetEnv}{Return specified environment string}
  222. \end{funclist}
  223. \subsection{System information}
  224. Functions for retrieving and setting general system information such as date
  225. and time.
  226. \begin{funclist}
  227. \funcref{DosVersion}{Get OS version}
  228. \procref{GetCBreak}{Get setting of control-break handling flag}
  229. \procrefl{GetDate}{Dos:GetDate}{Get system date}
  230. \procref{GetIntVec}{Get interrupt vector status}
  231. \procrefl{GetTime}{Dos:GetTime}{Get system time}
  232. \procref{GetVerify}{Get verify flag}
  233. \procref{Intr}{Execute an interrupt}
  234. \procref{Keep}{Keep process in memory and exit}
  235. \procref{MSDos}{Execute MS-dos function call}
  236. \procref{PackTime}{Pack time for file time}
  237. \procref{SetCBreak}{Set control-break handling flag}
  238. \procref{SetDate}{Set system date}
  239. \procref{SetIntVec}{Set interrupt vectors}
  240. \procref{SetTime}{Set system time}
  241. \procref{SetVerify}{Set verify flag}
  242. \procref{SwapVectors}{Swap interrupt vectors}
  243. \procref{UnPackTime}{Unpack file time}
  244. \end{funclist}
  245. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  246. % Functions and procedures
  247. \section{Functions and Procedures}
  248. \begin{procedure}{AddDisk}
  249. \Declaration
  250. Procedure AddDisk (Const S : String);
  251. \Description
  252. \var{AddDisk} adds a filename \var{S} to the internal list of disks. It is
  253. implemented for \linux only.
  254. This list is used to determine which disks to use in the \seef{DiskFree}
  255. and \seef{DiskSize} calls.
  256. The \seef{DiskFree} and \seef{DiskSize} functions need a file on the
  257. specified drive, since this is required for the \var{statfs} system call.
  258. The names are added sequentially. The dos
  259. initialization code presets the first three disks to:
  260. \begin{itemize}
  261. \item \var{'.'} for the current drive,
  262. \item \var{'/fd0/.'} for the first floppy-drive.
  263. \item \var{'/fd1/.'} for the second floppy-drive.
  264. \item \var{'/'} for the first hard disk.
  265. \end{itemize}
  266. The first call to \var{AddDisk} will therefore add a name for the second
  267. harddisk, The second call for the third drive, and so on until 23 drives
  268. have been added (corresponding to drives \var{'D:'} to \var{'Z:'})
  269. \Errors
  270. None
  271. \SeeAlso
  272. \seef{DiskFree}, \seef{DiskSize}
  273. \end{procedure}
  274. \begin{function}{DiskFree}
  275. \Declaration
  276. Function DiskFree (Drive: byte) : Int64;
  277. \Description
  278. \var{DiskFree} returns the number of free bytes on a disk. The parameter
  279. \var{Drive} indicates which disk should be checked. This parameter is 1 for
  280. floppy \var{a:}, 2 for floppy \var{b:}, etc. A value of 0 returns the free
  281. space on the current drive.
  282. Typically, the free space is the size of a disk block, multiplied by the
  283. number of free blocks on the disk.
  284. \textbf{For \linux only:}\\
  285. The \var{diskfree} and \var{disksize} functions need a file on the
  286. specified drive, since this is required for the \var{statfs} system call.
  287. These filenames are set in the initialization of the dos unit, and have
  288. been preset to :
  289. \begin{itemize}
  290. \item \var{'.'} for the current drive,
  291. \item \var{'/fd0/.'} for the first floppy-drive.
  292. \item \var{'/fd1/.'} for the second floppy-drive.
  293. \item \var{'/'} for the first hard disk.
  294. \end{itemize}
  295. There is room for 1-26 drives. You can add a drive with the
  296. \seep{AddDisk} procedure.
  297. These settings can be coded in \var{dos.pp}, in the initialization part.
  298. \Errors
  299. -1 when a failure occurs, or an invalid \var{drivenr} is given.
  300. \SeeAlso
  301. \seef{DiskSize}, \seep{AddDisk}
  302. \end{function}
  303. \FPCexample{ex6}
  304. \begin{function}{DiskSize}
  305. \Declaration
  306. Function DiskSize (Drive: byte) : Int64;
  307. \Description
  308. \var{DiskSize} returns the total size (in bytes) of a disk. The parameter
  309. \var{Drive} indicates which disk should be checked. This parameter is 1 for
  310. floppy \var{a:}, 2 for floppy \var{b:}, etc. A value of 0 returns the size
  311. of the current drive.
  312. \textbf{For \linux only:}\\
  313. The \var{diskfree} and \var{disksize} functions need a file on the specified drive, since this
  314. is required for the \var{statfs} system call.
  315. These filenames are set in the initialization of the dos unit, and have
  316. been preset to :
  317. \begin{itemize}
  318. \item \var{'.'} for the current drive,
  319. \item \var{'/fd0/.'} for the first floppy-drive.
  320. \item \var{'/fd1/.'} for the second floppy-drive.
  321. \item \var{'/'} for the first hard disk.
  322. \end{itemize}
  323. There is room for 1-26 drives. You can add a drive with the
  324. \seep{AddDisk} procedure.
  325. These settings can be coded in \var{dos.pp}, in the initialization part.
  326. \Errors
  327. -1 when a failure occurs, or an invalid drive number is given.
  328. \SeeAlso
  329. \seef{DiskFree}, \seep{AddDisk}
  330. \end{function}
  331. For an example, see \seef{DiskFree}.
  332. \begin{function}{DosExitCode}
  333. \Declaration
  334. Function DosExitCode : Word;
  335. \Description
  336. \var{DosExitCode} contains (in the low byte) the exit-code of a program
  337. executed with the \var{Exec} call.
  338. \Errors
  339. None.
  340. \SeeAlso
  341. \seep{Exec}
  342. \end{function}
  343. \FPCexample{ex5}
  344. \begin{function}{DosVersion}
  345. \Declaration
  346. Function DosVersion : Word;
  347. \Description
  348. \var{DosVersion} returns the \dos version number. On \linux systems, it
  349. returns the Linux version (The first 2 numbers, e.g Linux version 2.1.76 will
  350. give you DosVersion 2.1)
  351. \Errors
  352. None.
  353. \SeeAlso
  354. \end{function}
  355. \FPCexample{ex1}
  356. \begin{function}{EnvCount}
  357. \Declaration
  358. Function EnvCount : longint;\Description
  359. \var{EnvCount} returns the number of environment variables.
  360. \Errors
  361. None.
  362. \SeeAlso
  363. \seef{EnvStr}, \seef{Dos:GetEnv}
  364. \end{function}
  365. \begin{function}{EnvStr}
  366. \Declaration
  367. Function EnvStr (Index: integer) : string;\Description
  368. \var{EnvStr} returns the \var{Index}-th \var{Name=Value} pair from the list
  369. of environment variables.
  370. The index of the first pair is zero.
  371. \Errors
  372. The length is limited to 255 characters. This may cause problems under
  373. \linux. The \linux unit solves this problem.
  374. \SeeAlso
  375. \seef{EnvCount}, \seef{Dos:GetEnv}
  376. \end{function}
  377. \FPCexample{ex13}
  378. \begin{procedure}{Exec}
  379. \Declaration
  380. Procedure Exec (const Path: pathstr; const ComLine: comstr);
  381. \Description
  382. \var{Exec} executes the program in \var{Path}, with the options given by
  383. \var{ComLine}.
  384. After the program has terminated, the procedure returns. The Exit value of
  385. the program can be consulted with the \var{DosExitCode} function.
  386. \Errors
  387. Errors are reported in \var{DosError}.
  388. \SeeAlso
  389. \seef{DosExitCode}
  390. \end{procedure}
  391. For an example, see \seef{DosExitCode}
  392. \begin{functionl}{FExpand}{Dos:FExpand}
  393. \Declaration
  394. Function FExpand (const path: pathstr) : pathstr;
  395. \Description
  396. \var{FExpand} takes its argument and expands it to a complete filename, i.e.
  397. a filename starting from the root directory of the current drive, prepended
  398. with the drive-letter (under \dos).
  399. The resulting name is converted to uppercase on \dos systems. Under \linux,
  400. the name is left as it is. (filenames are case sensitive under Unix)
  401. \Errors
  402. \seep{FSplit}
  403. \SeeAlso
  404. \lstinputlisting{dosex/ex5.pp}
  405. \end{functionl}
  406. \begin{procedure}{FindClose}
  407. \Declaration
  408. Procedure FindClose (Var F: SearchRec);
  409. \Description
  410. \textbf{\linux, \windows and \ostwo wonly}
  411. \var{FindClose} frees any resources associated with the search record
  412. \var{F}.
  413. Under \linux, \windows and \ostwo the \var{findfirst/findnext} calls have
  414. to be mimicked. This call is needed to free any internal resources allocated
  415. by the \seef{FindFirst} or \seef{FindNext} calls.
  416. E.g. on \linux, an internal table of file descriptors is kept.
  417. When using different \var{searchrecs} at the same time,
  418. the system may run out of file descriptors for directories.
  419. The \linux implementation of the \dos unit therefore keeps a table of open
  420. directories, and when the table is full, closes one of the directories, and
  421. reopens another. This system is adequate but slow if you use a lot of
  422. \var{searchrecs}.
  423. So, to speed up the findfirst/findnext system, the \var{FindClose} call was
  424. implemented. When you don't need a \var{searchrec} any more, you can tell
  425. this to the \dos unit by issuing a \var{FindClose} call. The directory
  426. which is kept open for this \var{searchrec} is then closed, and the table slot
  427. freed.
  428. It is recommended to use the \linux call \var{Glob} when looking for files
  429. on \linux.
  430. \Errors
  431. None.
  432. \SeeAlso
  433. \seef{Glob}.
  434. \end{procedure}
  435. \begin{procedure}{FindFirst}
  436. \Declaration
  437. Procedure FindFirst (const Path: pathstr; Attr: word; var F: SearchRec);
  438. \Description
  439. \var{FindFirst} searches the file specified in \var{Path}, checks the
  440. atrributes specified in \var{Attr}. It returns a \var{SearchRec} record for
  441. further searching in \var{F}.
  442. \var{Path} can contain the wildcard characters \var{?} (matches any single
  443. character) and \var{*} (matches 0 ore more arbitrary characters). In this
  444. case \var{FindFirst} will return the first file which matches the specified
  445. criteria.
  446. If \var{DosError} is different from zero, no file(s) matching the criteria
  447. was(were) found.
  448. On \ostwo, you cannot issue two different \var{FindFirst} calls. That is,
  449. you must close any previous search operation with \seep{FindClose} before
  450. starting a new one. Failure to do so will end in a Run-Time Error 6
  451. (Invalid file handle)
  452. Also, on \ostwo, the boolean variable \var{FileNameCaseSensitive} indicates
  453. whether searches are conducted case-sensitive or not. By default, searches
  454. are not case sensitive. If the varieble is set to \var{True}, searches on
  455. \ostwo are case sensistive.
  456. \Errors
  457. Errors are reported in DosError.
  458. \SeeAlso
  459. \seep{FindNext},
  460. \seep{FindClose}
  461. \end{procedure}
  462. \FPCexample{ex7}
  463. \begin{procedure}{FindNext}
  464. \Declaration
  465. Procedure FindNext (var f: searchRec);
  466. \Description
  467. \var{FindNext} takes as an argument a \var{SearchRec} from a previous
  468. \var{FindNext} call, or a \var{FindFirst} call, and tries to find another
  469. file which matches the criteria, specified in the \var{FindFirst} call.
  470. If \var{DosError} is different from zero, no more files matching the
  471. criteria were found.
  472. \Errors
  473. \var{DosError} is used to report errors.
  474. \SeeAlso
  475. \seep{FindFirst}, \seep{FindClose}
  476. \end{procedure}
  477. For an example, see \seep{FindFirst}.
  478. \begin{functionl}{FSearch}{Dos:FSearch}
  479. \Declaration
  480. Function FSearch (Path: pathstr; DirList: string) : pathstr;
  481. \Description
  482. \var{FSearch} searches the file \var{Path} in all directories listed in
  483. \var{DirList}. The full name of the found file is returned.
  484. \var{DirList} must be a list of directories, separated by semi-colons (or
  485. colons under \linux).
  486. When no file is found, an empty string is returned.
  487. \Errors
  488. None.
  489. \SeeAlso
  490. \seefl{FExpand}{Dos:FExpand}
  491. \end{functionl}
  492. \FPCexample{ex10}
  493. \begin{procedure}{FSplit}
  494. \Declaration
  495. Procedure FSplit (path: pathstr; \\ var dir: dirstr; var name: namestr;
  496. var ext: extstr);
  497. \Description
  498. \var{FSplit} splits a full file name into 3 parts : A \var{Path}, a
  499. \var{Name} and an extension (in \var{ext}.)
  500. The extension is taken to be all letters after the {\em last} dot (.). For
  501. \dos, however, an exception is made when \var{LFNSupport=False}, then
  502. the extension is defined as all characters after the {\em first} dot.
  503. \Errors
  504. None.
  505. \SeeAlso
  506. \seefl{FSearch}{Dos:FSearch}
  507. \end{procedure}
  508. \FPCexample{ex12}
  509. \begin{procedure}{GetCBreak}
  510. \Declaration
  511. Procedure GetCBreak (var breakvalue: boolean);
  512. \Description
  513. \var{GetCBreak} gets the status of CTRL-Break checking under \dos.
  514. When \var{BreakValue} is \var{false}, then \dos only checks for the
  515. CTRL-Break key-press when I/O is performed. When it is set to \var{True},
  516. then a check is done at every system call.
  517. \Errors
  518. Under Linux, this exists but is
  519. not implemented, i.e. the call does nothing.
  520. \SeeAlso
  521. \seep{SetCBreak}
  522. \end{procedure}
  523. \begin{procedurel}{GetDate}{Dos:GetDate}
  524. \Declaration
  525. Procedure GetDate (var year, month, mday, wday: word);\Description
  526. \var{GetDate} returns the system's date. \var{Year} is a number in the range
  527. 1980..2099.\var{mday} is the day of the month,
  528. \var{wday} is the day of the week, starting with Sunday as day 0.
  529. \Errors
  530. None.
  531. \SeeAlso
  532. \seepl{GetTime}{Dos:GetTime},\seep{SetDate}
  533. \end{procedurel}
  534. \FPCexample{ex2}
  535. \begin{functionl}{GetEnv}{Dos:GetEnv}
  536. \Declaration
  537. Function GetEnv (EnvVar: String) : String;
  538. \Description
  539. \var{Getenv} returns the value of the environment variable \var{EnvVar}.
  540. Under \linux, case is important when looking for \var{EnvVar}.
  541. When there is no environment variable \var{EnvVar} defined, an empty
  542. string is returned.
  543. \Errors
  544. None.
  545. \SeeAlso
  546. \seef{EnvCount}, \seef{EnvStr}
  547. \end{functionl}
  548. \FPCexample{ex14}
  549. \begin{procedure}{GetFAttr}
  550. \Declaration
  551. Procedure GetFAttr (var F; var Attr: word);
  552. \Description
  553. \var{GetFAttr} returns the file attributes of the file-variable \var{f}.
  554. \var{F} can be a untyped or typed file, or of type \var{Text}. \var{f} must
  555. have been assigned, but not opened. The attributes can be examined with the
  556. following constants :
  557. \begin{itemize}
  558. \item \var{ReadOnly = 01h}
  559. \item \var{Hidden = 02h}
  560. \item \var{SysFile = 04h}
  561. \item \var{VolumeId = 08h}
  562. \item \var{Directory = 10h}
  563. \item \var{Archive = 20h}
  564. \end{itemize}
  565. Under \linux, supported attributes are:
  566. \begin{itemize}
  567. \item \var{Directory}
  568. \item \var{ReadOnly} if the current process doesn't have access to the file.
  569. \item \var{Hidden} for files whose name starts with a dot \var{('.')}.
  570. \end{itemize}
  571. \Errors
  572. Errors are reported in \var{DosError}
  573. \SeeAlso
  574. \seep{SetFAttr}
  575. \end{procedure}
  576. \FPCexample{ex8}
  577. \begin{procedure}{GetFTime}
  578. \Declaration
  579. Procedure GetFTime (var F; var Time: longint);
  580. \Description
  581. \var{GetFTime} returns the modification time of a file.
  582. This time is encoded and must be decoded with \var{UnPackTime}.
  583. \var{F} must be a file type, which has been assigned, and
  584. opened.
  585. \Errors
  586. Errors are reported in \var{DosError}
  587. \SeeAlso
  588. \seep{SetFTime}, \seep{PackTime},\seep{UnPackTime}
  589. \end{procedure}
  590. \FPCexample{ex9}
  591. \begin{procedure}{GetIntVec}
  592. \Declaration
  593. Procedure GetIntVec (IntNo: byte; var Vector: pointer);
  594. \Description
  595. \var{GetIntVec} returns the address of interrupt vector
  596. \var{IntNo}.
  597. \Errors
  598. Under non- \dos operating systems, this call does nothing.
  599. \SeeAlso
  600. \seep{SetIntVec}
  601. \end{procedure}
  602. \begin{function}{GetLongName}
  603. \Declaration
  604. function GetLongName(var p : String) : boolean;\Description
  605. This function is only implemented in the GO32V2 version of \fpc.
  606. \var{GetLongName} changes the filename \var{p} to a long filename
  607. if the \dos call to do this is successful. The resulting string
  608. is the long file name corresponding to the short filename \var{p}.
  609. The function returns \var{True} if the \dos call was successful,
  610. \var{False} otherwise.
  611. This function should only be necessary when using the DOS extender
  612. under Windows 95 and higher.
  613. \Errors
  614. If the \dos call was not succesfull, \var{False} is returned.
  615. \SeeAlso
  616. \seef{GetShortName}
  617. \end{function}
  618. \begin{function}{GetShortName}
  619. \Declaration
  620. function GetShortName(var p : String) : boolean;\Description
  621. This function is only implemented in the GO32V2 version of \fpc.
  622. \var{GetShortName} changes the filename \var{p} to a short filename
  623. if the \dos call to do this is successful. The resulting string
  624. is the short file name corresponding to the long filename \var{p}.
  625. The function returns \var{True} if the \dos call was successful,
  626. \var{False} otherwise.
  627. This function should only be necessary when using the DOS extender
  628. under Windows 95 and higher.
  629. \Errors
  630. If the \dos call was not successful, \var{False} is returned.
  631. \SeeAlso
  632. \seef{GetLongName}
  633. \end{function}
  634. \begin{procedurel}{GetTime}{Dos:GetTime}
  635. \Declaration
  636. Procedure GetTime (var hour, minute, second, sec100: word);
  637. \Description
  638. \var{GetTime} returns the system's time. \var{Hour} is a on a 24-hour time
  639. scale. \var{sec100} is in hundredth of a
  640. second.
  641. \Errors
  642. None.
  643. \SeeAlso
  644. \seepl{GetDate}{Dos:GetDate},
  645. \seep{SetTime}
  646. \end{procedurel}
  647. \FPCexample{ex3}
  648. \begin{procedure}{GetVerify}
  649. \Declaration
  650. Procedure GetVerify (var verify: boolean);
  651. \Description
  652. \var{GetVerify} returns the status of the verify flag under \dos. When
  653. \var{Verify} is \var{True}, then \dos checks data which are written to disk,
  654. by reading them after writing. If \var{Verify} is \var{False}, then data
  655. written to disk are not verified.
  656. \Errors
  657. Under \linux, Verify is always
  658. \var{True}.
  659. \SeeAlso
  660. \seep{SetVerify}
  661. \end{procedure}
  662. \begin{procedure}{Intr}
  663. \Declaration
  664. Procedure Intr (IntNo: byte; var Regs: registers);
  665. \Description
  666. \var{Intr} executes a software interrupt number \var{IntNo} (must be between
  667. 0 and 255), with processor registers set to \var{Regs}. After the interrupt call
  668. returned, the processor registers are saved in \var{Regs}.
  669. \Errors
  670. Under \linux this call does nothing, because interrupts are managed by the
  671. kernel. The only allowed interrupt is 80h, the Linux kernel entry interrupt.
  672. \SeeAlso
  673. \seep{MSDos}, see the \linux unit.
  674. \end{procedure}
  675. \begin{procedure}{Keep}
  676. \Declaration
  677. Procedure Keep (ExitCode: word);
  678. \Description
  679. \var{Keep} terminates the program, but stays in memory. This is used for TSR
  680. (Terminate Stay Resident) programs which catch some interrupt.
  681. \var{ExitCode} is the same parameter as the \var{Halt} function takes.
  682. \Errors
  683. Under non-\dos operating systems, this call does nothing.
  684. \SeeAlso
  685. \seem{Halt}{}
  686. \end{procedure}
  687. \begin{procedure}{MSDos}
  688. \Declaration
  689. Procedure MSDos (var regs: registers);
  690. \Description
  691. \var{MSDos} executes an MS-\dos call (int 21h). This is the same as doing a
  692. \var{Intr} call with an interrupt number of 21h.
  693. \Errors
  694. None.
  695. \SeeAlso
  696. \seep{Intr}
  697. \end{procedure}
  698. \begin{procedure}{PackTime}
  699. \Declaration
  700. Procedure PackTime (var T: datetime; var P: longint);
  701. \Description
  702. \var{UnPackTime} converts the date and time specified in \var{T}
  703. to a packed-time format which can be fed to \var{SetFTime}.
  704. \Errors
  705. None.
  706. \SeeAlso
  707. \seep{SetFTime}, \seep{FindFirst}, \seep{FindNext}, \seep{UnPackTime}
  708. \end{procedure}
  709. \FPCexample{ex4}
  710. \begin{procedure}{SetCBreak}
  711. \Declaration
  712. Procedure SetCBreak (breakvalue: boolean);
  713. \Description
  714. \var{SetCBreak} sets the status of CTRL-Break checking under \dos.
  715. When \var{BreakValue} is \var{false}, then \dos only checks for the
  716. CTRL-Break key-press when I/O is performed. When it is set to \var{True},
  717. then a check is done at every system call.
  718. \Errors
  719. Under Linux, this call exists
  720. but is not implemented, i.e. it does nothing.
  721. \SeeAlso
  722. \seep{GetCBreak}
  723. \end{procedure}
  724. \begin{procedure}{SetDate}
  725. \Declaration
  726. Procedure SetDate (year,month,day: word);
  727. \Description
  728. \var{SetDate} sets the system's internal date. \var{Year} is a number
  729. between 1980 and 2099.
  730. \Errors
  731. On a \linux machine, this is not implemented (allthough a procedure
  732. exists, it just doesn't do anything. The setting of the date is a
  733. root-only privilege, and is hence not implemented.
  734. \SeeAlso
  735. \seep{Dos:GetDate},
  736. \seep{SetTime}
  737. \end{procedure}
  738. \begin{procedure}{SetFAttr}
  739. \Declaration
  740. Procedure SetFAttr (var F; Attr: word);
  741. \Description
  742. \var{SetFAttr} sets the file attributes of the file-variable \var{F}.
  743. \var{F} can be a untyped or typed file, or of type \var{Text}. \var{F} must
  744. have been assigned, but not opened. The attributes can be a sum of the
  745. following constants:
  746. \begin{itemize}
  747. \item \var{ReadOnly = 01h}
  748. \item \var{Hidden = 02h}
  749. \item \var{SysFile = 04h}
  750. \item \var{VolumeId = 08h}
  751. \item \var{Directory = 10h}
  752. \item \var{Archive = 20h}
  753. \item \var{AnyFile = 3fh}
  754. \end{itemize}
  755. \Errors
  756. Errors are reported in \var{DosError}.
  757. Under \linux the call exists, but is not implemented, i.e. it does nothing.
  758. \SeeAlso
  759. \seep{GetFAttr}
  760. \end{procedure}
  761. \begin{procedure}{SetFTime}
  762. \Declaration
  763. Procedure SetFTime (var F; Time: longint);
  764. \Description
  765. \var{SetFTime} sets the modification time of a file,
  766. this time is encoded and must be encoded with \var{PackTime}.
  767. \var{F} must be a file type, which has been assigned, and
  768. opened.
  769. \Errors
  770. Errors are reported in \var{DosError}
  771. \SeeAlso
  772. \seep{GetFTime}, \seep{PackTime},\seep{UnPackTime}
  773. \end{procedure}
  774. \begin{procedure}{SetIntVec}
  775. \Declaration
  776. Procedure SetIntVec (IntNo: byte; Vector: pointer);
  777. \Description
  778. \var{SetIntVec} sets interrupt vector \var{IntNo} to \var{Vector}.
  779. \var{Vector} should point to an interrupt procedure.
  780. \Errors
  781. Under non- \dos operating systems, this call does nothing.
  782. \SeeAlso
  783. \seep{GetIntVec}
  784. \end{procedure}
  785. \begin{procedure}{SetTime}
  786. \Declaration
  787. Procedure SetTime (hour,minute,second,sec100: word);
  788. \Description
  789. \var{SetTime} sets the system's internal clock. The \var{Hour} parameter is
  790. on a 24-hour time scale.
  791. \Errors
  792. this call exists, but is not implemented on \linux,
  793. as setting the time is a root-only privilege.
  794. \SeeAlso
  795. \seep{Dos:GetTime}, \seep{SetDate}
  796. \end{procedure}
  797. \begin{procedure}{SetVerify}
  798. \Declaration
  799. Procedure SetVerify (verify: boolean);
  800. \Description
  801. \var{SetVerify} sets the status of the verify flag under \dos. When
  802. \var{Verify} is \var{True}, then \dos checks data which are written to disk,
  803. by reading them after writing. If \var{Verify} is \var{False}, then data
  804. written to disk are not verified.
  805. \Errors
  806. Under \linux, Verify is always
  807. \var{True}.
  808. \SeeAlso
  809. \seep{SetVerify}
  810. \end{procedure}
  811. \begin{procedure}{SwapVectors}
  812. \Declaration
  813. Procedure SwapVectors ;
  814. \Description
  815. \var{SwapVectors} swaps the contents of the internal table of interrupt
  816. vectors with the current contents of the interrupt vectors.
  817. This is called typically in before and after an \var{Exec} call.
  818. \Errors
  819. Under \linux this call does nothing, as the interrupt vectors are
  820. managed by the kernel.
  821. \SeeAlso
  822. \seep{Exec}, \seep{SetIntVec}
  823. \end{procedure}
  824. \begin{procedure}{UnPackTime}
  825. \Declaration
  826. Procedure UnPackTime (p: longint; var T: datetime);
  827. \Description
  828. \var{UnPackTime} converts the file-modification time in \var{p}
  829. to a \var{DateTime} record. The file-modification time can be
  830. returned by \var{GetFTime}, \var{FindFirst} or \var{FindNext} calls.
  831. \Errors
  832. None.
  833. \SeeAlso
  834. \seep{GetFTime}, \seep{FindFirst}, \seep{FindNext}, \seep{PackTime}
  835. \end{procedure}
  836. For an example, see \seep{PackTime}.