FIO.LST 97 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * FIO.MOD - File input/output *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 (*%F _fdata *)
  13. 12 (*# call(seg_name => null) *)
  14. 13 (*# data(seg_name => null) *)
  15. 14 (*%E *)
  16. 15 (*# call(o_a_copy => off) *)
  17. 16 (*# check(stack=>off,index=>off,range=>off,overflow=>off,nil_ptr=>off) *)
  18. 17
  19. 18 IMPLEMENTATION MODULE FIO;
  20. 19
  21. 20 IMPORT CoreFile,CoreIO,CoreMain,CoreSig,Lib,Str,SYSTEM;
  22. 21 (*%T _OS2 *)
  23. 22 IMPORT Dos,Err;
  24. 23
  25. 24 FROM Dos IMPORT QCurDisk, FindFirst, FindNext;
  26. ***** ^ duplicate identifier
  27. 25 (*%E *)
  28. 26
  29. 27 (*%T _mthread *)
  30. 28 IMPORT Process, CoreProc;
  31. 29 (*%E *)
  32. 30 CONST
  33. 31 TrueStr = 'TRUE';
  34. ***** ^ not supported yet
  35. 32
  36. 33 VAR
  37. 34 (* CoreFile.BufInf : ARRAY[0..MaxHandle] OF FileInf; *) (* NB in CoreFile *)
  38. 35 (*%T _mthread *)
  39. 36 IOR: ARRAY [1..Process.MaxProcess] OF CARDINAL;
  40. ***** ^ not supported yet
  41. ***** ^ not supported yet
  42. ***** ^ not supported yet
  43. 37 OKTable: ARRAY [1..Process.MaxProcess] OF BOOLEAN;
  44. ***** ^ not supported yet
  45. ***** ^ not supported yet
  46. ***** ^ not supported yet
  47. 38 EOFTable: ARRAY [1..Process.MaxProcess] OF BOOLEAN;
  48. ***** ^ not supported yet
  49. ***** ^ not supported yet
  50. ***** ^ not supported yet
  51. 39 (*%E *)
  52. 40 (*%F _mthread *)
  53. 41 IOR: CARDINAL;
  54. 42 (*%E *)
  55. 43 TYPE
  56. 44 Str80 = ARRAY[0..79] OF CHAR;
  57. ***** ^ not supported yet
  58. ***** ^ not supported yet
  59. 45
  60. 46 (*%T _mthread *)
  61. 47 PROCEDURE SetIOR(Num: CARDINAL);
  62. 48
  63. 49 BEGIN
  64. 50 IOR[CoreProc._getTID()] := Num;
  65. ***** ^ not supported yet
  66. ***** ^ not supported yet
  67. ***** ^ not supported yet
  68. ***** ^ not supported yet
  69. 51 END SetIOR;
  70. ***** ^ not supported yet
  71. 52
  72. 53 PROCEDURE SetThreadOK( b : BOOLEAN);
  73. 54
  74. 55 BEGIN
  75. 56 OKTable[CoreProc._getTID()] := b;
  76. ***** ^ not supported yet
  77. ***** ^ not supported yet
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. 57 END SetThreadOK;
  81. ***** ^ not supported yet
  82. 58
  83. 59 PROCEDURE SetThreadEOF( b : BOOLEAN);
  84. 60
  85. 61 BEGIN
  86. 62 EOFTable[CoreProc._getTID()] := b;
  87. ***** ^ not supported yet
  88. ***** ^ not supported yet
  89. ***** ^ not supported yet
  90. ***** ^ not supported yet
  91. 63 END SetThreadEOF;
  92. ***** ^ not supported yet
  93. 64
  94. 65
  95. 66
  96. 67 (*%E *)
  97. 68
  98. 69
  99. 70
  100. 71 PROCEDURE ErrorCheck(Code: CARDINAL; ErrNum: CARDINAL; Msg, Name: ARRAY OF CHAR);
  101. ***** ^ not supported yet
  102. 72
  103. 73 VAR
  104. 74 ErrMsg: ARRAY [0..119] OF CHAR;
  105. ***** ^ not supported yet
  106. ***** ^ not supported yet
  107. 75 NumStr: ARRAY [0..19] OF CHAR;
  108. ***** ^ not supported yet
  109. ***** ^ not supported yet
  110. 76 OK: BOOLEAN;
  111. 77 BEGIN
  112. 78 IF ErrNum = 0 THEN
  113. 79 ErrNum := Lib.SysErrno();
  114. ***** ^ not supported yet
  115. ***** ^ not supported yet
  116. ***** ^ not supported yet
  117. 80 END;
  118. 81 IF IOcheck THEN
  119. ***** ^ undeclared identifier
  120. 82 Str.Copy(ErrMsg, Msg);
  121. ***** ^ not supported yet
  122. ***** ^ not supported yet
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. 83 Str.Append(ErrMsg, Name);
  126. ***** ^ not supported yet
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. 84 Str.Append(ErrMsg, '. Dos Error Code ');
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. ***** ^ not supported yet
  135. 85 Str.CardToStr(LONGCARD(ErrNum), NumStr, 10, OK);
  136. ***** ^ not supported yet
  137. ***** ^ not supported yet
  138. ***** ^ undeclared identifier
  139. ***** ^ not supported yet
  140. ***** ^ not supported yet
  141. ***** ^ not supported yet
  142. 86 Str.Append(ErrMsg, NumStr);
  143. ***** ^ not supported yet
  144. ***** ^ not supported yet
  145. ***** ^ not supported yet
  146. ***** ^ not supported yet
  147. 87 (* Lib.WrDosError(SHORTCARD(ErrNum)); *)
  148. 88 Lib.RunTimeError(CoreSig._FatalErrorPos(), Code+0A0H, ErrMsg);
  149. ***** ^ not supported yet
  150. ***** ^ not supported yet
  151. ***** ^ not supported yet
  152. ***** ^ not supported yet
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. 89 END;
  156. 90 (*%T _mthread *)
  157. 91 SetIOR(ErrNum);
  158. ***** ^ not supported yet
  159. ***** ^ not supported yet
  160. 92 (*%E *)
  161. 93 (*%F _mthread *)
  162. 94 IOR := ErrNum;
  163. 95 (*%E *)
  164. 96 END ErrorCheck;
  165. ***** ^ not supported yet
  166. 97
  167. 98 PROCEDURE IOresult () : CARDINAL;
  168. 99 BEGIN
  169. 100 (*%T _mthread *)
  170. 101 RETURN IOR[CoreProc._getTID()];
  171. ***** ^ not supported yet
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. ***** ^ not supported yet
  175. 102 (*%E *)
  176. 103 (*%F _mthread *)
  177. 104 RETURN IOR;
  178. 105 (*%E *)
  179. 106 END IOresult;
  180. ***** ^ not supported yet
  181. 107
  182. 108 (*%T _OS2 *)
  183. 109 (*%T _mthread *)
  184. 110 PROCEDURE StreamLock(F: FileInf);
  185. ***** ^ undeclared identifier
  186. 111
  187. 112 VAR
  188. 113 ThisThread: SHORTCARD;
  189. 114 BEGIN
  190. 115 ThisThread := SHORTCARD(CoreProc._getTID());
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. ***** ^ not supported yet
  194. 116 IF F^.Ctrl # ThisThread THEN
  195. ***** ^ not supported yet
  196. ***** ^ not supported yet
  197. 117 IF Dos.SemRequest(ADR(F^.Sem), -1) # 0 THEN ErrorCheck(18H, 0, 'StreamLock : ', Lib.NilStr) END;
  198. ***** ^ not supported yet
  199. ***** ^ not supported yet
  200. ***** ^ undeclared identifier
  201. ***** ^ not supported yet
  202. ***** ^ not supported yet
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. 118 F^.Ctrl := ThisThread;
  209. ***** ^ not supported yet
  210. ***** ^ not supported yet
  211. 119 END;
  212. 120 INC(F^.SCnt);
  213. ***** ^ undeclared identifier
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. 121 END StreamLock;
  217. ***** ^ not supported yet
  218. 122
  219. 123 PROCEDURE StreamUnlock(F: FileInf);
  220. ***** ^ undeclared identifier
  221. 124
  222. 125 BEGIN
  223. 126 DEC(F^.SCnt);
  224. ***** ^ undeclared identifier
  225. ***** ^ not supported yet
  226. ***** ^ not supported yet
  227. 127 IF F^.SCnt = 0 THEN
  228. ***** ^ not supported yet
  229. ***** ^ not supported yet
  230. 128 IF Dos.SemClear(ADR(F^.Sem)) # 0 THEN ErrorCheck(19H, 0, 'StreamUnlock : ', Lib.NilStr) END;
  231. ***** ^ not supported yet
  232. ***** ^ not supported yet
  233. ***** ^ undeclared identifier
  234. ***** ^ not supported yet
  235. ***** ^ not supported yet
  236. ***** ^ not supported yet
  237. ***** ^ not supported yet
  238. ***** ^ not supported yet
  239. ***** ^ not supported yet
  240. 129 F^.Ctrl := 0;
  241. ***** ^ not supported yet
  242. ***** ^ not supported yet
  243. 130 END;
  244. 131 END StreamUnlock;
  245. ***** ^ not supported yet
  246. 132
  247. 133 (*%E *)
  248. 134
  249. 135 (*%E *)
  250. 136
  251. 137 PROCEDURE FlsBuf(F: FileInf): INTEGER;
  252. ***** ^ undeclared identifier
  253. 138 VAR
  254. 139 Wnum : CARDINAL;
  255. 140 nr,sr : INTEGER;
  256. 141 Pos : LONGINT;
  257. 142 zbuf : ARRAY [0..127] OF CHAR;
  258. ***** ^ not supported yet
  259. ***** ^ not supported yet
  260. 143 BEGIN
  261. 144 WITH F^ DO
  262. ***** ^ not supported yet
  263. 145 IF (Flag = {}) OR ((Flag * (CoreIO._F_ERR + CoreIO._F_EOF + CoreIO._F_IN)) # {}) THEN
  264. ***** ^ undeclared identifier
  265. ***** ^ not supported yet
  266. ***** ^ undeclared identifier
  267. ***** ^ not supported yet
  268. ***** ^ not supported yet
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. ***** ^ not supported yet
  272. ***** ^ not supported yet
  273. ***** ^ not supported yet
  274. 146 RETURN -1;
  275. 147 END; (*IF*)
  276. 148 IF (Flag >= CoreIO._F_RST) THEN (* set up reset buffer for output *)
  277. ***** ^ undeclared identifier
  278. ***** ^ not supported yet
  279. ***** ^ not supported yet
  280. 149 Flag := Flag - CoreIO._F_RST;
  281. ***** ^ undeclared identifier
  282. ***** ^ undeclared identifier
  283. ***** ^ not supported yet
  284. ***** ^ not supported yet
  285. 150 Flag := Flag + CoreIO._F_OUT;
  286. ***** ^ undeclared identifier
  287. ***** ^ undeclared identifier
  288. ***** ^ not supported yet
  289. ***** ^ not supported yet
  290. 151 Cnt := Size;
  291. ***** ^ undeclared identifier
  292. ***** ^ undeclared identifier
  293. 152 Ptr := Base;
  294. ***** ^ undeclared identifier
  295. ***** ^ undeclared identifier
  296. 153 RETURN 1; (* return - buffer wasn't full *)
  297. 154 END; (*IF*)
  298. 155 IF Cnt < 0 THEN
  299. ***** ^ undeclared identifier
  300. 156 Cnt := 0;
  301. ***** ^ undeclared identifier
  302. 157 END; (*IF*)
  303. 158 Wnum := Size - Cnt;
  304. ***** ^ undeclared identifier
  305. ***** ^ undeclared identifier
  306. 159 IF Wnum = 0 THEN
  307. 160 RETURN 0;
  308. 161 END; (*IF*)
  309. 162 IF (Flag >= CoreIO._F_APP) THEN
  310. ***** ^ undeclared identifier
  311. ***** ^ not supported yet
  312. ***** ^ not supported yet
  313. 163 Pos := CoreIO.lseek(Handle,-128,CoreIO.SEEK_END); (* append *)
  314. ***** ^ not supported yet
  315. ***** ^ not supported yet
  316. ***** ^ undeclared identifier
  317. ***** ^ not supported yet
  318. ***** ^ not supported yet
  319. 164 IF Pos < 0 THEN
  320. 165 CoreIO.lseek(Handle,0,CoreIO.SEEK_SET);
  321. ***** ^ not supported yet
  322. ***** ^ not supported yet
  323. ***** ^ undeclared identifier
  324. ***** ^ not supported yet
  325. ***** ^ not supported yet
  326. 166 END; (*IF*)
  327. 167 nr := CoreIO._read(Handle,ADR(zbuf),128);
  328. ***** ^ not supported yet
  329. ***** ^ not supported yet
  330. ***** ^ undeclared identifier
  331. ***** ^ undeclared identifier
  332. ***** ^ not supported yet
  333. ***** ^ not supported yet
  334. 168 sr := nr;
  335. 169 IF nr = -1 THEN
  336. 170 RETURN -1;
  337. 171 END; (*IF*)
  338. 172 REPEAT
  339. 173 DEC(sr);
  340. ***** ^ undeclared identifier
  341. ***** ^ not supported yet
  342. 174 UNTIL (sr < 0) OR (zbuf[sr] # 26C);
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. 175 Pos := LONGINT(sr) - LONGINT(nr) + 1;
  346. ***** ^ not supported yet
  347. ***** ^ not supported yet
  348. 176 CoreIO.lseek(Handle,Pos,CoreIO.SEEK_END); (* append after first cltZ *)
  349. ***** ^ not supported yet
  350. ***** ^ not supported yet
  351. ***** ^ undeclared identifier
  352. ***** ^ not supported yet
  353. ***** ^ not supported yet
  354. 177 END; (*IF*)
  355. 178 IF CoreIO._write(Handle,Base,Wnum) # INTEGER(Wnum) THEN
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. ***** ^ undeclared identifier
  359. ***** ^ undeclared identifier
  360. ***** ^ not supported yet
  361. ***** ^ not supported yet
  362. 179 Flag := Flag + CoreIO._F_ERR;
  363. ***** ^ undeclared identifier
  364. ***** ^ undeclared identifier
  365. ***** ^ not supported yet
  366. ***** ^ not supported yet
  367. 180 Cnt := 0;
  368. ***** ^ undeclared identifier
  369. 181 RETURN -1;
  370. 182 END; (*IF*)
  371. 183 Cnt := Size; (* set buffer pointers *)
  372. ***** ^ undeclared identifier
  373. ***** ^ undeclared identifier
  374. 184 Ptr := Base;
  375. ***** ^ undeclared identifier
  376. ***** ^ undeclared identifier
  377. 185 Flag := Flag + CoreIO._F_OUT; (* set output flag *)
  378. ***** ^ undeclared identifier
  379. ***** ^ undeclared identifier
  380. ***** ^ not supported yet
  381. ***** ^ not supported yet
  382. 186 RETURN Wnum;
  383. 187 END; (*WITH*)
  384. ***** ^ not supported yet
  385. 188 END FlsBuf;
  386. ***** ^ not supported yet
  387. 189
  388. 190 PROCEDURE FilBuf(F: FileInf): INTEGER;
  389. ***** ^ undeclared identifier
  390. 191
  391. 192 VAR
  392. 193 NumRead: INTEGER;
  393. 194 BEGIN
  394. 195 WITH F^ DO
  395. ***** ^ not supported yet
  396. 196 IF (Flag = {}) OR ((Flag * (CoreIO._F_ERR + CoreIO._F_OUT)) # {}) THEN
  397. ***** ^ undeclared identifier
  398. ***** ^ not supported yet
  399. ***** ^ undeclared identifier
  400. ***** ^ not supported yet
  401. ***** ^ not supported yet
  402. ***** ^ not supported yet
  403. ***** ^ not supported yet
  404. ***** ^ not supported yet
  405. 197 RETURN -1;
  406. 198 END;
  407. 199 IF (Flag >= CoreIO._F_EOF) THEN
  408. ***** ^ undeclared identifier
  409. ***** ^ not supported yet
  410. ***** ^ not supported yet
  411. 200 RETURN 0;
  412. 201 END;
  413. 202 IF (Flag >= CoreIO._F_RST) THEN
  414. ***** ^ undeclared identifier
  415. ***** ^ not supported yet
  416. ***** ^ not supported yet
  417. 203 Flag := Flag - CoreIO._F_RST;
  418. ***** ^ undeclared identifier
  419. ***** ^ undeclared identifier
  420. ***** ^ not supported yet
  421. ***** ^ not supported yet
  422. 204 END;
  423. 205 NumRead := CoreIO._read(Handle, Base, Size);
  424. ***** ^ not supported yet
  425. ***** ^ not supported yet
  426. ***** ^ undeclared identifier
  427. ***** ^ undeclared identifier
  428. ***** ^ undeclared identifier
  429. 206 Ptr := Base;
  430. ***** ^ undeclared identifier
  431. ***** ^ undeclared identifier
  432. 207 IF (NumRead = -1) AND (NumRead # Size) THEN
  433. ***** ^ undeclared identifier
  434. 208 Flag := Flag + CoreIO._F_ERR;
  435. ***** ^ undeclared identifier
  436. ***** ^ undeclared identifier
  437. ***** ^ not supported yet
  438. ***** ^ not supported yet
  439. 209 Cnt := 0;
  440. ***** ^ undeclared identifier
  441. 210 RETURN -1;
  442. 211 END;
  443. 212 Cnt := NumRead; (* reset pointers *)
  444. ***** ^ undeclared identifier
  445. 213 Flag := Flag + CoreIO._F_IN; (* set input flag *)
  446. ***** ^ undeclared identifier
  447. ***** ^ undeclared identifier
  448. ***** ^ not supported yet
  449. ***** ^ not supported yet
  450. 214 IF NumRead = 0 THEN
  451. 215 Flag := Flag + CoreIO._F_EOF; (* end of file *)
  452. ***** ^ undeclared identifier
  453. ***** ^ undeclared identifier
  454. ***** ^ not supported yet
  455. ***** ^ not supported yet
  456. 216 (*%T _mthread *)
  457. 217 SetThreadEOF(TRUE);
  458. ***** ^ not supported yet
  459. ***** ^ not supported yet
  460. 218 (*%E *)
  461. 219 EOF := TRUE;
  462. ***** ^ undeclared identifier
  463. 220 RETURN 0;
  464. 221 END;
  465. 222 RETURN NumRead;
  466. 223 END;
  467. ***** ^ not supported yet
  468. 224 END FilBuf;
  469. ***** ^ not supported yet
  470. 225
  471. 226 PROCEDURE WrBin(F:File;Buf:ARRAY OF BYTE;Count:CARDINAL);
  472. ***** ^ undeclared identifier
  473. ***** ^ undeclared identifier
  474. 227 VAR
  475. 228 NumWrit : INTEGER;
  476. 229 NumToWrite : INTEGER;
  477. 230 NumLeft : CARDINAL;
  478. 231 ST : POINTER TO CoreFile.CStream;
  479. ***** ^ not supported yet
  480. 232 Buffer : CoreFile.StreamPtr;
  481. ***** ^ not supported yet
  482. 233 BEGIN
  483. 234 (*%T _mthread *)
  484. 235 SetIOR(0);
  485. ***** ^ not supported yet
  486. ***** ^ not supported yet
  487. 236 SetThreadOK(TRUE);
  488. ***** ^ not supported yet
  489. ***** ^ not supported yet
  490. 237 (*%E *)
  491. 238 (*%F _mthread *)
  492. 239 IOR := 0;
  493. 240 (*%E *)
  494. 241 OK := TRUE;
  495. ***** ^ undeclared identifier
  496. 242 NumWrit := 0;
  497. 243 IF Count # 0 THEN
  498. 244 IF (F <= CoreFile._open_max) & (CoreFile.BufInf[F] # NIL) THEN
  499. ***** ^ not supported yet
  500. ***** ^ not supported yet
  501. ***** ^ not supported yet
  502. ***** ^ not supported yet
  503. ***** ^ not supported yet
  504. ***** ^ not supported yet
  505. 245 WITH CoreFile.BufInf[F]^ DO
  506. ***** ^ not supported yet
  507. ***** ^ not supported yet
  508. ***** ^ not supported yet
  509. 246 IF (Flag = {}) OR ((Flag * (CoreIO._F_ERR + CoreIO._F_EOF)) # {}) THEN
  510. ***** ^ undeclared identifier
  511. ***** ^ not supported yet
  512. ***** ^ undeclared identifier
  513. ***** ^ not supported yet
  514. ***** ^ not supported yet
  515. ***** ^ not supported yet
  516. ***** ^ not supported yet
  517. ***** ^ not supported yet
  518. 247 ErrorCheck(6, CoreIO.EBADF, 'WrBin : ', Lib.NilStr);
  519. ***** ^ not supported yet
  520. ***** ^ not supported yet
  521. ***** ^ not supported yet
  522. ***** ^ not supported yet
  523. ***** ^ not supported yet
  524. ***** ^ not supported yet
  525. 248 (*%T _mthread *)
  526. 249 SetThreadOK(FALSE);
  527. ***** ^ not supported yet
  528. ***** ^ not supported yet
  529. 250 (*%E *)
  530. 251 OK := FALSE;
  531. ***** ^ undeclared identifier
  532. 252 RETURN;
  533. 253 END; (*IF*)
  534. 254 IF ((Flag * CoreIO._F_WRIT) = {}) OR (Flag >= CoreIO._F_IN) THEN
  535. ***** ^ undeclared identifier
  536. ***** ^ not supported yet
  537. ***** ^ not supported yet
  538. ***** ^ not supported yet
  539. ***** ^ undeclared identifier
  540. ***** ^ not supported yet
  541. ***** ^ not supported yet
  542. 255 Flag := Flag + CoreIO._F_ERR;
  543. ***** ^ undeclared identifier
  544. ***** ^ undeclared identifier
  545. ***** ^ not supported yet
  546. ***** ^ not supported yet
  547. 256 ErrorCheck(6, CoreIO.EACCES, 'WrBin : ', Lib.NilStr);
  548. ***** ^ not supported yet
  549. ***** ^ not supported yet
  550. ***** ^ not supported yet
  551. ***** ^ not supported yet
  552. ***** ^ not supported yet
  553. ***** ^ not supported yet
  554. 257 (*%T _mthread *)
  555. 258 SetThreadOK(FALSE);
  556. ***** ^ not supported yet
  557. ***** ^ not supported yet
  558. 259 (*%E *)
  559. 260 OK := FALSE;
  560. ***** ^ undeclared identifier
  561. 261 RETURN;
  562. 262 END;
  563. 263 (*%T _mthread *)
  564. 264 (*%F _OS2 *)
  565. 265 Process.Lock();
  566. 266 (*%E *)
  567. 267 (*%T _OS2 *)
  568. 268 StreamLock(CoreFile.BufInf[F]);
  569. ***** ^ not supported yet
  570. ***** ^ not supported yet
  571. ***** ^ not supported yet
  572. ***** ^ not supported yet
  573. 269 (*%E *)
  574. 270 (*%E *)
  575. 271 Flag := Flag + CoreIO._F_OUT;
  576. ***** ^ undeclared identifier
  577. ***** ^ undeclared identifier
  578. ***** ^ not supported yet
  579. ***** ^ not supported yet
  580. 272 IF Flag * CoreIO._F_RST # {} THEN
  581. ***** ^ undeclared identifier
  582. ***** ^ not supported yet
  583. ***** ^ not supported yet
  584. ***** ^ not supported yet
  585. 273 IF FlsBuf(CoreFile.BufInf[F]) <= 0 THEN
  586. ***** ^ not supported yet
  587. ***** ^ not supported yet
  588. ***** ^ not supported yet
  589. ***** ^ not supported yet
  590. 274 ErrorCheck(6, 0, 'WrBin : ', Lib.NilStr);
  591. ***** ^ not supported yet
  592. ***** ^ not supported yet
  593. ***** ^ not supported yet
  594. ***** ^ not supported yet
  595. 275 (*%T _mthread *)
  596. 276 SetThreadOK(FALSE);
  597. ***** ^ not supported yet
  598. ***** ^ not supported yet
  599. 277 (*%E *)
  600. 278 OK := FALSE;
  601. ***** ^ undeclared identifier
  602. 279 (*%T _mthread *)
  603. 280 (*%F _OS2 *)
  604. 281 Process.Unlock();
  605. 282 (*%E *)
  606. 283 (*%T _OS2 *)
  607. 284 StreamUnlock(CoreFile.BufInf[F]);
  608. ***** ^ not supported yet
  609. ***** ^ not supported yet
  610. ***** ^ not supported yet
  611. ***** ^ not supported yet
  612. 285 (*%E *)
  613. 286 (*%E *)
  614. 287 RETURN;
  615. 288 END; (*IF*)
  616. 289 END; (*IF*)
  617. 290 NumLeft := Count;
  618. 291 Buffer := CoreFile.StreamPtr(ADR(Buf));
  619. ***** ^ not supported yet
  620. ***** ^ not supported yet
  621. ***** ^ not supported yet
  622. ***** ^ undeclared identifier
  623. ***** ^ not supported yet
  624. 292 LOOP
  625. 293 IF(CARDINAL(Cnt) >= NumLeft) THEN (* write entire item *)
  626. ***** ^ undeclared identifier
  627. 294 NumToWrite := INTEGER(NumLeft);
  628. ***** ^ not supported yet
  629. 295 ELSE
  630. 296 NumToWrite := Cnt; (* write entire buffer *)
  631. ***** ^ undeclared identifier
  632. 297 END; (*IF*)
  633. 298 IF NumToWrite > 0 THEN
  634. 299 Lib.Move(Buffer,Ptr,NumToWrite);
  635. ***** ^ not supported yet
  636. ***** ^ not supported yet
  637. ***** ^ not supported yet
  638. ***** ^ undeclared identifier
  639. ***** ^ not supported yet
  640. 300 DEC(Cnt,NumToWrite);
  641. ***** ^ undeclared identifier
  642. ***** ^ undeclared identifier
  643. ***** ^ not supported yet
  644. 301 INC(CARDINAL(Buffer),NumToWrite);
  645. ***** ^ undeclared identifier
  646. ***** ^ not supported yet
  647. ***** ^ not supported yet
  648. 302 INC(CARDINAL(Ptr),NumToWrite);
  649. ***** ^ undeclared identifier
  650. ***** ^ undeclared identifier
  651. ***** ^ not supported yet
  652. 303 DEC(NumLeft,CARDINAL(NumToWrite));
  653. ***** ^ undeclared identifier
  654. ***** ^ not supported yet
  655. 304 INC(NumWrit,NumToWrite);
  656. ***** ^ undeclared identifier
  657. ***** ^ not supported yet
  658. 305 END; (*IF*)
  659. 306 IF (Cnt = 0) & (FlsBuf(CoreFile.BufInf[F]) <= 0) THEN (* flush full buffer *)
  660. ***** ^ undeclared identifier
  661. ***** ^ not supported yet
  662. ***** ^ not supported yet
  663. ***** ^ not supported yet
  664. ***** ^ not supported yet
  665. 307 EXIT; (* error or EOF *)
  666. 308 END; (*IF*)
  667. 309 IF NumLeft = 0 THEN
  668. 310 EXIT;
  669. 311 END; (*IF*)
  670. 312 END; (*LOOP*)
  671. 313 IF (Flag >= CoreIO._F_LBUF) & (FlsBuf(CoreFile.BufInf[F]) < 0) THEN
  672. ***** ^ undeclared identifier
  673. ***** ^ not supported yet
  674. ***** ^ not supported yet
  675. ***** ^ not supported yet
  676. ***** ^ not supported yet
  677. ***** ^ not supported yet
  678. ***** ^ not supported yet
  679. 314 ErrorCheck(6, 0, 'WrBin : ', Lib.NilStr);
  680. ***** ^ not supported yet
  681. ***** ^ not supported yet
  682. ***** ^ not supported yet
  683. ***** ^ not supported yet
  684. 315 (*%T _mthread *)
  685. 316 SetThreadOK(FALSE);
  686. ***** ^ not supported yet
  687. ***** ^ not supported yet
  688. 317 (*%E *)
  689. 318 OK := FALSE;
  690. ***** ^ undeclared identifier
  691. 319 END; (*IF*)
  692. 320 END; (*WITH*)
  693. ***** ^ not supported yet
  694. 321 (*%T _mthread *)
  695. 322 (*%F _OS2 *)
  696. 323 Process.Unlock();
  697. 324 (*%E *)
  698. 325 (*%T _OS2 *)
  699. 326 StreamUnlock(CoreFile.BufInf[F]);
  700. ***** ^ not supported yet
  701. ***** ^ not supported yet
  702. ***** ^ not supported yet
  703. ***** ^ undeclared identifier
  704. 327 (*%E *)
  705. 328 (*%E *)
  706. 329 ELSE
  707. 330 (*%T _mthread *)
  708. 331 (*%F _OS2 *)
  709. 332 Process.Lock();
  710. 333 (*%E *)
  711. 334 (*%E *)
  712. 335 IF CoreFile._openfd[F] >= CoreIO.O_APPEND THEN
  713. ***** ^ not supported yet
  714. ***** ^ not supported yet
  715. ***** ^ undeclared identifier
  716. ***** ^ not supported yet
  717. ***** ^ not supported yet
  718. 336 CoreIO.lseek(F, 0, CoreIO.SEEK_END);
  719. ***** ^ not supported yet
  720. ***** ^ not supported yet
  721. ***** ^ undeclared identifier
  722. ***** ^ not supported yet
  723. ***** ^ not supported yet
  724. 337 END; (*IF*)
  725. 338 NumWrit := CoreIO._write(F,CoreFile.StreamPtr(ADR(Buf)),Count);
  726. ***** ^ undeclared identifier
  727. ***** ^ not supported yet
  728. ***** ^ not supported yet
  729. ***** ^ undeclared identifier
  730. ***** ^ not supported yet
  731. ***** ^ not supported yet
  732. ***** ^ undeclared identifier
  733. ***** ^ undeclared identifier
  734. ***** ^ undeclared identifier
  735. 339 (*%T _mthread *)
  736. 340 (*%F _OS2 *)
  737. 341 Process.Unlock();
  738. 342 (*%E *)
  739. 343 (*%E *)
  740. 344 END; (*IF*)
  741. 345 IF CARDINAL(NumWrit) # Count THEN
  742. ***** ^ undeclared identifier
  743. ***** ^ undeclared identifier
  744. 346 ErrorCheck(6, CoreIO.EDISKFUL, 'WrBin : ', Lib.NilStr);
  745. ***** ^ not supported yet
  746. ***** ^ not supported yet
  747. ***** ^ not supported yet
  748. ***** ^ not supported yet
  749. ***** ^ not supported yet
  750. ***** ^ not supported yet
  751. 347 OK := FALSE;
  752. ***** ^ undeclared identifier
  753. 348 (*%T _mthread *)
  754. 349 SetThreadOK(FALSE);
  755. ***** ^ not supported yet
  756. ***** ^ not supported yet
  757. 350 (*%E *)
  758. 351 END; (*IF*)
  759. 352 END; (*IF*)
  760. 353 END WrBin;
  761. ***** ^ not supported yet
  762. 354
  763. 355 PROCEDURE Flush(F: File);
  764. ***** ^ undeclared identifier
  765. 356
  766. 357 VAR
  767. 358 ret: INTEGER;
  768. 359 BEGIN
  769. 360 (*%T _mthread *)
  770. 361 SetIOR(0);
  771. ***** ^ not supported yet
  772. ***** ^ not supported yet
  773. 362 (*%E *)
  774. 363 (*%F _mthread *)
  775. 364 IOR := 0;
  776. 365 (*%E *)
  777. 366 IF (F > CoreFile._open_max) OR (CoreFile.BufInf[F] = NIL) THEN RETURN END;
  778. ***** ^ not supported yet
  779. ***** ^ not supported yet
  780. ***** ^ not supported yet
  781. ***** ^ not supported yet
  782. ***** ^ not supported yet
  783. ***** ^ not supported yet
  784. 367 WITH CoreFile.BufInf[F]^ DO
  785. ***** ^ not supported yet
  786. ***** ^ not supported yet
  787. ***** ^ not supported yet
  788. 368 IF (Flag = {}) OR ((Flag * (CoreIO._F_ERR + CoreIO._F_EOF)) # {}) THEN
  789. ***** ^ undeclared identifier
  790. ***** ^ not supported yet
  791. ***** ^ undeclared identifier
  792. ***** ^ not supported yet
  793. ***** ^ not supported yet
  794. ***** ^ not supported yet
  795. ***** ^ not supported yet
  796. ***** ^ not supported yet
  797. 369 RETURN;
  798. 370 END;
  799. 371 (*%T _mthread *)
  800. 372 (*%F _OS2 *)
  801. 373 Process.Lock();
  802. 374 (*%E *)
  803. 375 (*%T _OS2 *)
  804. 376 StreamLock(CoreFile.BufInf[F]);
  805. ***** ^ not supported yet
  806. ***** ^ not supported yet
  807. ***** ^ not supported yet
  808. ***** ^ not supported yet
  809. 377 (*%E *)
  810. 378 (*%E *)
  811. 379 IF (Flag >= CoreIO._F_OUT) THEN
  812. ***** ^ undeclared identifier
  813. ***** ^ not supported yet
  814. ***** ^ not supported yet
  815. 380 ret :=FlsBuf(CoreFile.BufInf[F]); (* flush output buffer *)
  816. ***** ^ not supported yet
  817. ***** ^ not supported yet
  818. ***** ^ not supported yet
  819. ***** ^ not supported yet
  820. 381 IF ret < 0 THEN
  821. 382 ErrorCheck(8, 0, 'Flush : ', Lib.NilStr);
  822. ***** ^ not supported yet
  823. ***** ^ not supported yet
  824. ***** ^ not supported yet
  825. ***** ^ not supported yet
  826. 383 END;
  827. 384 ELSIF (Flag * CoreIO._F_DEV = {}) THEN
  828. ***** ^ undeclared identifier
  829. ***** ^ not supported yet
  830. ***** ^ not supported yet
  831. ***** ^ not supported yet
  832. 385 Seek(F, GetPos(F));
  833. ***** ^ undeclared identifier
  834. ***** ^ not supported yet
  835. ***** ^ undeclared identifier
  836. ***** ^ not supported yet
  837. 386 END;
  838. 387 WITH CoreFile.BufInf[F]^ DO
  839. ***** ^ not supported yet
  840. ***** ^ not supported yet
  841. ***** ^ not supported yet
  842. 388 Pback := 0; (* reset buffer *)
  843. ***** ^ undeclared identifier
  844. 389 Cnt := 0;
  845. ***** ^ undeclared identifier
  846. 390 Flag := Flag + CoreIO._F_RST;
  847. ***** ^ undeclared identifier
  848. ***** ^ undeclared identifier
  849. ***** ^ not supported yet
  850. ***** ^ not supported yet
  851. 391 Flag := Flag - (CoreIO._F_OUT + CoreIO._F_IN);
  852. ***** ^ undeclared identifier
  853. ***** ^ undeclared identifier
  854. ***** ^ not supported yet
  855. ***** ^ not supported yet
  856. ***** ^ not supported yet
  857. ***** ^ not supported yet
  858. 392 END;
  859. ***** ^ not supported yet
  860. 393 (*%T _mthread *)
  861. 394 (*%F _OS2 *)
  862. 395 Process.Unlock();
  863. 396 (*%E *)
  864. 397 (*%T _OS2 *)
  865. 398 StreamUnlock(CoreFile.BufInf[F]);
  866. ***** ^ not supported yet
  867. ***** ^ not supported yet
  868. ***** ^ not supported yet
  869. ***** ^ undeclared identifier
  870. 399 (*%E *)
  871. 400 (*%E *)
  872. 401 END;
  873. ***** ^ not supported yet
  874. 402 RETURN;
  875. 403 END Flush;
  876. ***** ^ not supported yet
  877. 404
  878. 405 (*%F _OS2 *)
  879. 406 PROCEDURE Truncate(F: File);
  880. 407
  881. 408 BEGIN
  882. 409 (*%T _mthread *)
  883. 410 SetIOR(0);
  884. 411 (*%E *)
  885. 412 (*%F _mthread *)
  886. 413 IOR := 0;
  887. 414 (*%E *)
  888. 415 (*%T _mthread *)
  889. 416 Process.Lock();
  890. 417 (*%E *)
  891. 418 Flush( F );
  892. 419 IF CoreIO._write(F, NIL, 0) = -1 THEN
  893. 420 ErrorCheck(0CH, 0, 'Truncate : ', Lib.NilStr);
  894. 421 END;
  895. 422 (*%T _mthread *)
  896. 423 Process.Unlock();
  897. 424 (*%E *)
  898. 425 END Truncate;
  899. 426 (*%E *)
  900. 427
  901. 428 (*%T _OS2 *)
  902. 429 PROCEDURE Truncate(F: File);
  903. ***** ^ undeclared identifier
  904. 430 VAR IOR, r : CARDINAL; l : LONGCARD;
  905. ***** ^ undeclared identifier
  906. 431 BEGIN
  907. 432 Flush(F);
  908. ***** ^ not supported yet
  909. ***** ^ not supported yet
  910. 433 IOR := Dos.ChgFilePtr(F,0,1,l);
  911. ***** ^ not supported yet
  912. ***** ^ not supported yet
  913. ***** ^ not supported yet
  914. ***** ^ not supported yet
  915. 434 IF IOR = 0 THEN IOR := Dos.NewSize(F,l) END;
  916. ***** ^ not supported yet
  917. ***** ^ not supported yet
  918. ***** ^ not supported yet
  919. ***** ^ not supported yet
  920. 435 IF IOR # 0 THEN ErrorCheck(0CH, IOR, 'Truncate : ', Lib.NilStr) END;
  921. ***** ^ not supported yet
  922. ***** ^ not supported yet
  923. ***** ^ not supported yet
  924. ***** ^ not supported yet
  925. 436 END Truncate;
  926. ***** ^ not supported yet
  927. 437 (*%E *)
  928. 438
  929. 439
  930. 440 PROCEDURE RdBin(F: File; VAR Buf: ARRAY OF BYTE; Count: CARDINAL) : CARDINAL;
  931. ***** ^ undeclared identifier
  932. ***** ^ undeclared identifier
  933. 441 VAR
  934. 442 NumRead : CARDINAL;
  935. 443 NumToRead : CARDINAL;
  936. 444 NumLeft : LONGCARD;
  937. ***** ^ undeclared identifier
  938. 445 Buffer : CoreFile.StreamPtr;
  939. ***** ^ not supported yet
  940. 446 Res : INTEGER;
  941. 447 BEGIN
  942. 448 (*%T _mthread *)
  943. 449 SetIOR(0);
  944. ***** ^ not supported yet
  945. ***** ^ not supported yet
  946. 450 (*%E *)
  947. 451 (*%F _mthread *)
  948. 452 IOR := 0;
  949. 453 (*%E *)
  950. 454 OK := TRUE;
  951. ***** ^ undeclared identifier
  952. 455 (*%T _mthread *)
  953. 456 SetThreadOK(TRUE);
  954. ***** ^ not supported yet
  955. ***** ^ not supported yet
  956. 457 SetThreadEOF(FALSE);
  957. ***** ^ not supported yet
  958. ***** ^ not supported yet
  959. 458 (*%E *)
  960. 459 EOF := FALSE;
  961. ***** ^ undeclared identifier
  962. 460 Res := 0;
  963. 461 NumRead := 0;
  964. 462 IF Count = 0 THEN RETURN 0 END;
  965. 463 IF (F <= CoreFile._open_max) AND (CoreFile.BufInf[F] # NIL) THEN
  966. ***** ^ not supported yet
  967. ***** ^ not supported yet
  968. ***** ^ not supported yet
  969. ***** ^ not supported yet
  970. ***** ^ not supported yet
  971. ***** ^ not supported yet
  972. 464 WITH CoreFile.BufInf[F]^ DO
  973. ***** ^ not supported yet
  974. ***** ^ not supported yet
  975. ***** ^ not supported yet
  976. 465 IF (Flag = {}) OR ((Flag * (CoreIO._F_ERR + CoreIO._F_EOF)) # {}) THEN
  977. ***** ^ undeclared identifier
  978. ***** ^ not supported yet
  979. ***** ^ undeclared identifier
  980. ***** ^ not supported yet
  981. ***** ^ not supported yet
  982. ***** ^ not supported yet
  983. ***** ^ not supported yet
  984. ***** ^ not supported yet
  985. 466 ErrorCheck(7, CoreIO.EBADF, 'RdBin : ', Lib.NilStr);
  986. ***** ^ not supported yet
  987. ***** ^ not supported yet
  988. ***** ^ not supported yet
  989. ***** ^ not supported yet
  990. ***** ^ not supported yet
  991. ***** ^ not supported yet
  992. 467 OK := FALSE;
  993. ***** ^ undeclared identifier
  994. 468 (*%T _mthread *)
  995. 469 SetThreadOK(FALSE);
  996. ***** ^ not supported yet
  997. ***** ^ not supported yet
  998. 470 (*%E *)
  999. 471 RETURN MAX(CARDINAL);
  1000. ***** ^ undeclared identifier
  1001. ***** ^ not supported yet
  1002. 472 END;
  1003. 473 IF (Flag >= CoreIO._F_OUT) OR ((Flag * CoreIO._F_READ) = {} ) THEN
  1004. ***** ^ undeclared identifier
  1005. ***** ^ not supported yet
  1006. ***** ^ not supported yet
  1007. ***** ^ undeclared identifier
  1008. ***** ^ not supported yet
  1009. ***** ^ not supported yet
  1010. ***** ^ not supported yet
  1011. 474 Flag := Flag + CoreIO._F_ERR;
  1012. ***** ^ undeclared identifier
  1013. ***** ^ undeclared identifier
  1014. ***** ^ not supported yet
  1015. ***** ^ not supported yet
  1016. 475 ErrorCheck(7, CoreIO.EACCES, 'RdBin : ', Lib.NilStr);
  1017. ***** ^ not supported yet
  1018. ***** ^ not supported yet
  1019. ***** ^ not supported yet
  1020. ***** ^ not supported yet
  1021. ***** ^ not supported yet
  1022. ***** ^ not supported yet
  1023. 476 OK := FALSE;
  1024. ***** ^ undeclared identifier
  1025. 477 (*%T _mthread *)
  1026. 478 SetThreadOK(FALSE);
  1027. ***** ^ not supported yet
  1028. ***** ^ not supported yet
  1029. 479 (*%E *)
  1030. 480 RETURN MAX(CARDINAL);
  1031. ***** ^ undeclared identifier
  1032. ***** ^ not supported yet
  1033. 481 END;
  1034. 482 (*%T _mthread *)
  1035. 483 (*%F _OS2 *)
  1036. 484 Process.Lock();
  1037. 485 (*%E *)
  1038. 486 (*%T _OS2 *)
  1039. 487 StreamLock(CoreFile.BufInf[F]);
  1040. ***** ^ not supported yet
  1041. ***** ^ not supported yet
  1042. ***** ^ not supported yet
  1043. ***** ^ not supported yet
  1044. 488 (*%E *)
  1045. 489 (*%E *)
  1046. 490 Flag := Flag + CoreIO._F_IN;
  1047. ***** ^ undeclared identifier
  1048. ***** ^ undeclared identifier
  1049. ***** ^ not supported yet
  1050. ***** ^ not supported yet
  1051. 491 NumLeft := LONGCARD(Count);
  1052. ***** ^ not supported yet
  1053. ***** ^ undeclared identifier
  1054. ***** ^ not supported yet
  1055. 492 NumRead := 0;
  1056. 493 Buffer := CoreFile.StreamPtr(ADR(Buf));
  1057. ***** ^ not supported yet
  1058. ***** ^ not supported yet
  1059. ***** ^ not supported yet
  1060. ***** ^ undeclared identifier
  1061. ***** ^ not supported yet
  1062. 494 LOOP
  1063. 495 IF Cnt = 0 THEN (* fill empty buffer *)
  1064. ***** ^ undeclared identifier
  1065. 496 Res := FilBuf(CoreFile.BufInf[F]);
  1066. ***** ^ not supported yet
  1067. ***** ^ not supported yet
  1068. ***** ^ not supported yet
  1069. ***** ^ not supported yet
  1070. 497 IF (INTEGER(Res) = -1)OR(Res = 0) THEN
  1071. ***** ^ not supported yet
  1072. 498 EXIT; (* error or EOF *)
  1073. 499 END;
  1074. 500 END;
  1075. 501 IF(LONGCARD(Cnt) >= NumLeft) THEN (* read entire item *)
  1076. ***** ^ undeclared identifier
  1077. ***** ^ undeclared identifier
  1078. ***** ^ not supported yet
  1079. 502 NumToRead := CARDINAL(NumLeft);
  1080. ***** ^ not supported yet
  1081. 503 ELSE
  1082. 504 NumToRead := Cnt; (* read entire buffer *)
  1083. ***** ^ undeclared identifier
  1084. 505 END;
  1085. 506 Lib.Move(Ptr, Buffer, NumToRead);
  1086. ***** ^ not supported yet
  1087. ***** ^ not supported yet
  1088. ***** ^ undeclared identifier
  1089. ***** ^ not supported yet
  1090. ***** ^ not supported yet
  1091. 507 DEC(Cnt,NumToRead);
  1092. ***** ^ undeclared identifier
  1093. ***** ^ undeclared identifier
  1094. ***** ^ not supported yet
  1095. 508 INC(CARDINAL(Buffer), NumToRead);
  1096. ***** ^ undeclared identifier
  1097. ***** ^ not supported yet
  1098. ***** ^ not supported yet
  1099. 509 INC(CARDINAL(Ptr), NumToRead);
  1100. ***** ^ undeclared identifier
  1101. ***** ^ undeclared identifier
  1102. ***** ^ not supported yet
  1103. 510 NumLeft := NumLeft - LONGCARD(NumToRead);
  1104. ***** ^ not supported yet
  1105. ***** ^ not supported yet
  1106. ***** ^ undeclared identifier
  1107. ***** ^ not supported yet
  1108. 511 INC(NumRead, NumToRead);
  1109. ***** ^ undeclared identifier
  1110. ***** ^ not supported yet
  1111. 512 IF NumLeft = 0 THEN EXIT END;
  1112. ***** ^ not supported yet
  1113. 513 END;
  1114. 514 END;
  1115. ***** ^ not supported yet
  1116. 515 (*%T _mthread *)
  1117. 516 (*%F _OS2 *)
  1118. 517 Process.Unlock();
  1119. 518 (*%E *)
  1120. 519 (*%T _OS2 *)
  1121. 520 StreamUnlock(CoreFile.BufInf[F]);
  1122. ***** ^ not supported yet
  1123. ***** ^ not supported yet
  1124. ***** ^ not supported yet
  1125. ***** ^ undeclared identifier
  1126. 521 (*%E *)
  1127. 522 (*%E *)
  1128. 523 ELSE
  1129. 524 (*%T _mthread *)
  1130. 525 (*%F _OS2 *)
  1131. 526 Process.Lock();
  1132. 527 (*%E *)
  1133. 528 (*%E *)
  1134. 529 NumRead := CoreIO._read(F, CoreFile.StreamPtr(ADR(Buf)), Count);
  1135. ***** ^ undeclared identifier
  1136. ***** ^ not supported yet
  1137. ***** ^ not supported yet
  1138. ***** ^ undeclared identifier
  1139. ***** ^ not supported yet
  1140. ***** ^ not supported yet
  1141. ***** ^ undeclared identifier
  1142. ***** ^ undeclared identifier
  1143. ***** ^ undeclared identifier
  1144. 530 IF NumRead=MAX(CARDINAL) THEN Res := -1 END;
  1145. ***** ^ undeclared identifier
  1146. ***** ^ undeclared identifier
  1147. ***** ^ not supported yet
  1148. ***** ^ undeclared identifier
  1149. 531 (*%T _mthread *)
  1150. 532 (*%F _OS2 *)
  1151. 533 Process.Unlock();
  1152. 534 (*%E *)
  1153. 535 (*%E *)
  1154. 536 END;
  1155. 537 IF NumRead # Count THEN
  1156. ***** ^ undeclared identifier
  1157. ***** ^ undeclared identifier
  1158. 538 (*%T _mthread *)
  1159. 539 SetThreadOK(FALSE);
  1160. ***** ^ not supported yet
  1161. ***** ^ not supported yet
  1162. 540 (*%E *)
  1163. 541 OK := FALSE;
  1164. ***** ^ undeclared identifier
  1165. 542 IF Res = -1 THEN
  1166. ***** ^ undeclared identifier
  1167. 543 ErrorCheck(7, 0, 'RbBin : ', Lib.NilStr);
  1168. ***** ^ not supported yet
  1169. ***** ^ not supported yet
  1170. ***** ^ not supported yet
  1171. ***** ^ not supported yet
  1172. 544 NumRead := 0;
  1173. ***** ^ undeclared identifier
  1174. 545 ELSE
  1175. 546 (*%T _mthread *)
  1176. 547 SetThreadEOF(TRUE);
  1177. ***** ^ not supported yet
  1178. ***** ^ not supported yet
  1179. 548 (*%E *)
  1180. 549 EOF := TRUE;
  1181. ***** ^ undeclared identifier
  1182. 550 END;
  1183. 551 END;
  1184. 552 RETURN NumRead;
  1185. ***** ^ undeclared identifier
  1186. 553 END RdBin;
  1187. ***** ^ not supported yet
  1188. 554
  1189. 555
  1190. 556 PROCEDURE WrStr(F: File; Buf: ARRAY OF CHAR);
  1191. ***** ^ undeclared identifier
  1192. ***** ^ not supported yet
  1193. 557 BEGIN
  1194. 558 WrBin( F,Buf,Str.Length( Buf ) );
  1195. ***** ^ not supported yet
  1196. ***** ^ not supported yet
  1197. ***** ^ not supported yet
  1198. ***** ^ not supported yet
  1199. ***** ^ not supported yet
  1200. ***** ^ not supported yet
  1201. 559 END WrStr;
  1202. ***** ^ not supported yet
  1203. 560
  1204. 561 PROCEDURE WrLn(F: File);
  1205. ***** ^ undeclared identifier
  1206. 562 TYPE a = ARRAY [ 0..1 ] OF CHAR;
  1207. ***** ^ not supported yet
  1208. ***** ^ not supported yet
  1209. 563 BEGIN
  1210. 564 WrBin( F, a( CHR( 13 ),CHR( 10 ) ), 2 )
  1211. ***** ^ not supported yet
  1212. ***** ^ not supported yet
  1213. ***** ^ undeclared identifier
  1214. ***** ^ not supported yet
  1215. ***** ^ undeclared identifier
  1216. ***** ^ not supported yet
  1217. ***** ^ not supported yet
  1218. 565 END WrLn;
  1219. ***** ^ not supported yet
  1220. 566
  1221. 567 PROCEDURE RdChar(F: File ) : CHAR;
  1222. ***** ^ undeclared identifier
  1223. 568 VAR c : CHAR;
  1224. 569 BEGIN
  1225. 570 (*%T _mthread *)
  1226. 571 SetIOR(0);
  1227. ***** ^ not supported yet
  1228. ***** ^ not supported yet
  1229. 572 (*%E *)
  1230. 573 (*%F _mthread *)
  1231. 574 IOR := 0;
  1232. 575 (*%E *)
  1233. 576 OK := TRUE;
  1234. ***** ^ undeclared identifier
  1235. 577 (*%T _mthread *)
  1236. 578 SetThreadOK(TRUE);
  1237. ***** ^ not supported yet
  1238. ***** ^ not supported yet
  1239. 579 (*%E *)
  1240. 580 IF (F <= CoreFile._open_max) AND (CoreFile.BufInf[F] # NIL) THEN
  1241. ***** ^ not supported yet
  1242. ***** ^ not supported yet
  1243. ***** ^ not supported yet
  1244. ***** ^ not supported yet
  1245. ***** ^ not supported yet
  1246. ***** ^ not supported yet
  1247. 581 (*%T _mthread *)
  1248. 582 (*%F _OS2 *)
  1249. 583 Process.Lock();
  1250. 584 (*%E *)
  1251. 585 (*%T _OS2 *)
  1252. 586 StreamLock(CoreFile.BufInf[F]);
  1253. ***** ^ not supported yet
  1254. ***** ^ not supported yet
  1255. ***** ^ not supported yet
  1256. ***** ^ not supported yet
  1257. 587 (*%E *)
  1258. 588 (*%E *)
  1259. 589 WITH CoreFile.BufInf[F]^ DO
  1260. ***** ^ not supported yet
  1261. ***** ^ not supported yet
  1262. ***** ^ not supported yet
  1263. 590 DEC(Cnt);
  1264. ***** ^ undeclared identifier
  1265. ***** ^ undeclared identifier
  1266. 591 IF Cnt < 0 THEN
  1267. ***** ^ undeclared identifier
  1268. 592 IF FilBuf(CoreFile.BufInf[F]) <= 0 THEN;
  1269. ***** ^ not supported yet
  1270. ***** ^ not supported yet
  1271. ***** ^ not supported yet
  1272. ***** ^ not supported yet
  1273. ***** ^ 'END' expected
  1274. 593 (*%T _mthread *)
  1275. 594 SetThreadEOF((Flag >= CoreIO._F_EOF));
  1276. ***** ^ not supported yet
  1277. ***** ^ undeclared identifier
  1278. ***** ^ not supported yet
  1279. ***** ^ not supported yet
  1280. ***** ^ not supported yet
  1281. 595 (*%E *)
  1282. 596 EOF := (Flag >= CoreIO._F_EOF);
  1283. ***** ^ undeclared identifier
  1284. ***** ^ undeclared identifier
  1285. ***** ^ not supported yet
  1286. ***** ^ not supported yet
  1287. 597 (*%T _mthread *)
  1288. 598 SetThreadOK(FALSE);
  1289. ***** ^ not supported yet
  1290. ***** ^ not supported yet
  1291. 599 (*%E *)
  1292. 600 OK := FALSE;
  1293. ***** ^ undeclared identifier
  1294. 601 (*%T _mthread *)
  1295. 602 (*%F _OS2 *)
  1296. 603 Process.Unlock();
  1297. 604 (*%E *)
  1298. 605 (*%T _OS2 *)
  1299. 606 StreamUnlock(CoreFile.BufInf[F]);
  1300. ***** ^ not supported yet
  1301. ***** ^ not supported yet
  1302. ***** ^ not supported yet
  1303. ***** ^ not supported yet
  1304. 607 (*%E *)
  1305. 608 (*%E *)
  1306. 609 RETURN CHR(26);
  1307. ***** ^ undeclared identifier
  1308. ***** ^ not supported yet
  1309. 610 END;
  1310. 611 DEC(Cnt);
  1311. ***** ^ undeclared identifier
  1312. ***** ^ undeclared identifier
  1313. 612 END;
  1314. ***** ^ not supported yet
  1315. 613 c := Ptr^;
  1316. ***** ^ undeclared identifier
  1317. ***** ^ undeclared identifier
  1318. 614 INC(CARDINAL(Ptr), 1);
  1319. ***** ^ undeclared identifier
  1320. ***** ^ undeclared identifier
  1321. ***** ^ not supported yet
  1322. 615 (*%T _mthread *)
  1323. 616 SetThreadEOF((Flag >= CoreIO._F_EOF) OR (c = CHR(26)));
  1324. ***** ^ not supported yet
  1325. ***** ^ undeclared identifier
  1326. ***** ^ not supported yet
  1327. ***** ^ not supported yet
  1328. ***** ^ undeclared identifier
  1329. ***** ^ undeclared identifier
  1330. ***** ^ not supported yet
  1331. ***** ^ not supported yet
  1332. 617 (*%E *)
  1333. 618 EOF := ((Flag >= CoreIO._F_EOF) OR (c = CHR(26)));
  1334. ***** ^ undeclared identifier
  1335. ***** ^ undeclared identifier
  1336. ***** ^ not supported yet
  1337. ***** ^ not supported yet
  1338. ***** ^ undeclared identifier
  1339. ***** ^ undeclared identifier
  1340. ***** ^ not supported yet
  1341. 619 (*%T _mthread *)
  1342. 620 (*%F _OS2 *)
  1343. 621 Process.Unlock();
  1344. 622 (*%E *)
  1345. 623 (*%T _OS2 *)
  1346. 624 StreamUnlock(CoreFile.BufInf[F]);
  1347. ***** ^ not supported yet
  1348. ***** ^ not supported yet
  1349. ***** ^ not supported yet
  1350. ***** ^ undeclared identifier
  1351. 625 (*%E *)
  1352. 626 (*%E *)
  1353. 627 RETURN c;
  1354. ***** ^ undeclared identifier
  1355. 628 END;
  1356. 629 END;
  1357. ***** ^ ident expected
  1358. 630 (*%T _mthread *)
  1359. 631 (*%F _OS2 *)
  1360. 632 Process.Lock();
  1361. 633 (*%E *)
  1362. 634 (*%E *)
  1363. 635 IF CoreIO._read(F, CoreFile.StreamPtr(ADR(c)), 1) <= 0 THEN
  1364. 636 OK := FALSE;
  1365. 637 (*%T _mthread *)
  1366. 638 SetThreadOK(FALSE);
  1367. 639 (*%E *)
  1368. 640 c := CHR(26);
  1369. 641 END;
  1370. 642 (*%T _mthread *)
  1371. 643 SetThreadEOF((c = CHR(26)));
  1372. 644 (*%E *)
  1373. 645 EOF := (c = CHR(26));
  1374. 646 (*%T _mthread *)
  1375. 647 (*%F _OS2 *)
  1376. 648 Process.Unlock();
  1377. 649 (*%E *)
  1378. 650 (*%E *)
  1379. 651 RETURN c;
  1380. 652 END RdChar;
  1381. 653
  1382. 654
  1383. 655 PROCEDURE RdStr(F: File; VAR Buf: ARRAY OF CHAR);
  1384. 656 VAR
  1385. 657 i,h : CARDINAL;
  1386. 658 c : CHAR;
  1387. 659 BEGIN
  1388. 660 i := 0;
  1389. 661 h := HIGH( Buf );
  1390. 662 (*%T _mthread *)
  1391. 663 SetThreadOK(TRUE);
  1392. 664 (*%E *)
  1393. 665 OK := TRUE;
  1394. 666 LOOP
  1395. 667 IF i > h THEN RETURN END;
  1396. 668 c := RdChar( F );
  1397. 669 IF c = CHR( 26 ) THEN
  1398. 670 Buf[ i ] := CHR(0);
  1399. 671 (*%T _mthread *)
  1400. 672 SetThreadEOF((i = 0));
  1401. 673 (*%E *)
  1402. 674 EOF := (i = 0);
  1403. 675 RETURN;
  1404. 676 ELSIF c = EOL THEN
  1405. 677 Buf[ i ] := CHR(0);
  1406. 678 RETURN;
  1407. 679 ELSIF (c # CHR( 10 )) AND (c # CHR( 13 )) THEN
  1408. 680 Buf[ i ] := c;
  1409. 681 INC( i );
  1410. 682 END;
  1411. 683 END;
  1412. 684 END RdStr;
  1413. 685
  1414. 686 PROCEDURE RdItem( F : File; VAR S : ARRAY OF CHAR );
  1415. 687 VAR c : CHAR; i,L : CARDINAL;
  1416. 688 BEGIN
  1417. 689 i := 0;
  1418. 690 LOOP
  1419. 691 c := RdChar( F );
  1420. 692 IF NOT (*%T _mthread *) ThreadOK() (*%E *) (*%F _mthread *) OK (*%E *)
  1421. 693 OR NOT (c IN Separators) THEN EXIT; END;
  1422. 694 END;
  1423. 695 L := HIGH( S );
  1424. 696 LOOP
  1425. 697 IF NOT (*%T _mthread *) ThreadOK() (*%E *) (*%F _mthread *) OK (*%E *)
  1426. 698 OR ( c IN Separators ) THEN EXIT; END;
  1427. 699 S[i] := c;
  1428. 700 INC( i );
  1429. 701 IF i > L THEN
  1430. 702 EXIT;
  1431. 703 ELSE
  1432. 704 c := RdChar( F );
  1433. 705 IF c = CHR(26) THEN
  1434. 706 (*%T _mthread *)
  1435. 707 SetThreadOK(TRUE);
  1436. 708 (*%E *)
  1437. 709 OK := TRUE;
  1438. 710 EXIT;
  1439. 711 ELSIF c = CHR(13) THEN
  1440. 712 c := RdChar(F);
  1441. 713 EXIT;
  1442. 714 END;
  1443. 715 END;
  1444. 716 END;
  1445. 717 IF i <= L THEN S[i] := 0C; END;
  1446. 718 END RdItem;
  1447. 719
  1448. 720 (*# save,
  1449. 721 call(o_a_copy => on) *)
  1450. 722
  1451. 723 PROCEDURE WrStrAdj(F: File; S: ARRAY OF CHAR; Length: INTEGER);
  1452. 724 VAR
  1453. 725 L : CARDINAL;
  1454. 726 a : INTEGER;
  1455. 727 BEGIN
  1456. 728 (*%T _mthread *)
  1457. 729 SetThreadOK(TRUE);
  1458. 730 (*%E *)
  1459. 731 OK := TRUE;
  1460. 732 L := Str.Length( S );
  1461. 733 a := ABS( Length ) - INTEGER( L );
  1462. 734 IF (a < 0) AND ChopOff THEN
  1463. 735 L := CARDINAL(ABS(Length));
  1464. 736 IF L>HIGH(S) THEN
  1465. 737 L := HIGH(S)+1;
  1466. 738 ELSE
  1467. 739 S[L] := CHR(0);
  1468. 740 END;
  1469. 741 WHILE (L>0) DO DEC(L) ; S[L] := '?'; END;
  1470. 742 (*%T _mthread *)
  1471. 743 SetThreadOK(FALSE);
  1472. 744 (*%E *)
  1473. 745 OK := FALSE;
  1474. 746 a := 0;
  1475. 747 END;
  1476. 748 IF (Length > 0) AND (a > 0) THEN WrCharRep( F, PrefixChar, a ); END;
  1477. 749 WrStr( F,S );
  1478. 750 IF (Length < 0) AND (a > 0) THEN WrCharRep( F, SuffixChar, a ); END;
  1479. 751 END WrStrAdj;
  1480. 752
  1481. 753 (*# restore *)
  1482. 754
  1483. 755 PROCEDURE WrChar(F: File; V: CHAR);
  1484. 756 BEGIN
  1485. 757 (*%T _mthread *)
  1486. 758 SetThreadOK(TRUE);
  1487. 759 (*%E *)
  1488. 760 OK := TRUE;
  1489. 761 IF (F <= CoreFile._open_max) AND (CoreFile.BufInf[F] # NIL) THEN
  1490. 762 (*%T _mthread *)
  1491. 763 (*%F _OS2 *)
  1492. 764 Process.Lock();
  1493. 765 (*%E *)
  1494. 766 (*%T _OS2 *)
  1495. 767 StreamLock(CoreFile.BufInf[F]);
  1496. 768 (*%E *)
  1497. 769 (*%E *)
  1498. 770 WITH CoreFile.BufInf[F]^ DO
  1499. 771 DEC(Cnt);
  1500. 772 IF Cnt < 0 THEN
  1501. 773 IF FlsBuf(CoreFile.BufInf[F]) <= 0 THEN
  1502. 774 (*%T _mthread *)
  1503. 775 SetThreadOK(FALSE);
  1504. 776 (*%E *)
  1505. 777 OK := FALSE;
  1506. 778 (*%T _mthread *)
  1507. 779 (*%F _OS2 *)
  1508. 780 Process.Unlock();
  1509. 781 (*%E *)
  1510. 782 (*%T _OS2 *)
  1511. 783 StreamUnlock(CoreFile.BufInf[F]);
  1512. 784 (*%E *)
  1513. 785 (*%E *)
  1514. 786 RETURN;
  1515. 787 END;
  1516. 788 DEC(Cnt);
  1517. 789 END;
  1518. 790 Ptr^ := V;
  1519. 791 INC(CARDINAL(Ptr), 1);
  1520. 792 RETURN;
  1521. 793 END;
  1522. 794 END;
  1523. 795 (*%T _mthread *)
  1524. 796 (*%F _OS2 *)
  1525. 797 Process.Lock();
  1526. 798 (*%E *)
  1527. 799 (*%E *)
  1528. 800 IF CoreIO._write(F, CoreFile.StreamPtr(ADR(V)), 1) = 0 THEN
  1529. 801 (*%T _mthread *)
  1530. 802 SetThreadOK(FALSE);
  1531. 803 (*%E *)
  1532. 804 OK := FALSE;
  1533. 805 END;
  1534. 806 (*%T _mthread *)
  1535. 807 (*%F _OS2 *)
  1536. 808 Process.Unlock();
  1537. 809 (*%E *)
  1538. 810 (*%E *)
  1539. 811 RETURN;
  1540. 812 END WrChar;
  1541. 813
  1542. 814 PROCEDURE WrCharRep(F: File; V: CHAR ; Count: CARDINAL);
  1543. 815 VAR
  1544. 816 S : Str80;
  1545. 817 i,j : CARDINAL;
  1546. 818 BEGIN
  1547. 819 WHILE Count>0 DO
  1548. 820 i := SIZE(S);
  1549. 821 IF i > Count THEN i := Count END;
  1550. 822 DEC(Count,i);
  1551. 823 FOR j := 0 TO i-1 DO S[j] := V END;
  1552. 824 WrBin( F,S,i );
  1553. 825 IF NOT (*%T _mthread *) ThreadOK() (*%E *) (*%F _mthread *) OK (*%E *) THEN RETURN END ;
  1554. 826 END;
  1555. 827 END WrCharRep;
  1556. 828
  1557. 829 PROCEDURE WrBool(F: File; V: BOOLEAN; Length: INTEGER);
  1558. 830 BEGIN
  1559. 831 IF V THEN
  1560. 832 WrStrAdj( F,TrueStr,Length );
  1561. 833 ELSE
  1562. 834 WrStrAdj( F,'FALSE',Length );
  1563. 835 END;
  1564. 836 END WrBool;
  1565. 837
  1566. 838 PROCEDURE WrShtInt(F: File; V: SHORTINT; Length: INTEGER);
  1567. 839 VAR
  1568. 840 S : Str80;
  1569. 841 b : BOOLEAN;
  1570. 842 BEGIN
  1571. 843 Str.IntToStr( LONGINT(V),S,10,b);
  1572. 844 (*%T _mthread *)
  1573. 845 SetThreadOK(b);
  1574. 846 (*%E *)
  1575. 847 IF b THEN
  1576. 848 WrStrAdj(F,S,Length );
  1577. 849 END;
  1578. 850 OK := b;
  1579. 851 END WrShtInt;
  1580. 852
  1581. 853 PROCEDURE WrInt(F: File; V: INTEGER; Length: INTEGER);
  1582. 854 VAR
  1583. 855 S : Str80;
  1584. 856 b : BOOLEAN;
  1585. 857 BEGIN
  1586. 858 Str.IntToStr( LONGINT(V),S,10,b);
  1587. 859 (*%T _mthread *)
  1588. 860 SetThreadOK(b);
  1589. 861 (*%E *)
  1590. 862 IF b THEN
  1591. 863 WrStrAdj(F,S,Length );
  1592. 864 END;
  1593. 865 OK := b;
  1594. 866 END WrInt;
  1595. 867
  1596. 868 PROCEDURE WrLngInt(F: File; V: LONGINT; Length: INTEGER);
  1597. 869 VAR
  1598. 870 S : Str80;
  1599. 871 b : BOOLEAN;
  1600. 872 BEGIN
  1601. 873 Str.IntToStr( V,S,10,b);
  1602. 874 (*%T _mthread *)
  1603. 875 SetThreadOK(b);
  1604. 876 (*%E *)
  1605. 877 IF b THEN
  1606. 878 WrStrAdj(F,S,Length );
  1607. 879 END;
  1608. 880 OK := b;
  1609. 881 END WrLngInt;
  1610. 882
  1611. 883 PROCEDURE WrShtCard(F: File; V: SHORTCARD; Length: INTEGER);
  1612. 884 VAR S : Str80;
  1613. 885 b : BOOLEAN;
  1614. 886 BEGIN
  1615. 887 Str.CardToStr(LONGCARD(V),S,10,b);
  1616. 888 (*%T _mthread *)
  1617. 889 SetThreadOK(b);
  1618. 890 (*%E *)
  1619. 891 IF b THEN
  1620. 892 WrStrAdj(F,S,Length );
  1621. 893 END;
  1622. 894 OK := b;
  1623. 895 END WrShtCard;
  1624. 896
  1625. 897 PROCEDURE WrCard(F: File; V: CARDINAL; Length: INTEGER);
  1626. 898 VAR
  1627. 899 S : Str80;
  1628. 900 b : BOOLEAN;
  1629. 901 BEGIN
  1630. 902 Str.CardToStr(LONGCARD(V),S,10,b);
  1631. 903 (*%T _mthread *)
  1632. 904 SetThreadOK(b);
  1633. 905 (*%E *)
  1634. 906 IF b THEN
  1635. 907 WrStrAdj(F,S,Length );
  1636. 908 END;
  1637. 909 OK := b;
  1638. 910 END WrCard;
  1639. 911
  1640. 912 PROCEDURE WrLngCard(F: File; V: LONGCARD; Length: INTEGER);
  1641. 913 VAR
  1642. 914 S : Str80;
  1643. 915 b : BOOLEAN;
  1644. 916 BEGIN
  1645. 917 Str.CardToStr(V,S,10,b);
  1646. 918 (*%T _mthread *)
  1647. 919 SetThreadOK(b);
  1648. 920 (*%E *)
  1649. 921 IF b THEN
  1650. 922 WrStrAdj(F,S,Length );
  1651. 923 END;
  1652. 924 OK := b;
  1653. 925 END WrLngCard;
  1654. 926
  1655. 927 PROCEDURE WrShtHex(F: File; V: SHORTCARD; Length: INTEGER);
  1656. 928 VAR
  1657. 929 S : Str80;
  1658. 930 b : BOOLEAN;
  1659. 931 BEGIN
  1660. 932 Str.CardToStr(LONGCARD(V),S,16,b);
  1661. 933 (*%T _mthread *)
  1662. 934 SetThreadOK(b);
  1663. 935 (*%E *)
  1664. 936 IF b THEN
  1665. 937 WrStrAdj(F,S,Length );
  1666. 938 END;
  1667. 939 OK := b;
  1668. 940 END WrShtHex;
  1669. 941
  1670. 942 PROCEDURE WrHex(F: File; V: CARDINAL; Length: INTEGER);
  1671. 943 VAR
  1672. 944 S : Str80;
  1673. 945 b : BOOLEAN;
  1674. 946 BEGIN
  1675. 947 Str.CardToStr(LONGCARD(V),S,16,b);
  1676. 948 (*%T _mthread *)
  1677. 949 SetThreadOK(b);
  1678. 950 (*%E *)
  1679. 951 IF b THEN
  1680. 952 WrStrAdj(F,S,Length );
  1681. 953 END;
  1682. 954 OK := b;
  1683. 955 END WrHex;
  1684. 956
  1685. 957 PROCEDURE WrLngHex(F: File; V: LONGCARD; Length: INTEGER);
  1686. 958 VAR S : Str80;
  1687. 959 b : BOOLEAN;
  1688. 960 BEGIN
  1689. 961 Str.CardToStr(V,S,16,b);
  1690. 962 (*%T _mthread *)
  1691. 963 SetThreadOK(b);
  1692. 964 (*%E *)
  1693. 965 IF b THEN
  1694. 966 WrStrAdj(F,S,Length );
  1695. 967 END;
  1696. 968 OK := b;
  1697. 969 END WrLngHex;
  1698. 970
  1699. 971 PROCEDURE WrReal(F: File; V: REAL; Precision: CARDINAL; Length: INTEGER);
  1700. 972 VAR
  1701. 973 S : Str80;
  1702. 974 b : BOOLEAN;
  1703. 975 BEGIN
  1704. 976 Str.RealToStr( LONGREAL ( V ),Precision,Eng,S,b);
  1705. 977 (*%T _mthread *)
  1706. 978 SetThreadOK(b);
  1707. 979 (*%E *)
  1708. 980 IF b THEN
  1709. 981 WrStrAdj(F,S,Length );
  1710. 982 END;
  1711. 983 OK := b;
  1712. 984 END WrReal;
  1713. 985
  1714. 986 PROCEDURE WrFixReal(F: File; V: REAL; Precision: CARDINAL; Length: INTEGER);
  1715. 987 VAR
  1716. 988 S : Str80;
  1717. 989 b : BOOLEAN;
  1718. 990 BEGIN
  1719. 991 Str.FixRealToStr( LONGREAL ( V ),Precision,S,b );
  1720. 992 (*%T _mthread *)
  1721. 993 SetThreadOK(b);
  1722. 994 (*%E *)
  1723. 995 IF b THEN
  1724. 996 WrStrAdj(F,S,Length );
  1725. 997 END;
  1726. 998 OK := b;
  1727. 999 END WrFixReal;
  1728. 1000
  1729. 1001 PROCEDURE WrLngReal(F: File; V : LONGREAL; Precision: CARDINAL; Length: INTEGER);
  1730. 1002 VAR
  1731. 1003 S : Str80;
  1732. 1004 b : BOOLEAN;
  1733. 1005 BEGIN
  1734. 1006 Str.RealToStr( V,Precision,Eng,S,b);
  1735. 1007 (*%T _mthread *)
  1736. 1008 SetThreadOK(b);
  1737. 1009 (*%E *)
  1738. 1010 IF b THEN
  1739. 1011 WrStrAdj(F,S,Length );
  1740. 1012 END;
  1741. 1013 OK := b;
  1742. 1014 END WrLngReal;
  1743. 1015
  1744. 1016 PROCEDURE WrFixLngReal(F: File; V: LONGREAL; Precision: CARDINAL; Length: INTEGER);
  1745. 1017 VAR
  1746. 1018 S : Str80;
  1747. 1019 b : BOOLEAN;
  1748. 1020 BEGIN
  1749. 1021 Str.FixRealToStr(V,Precision,S,b );
  1750. 1022 (*%T _mthread *)
  1751. 1023 SetThreadOK(b);
  1752. 1024 (*%E *)
  1753. 1025 IF b THEN
  1754. 1026 WrStrAdj(F,S,Length );
  1755. 1027 END;
  1756. 1028 OK := b;
  1757. 1029 END WrFixLngReal;
  1758. 1030
  1759. 1031 PROCEDURE RdBool(F: File): BOOLEAN;
  1760. 1032 VAR s : Str80;
  1761. 1033 BEGIN
  1762. 1034 RdItem( F,s );
  1763. 1035 RETURN Str.Compare( s,TrueStr )=0;
  1764. 1036 END RdBool;
  1765. 1037
  1766. 1038 PROCEDURE RdShtInt(F: File) : SHORTINT;
  1767. 1039 VAR
  1768. 1040 S : Str80;
  1769. 1041 i : LONGINT;
  1770. 1042 b : BOOLEAN;
  1771. 1043 BEGIN
  1772. 1044 RdItem(F,S );
  1773. 1045 i := Str.StrToInt( S,10,b );
  1774. 1046 (*%T _mthread *)
  1775. 1047 SetThreadOK(b AND (i >= -80H) AND (i < 80H));
  1776. 1048 (*%E *)
  1777. 1049 OK := b AND (i >= -80H) AND (i < 80H);
  1778. 1050 RETURN SHORTINT( i );
  1779. 1051 END RdShtInt;
  1780. 1052
  1781. 1053 PROCEDURE RdInt(F: File) : INTEGER;
  1782. 1054 VAR
  1783. 1055 S : Str80;
  1784. 1056 i : LONGINT;
  1785. 1057 b : BOOLEAN;
  1786. 1058 BEGIN
  1787. 1059 RdItem(F,S);
  1788. 1060 i := Str.StrToInt( S,10,b );
  1789. 1061 (*%T _mthread *)
  1790. 1062 SetThreadOK(b AND (i >= -8000H) AND (i < 8000H));
  1791. 1063 (*%E *)
  1792. 1064 OK := b AND (i >= -8000H) AND (i < 8000H);
  1793. 1065 RETURN INTEGER(i);
  1794. 1066 END RdInt;
  1795. 1067
  1796. 1068 PROCEDURE RdLngInt(F: File) : LONGINT;
  1797. 1069 VAR
  1798. 1070 S : Str80;
  1799. 1071 i : LONGINT;
  1800. 1072 b : BOOLEAN;
  1801. 1073 BEGIN
  1802. 1074 RdItem(F,S);
  1803. 1075 i := Str.StrToInt( S,10,b );
  1804. 1076 (*%T _mthread *)
  1805. 1077 SetThreadOK(b);
  1806. 1078 (*%E *)
  1807. 1079 OK := b;
  1808. 1080 RETURN i;
  1809. 1081 END RdLngInt;
  1810. 1082
  1811. 1083 PROCEDURE RdShtCard(F: File) : SHORTCARD;
  1812. 1084 VAR
  1813. 1085 S : Str80;
  1814. 1086 i : LONGCARD;
  1815. 1087 b : BOOLEAN;
  1816. 1088 BEGIN
  1817. 1089 RdItem(F,S);
  1818. 1090 i := Str.StrToCard( S,10,b );
  1819. 1091 (*%T _mthread *)
  1820. 1092 SetThreadOK(b AND (i < 100H));
  1821. 1093 (*%E *)
  1822. 1094 OK := b AND (i < 100H);
  1823. 1095 RETURN SHORTCARD( i );
  1824. 1096 END RdShtCard;
  1825. 1097
  1826. 1098 PROCEDURE RdShtHex(F: File) : SHORTCARD;
  1827. 1099 VAR
  1828. 1100 S : Str80;
  1829. 1101 i : LONGCARD;
  1830. 1102 b : BOOLEAN;
  1831. 1103 BEGIN
  1832. 1104 RdItem(F,S);
  1833. 1105 i := Str.StrToCard( S,16,b );
  1834. 1106 (*%T _mthread *)
  1835. 1107 SetThreadOK(b AND (i < 100H));
  1836. 1108 (*%E *)
  1837. 1109 OK := b AND (i < 100H);
  1838. 1110 RETURN SHORTCARD( i );
  1839. 1111 END RdShtHex;
  1840. 1112
  1841. 1113 PROCEDURE RdCard(F: File) : CARDINAL;
  1842. 1114 VAR
  1843. 1115 S : Str80;
  1844. 1116 i : LONGCARD;
  1845. 1117 b : BOOLEAN;
  1846. 1118 BEGIN
  1847. 1119 RdItem(F,S);
  1848. 1120 i := Str.StrToCard( S,10,b );
  1849. 1121 (*%T _mthread *)
  1850. 1122 SetThreadOK(b AND (i < 10000H));
  1851. 1123 (*%E *)
  1852. 1124 OK := b AND (i < 10000H);
  1853. 1125 RETURN CARDINAL( i );
  1854. 1126 END RdCard;
  1855. 1127
  1856. 1128 PROCEDURE RdHex(F: File) : CARDINAL;
  1857. 1129 VAR
  1858. 1130 S : Str80;
  1859. 1131 i : LONGCARD;
  1860. 1132 b : BOOLEAN;
  1861. 1133 BEGIN
  1862. 1134 RdItem(F,S);
  1863. 1135 i := Str.StrToCard( S,16,b );
  1864. 1136 (*%T _mthread *)
  1865. 1137 SetThreadOK(b AND (i < 10000H));
  1866. 1138 (*%E *)
  1867. 1139 OK := b AND (i < 10000H);
  1868. 1140 RETURN CARDINAL( i );
  1869. 1141 END RdHex;
  1870. 1142
  1871. 1143 PROCEDURE RdLngCard(F: File) : LONGCARD;
  1872. 1144 VAR
  1873. 1145 S : Str80;
  1874. 1146 i : LONGCARD;
  1875. 1147 b : BOOLEAN;
  1876. 1148 BEGIN
  1877. 1149 RdItem(F,S);
  1878. 1150 i := Str.StrToCard( S,10,b );
  1879. 1151 (*%T _mthread *)
  1880. 1152 SetThreadOK(b);
  1881. 1153 (*%E *)
  1882. 1154 OK := b;
  1883. 1155 RETURN i;
  1884. 1156 END RdLngCard;
  1885. 1157
  1886. 1158 PROCEDURE RdLngHex(F: File) : LONGCARD;
  1887. 1159 VAR
  1888. 1160 S : Str80;
  1889. 1161 i : LONGCARD;
  1890. 1162 b : BOOLEAN;
  1891. 1163 BEGIN
  1892. 1164 RdItem(F,S);
  1893. 1165 i := Str.StrToCard( S,16,b );
  1894. 1166 (*%T _mthread *)
  1895. 1167 SetThreadOK(b);
  1896. 1168 (*%E *)
  1897. 1169 OK := b;
  1898. 1170 RETURN i;
  1899. 1171 END RdLngHex ;
  1900. 1172
  1901. 1173 PROCEDURE RdReal(F: File) : REAL;
  1902. 1174 VAR
  1903. 1175 S : Str80;
  1904. 1176 r : LONGREAL;
  1905. 1177 b : BOOLEAN;
  1906. 1178 BEGIN
  1907. 1179 RdItem(F,S );
  1908. 1180 r := Str.StrToReal( S,b);
  1909. 1181 (*%T _mthread *)
  1910. 1182 SetThreadOK(b AND (ABS(r) <= 3.4E38 ));
  1911. 1183 (*%E *)
  1912. 1184 OK := b AND (ABS(r) <= 3.4E38 );
  1913. 1185 RETURN REAL ( r );
  1914. 1186 END RdReal;
  1915. 1187
  1916. 1188 PROCEDURE RdLngReal(F: File) : LONGREAL;
  1917. 1189 VAR
  1918. 1190 S : Str80;
  1919. 1191 r : LONGREAL;
  1920. 1192 b : BOOLEAN;
  1921. 1193 BEGIN
  1922. 1194 RdItem(F,S);
  1923. 1195 r := Str.StrToReal( S,b);
  1924. 1196 (*%T _mthread *)
  1925. 1197 SetThreadOK(b);
  1926. 1198 (*%E *)
  1927. 1199 OK := b;
  1928. 1200 RETURN r;
  1929. 1201 END RdLngReal;
  1930. 1202
  1931. 1203
  1932. 1204 PROCEDURE GetName(name: ARRAY OF CHAR; VAR fn: PathStr);
  1933. 1205 (* Makes Null terminated filename, also sets IOR to 0 *)
  1934. 1206 BEGIN
  1935. 1207 Str.Copy(fn,name);
  1936. 1208 fn[HIGH(fn)] := CHR(0);
  1937. 1209 (*%T _mthread *)
  1938. 1210 SetIOR(0);
  1939. 1211 (*%E *)
  1940. 1212 (*%F _mthread *)
  1941. 1213 IOR := 0;
  1942. 1214 (*%E *)
  1943. 1215 END GetName;
  1944. 1216
  1945. 1217 PROCEDURE Open(Name: ARRAY OF CHAR) : File;
  1946. 1218 VAR
  1947. 1219 fn: PathStr;
  1948. 1220 H: File;
  1949. 1221 BEGIN
  1950. 1222 GetName(Name,fn);
  1951. 1223 (*%F _OS2 *)
  1952. 1224 H := CoreIO._open(fn, CARDINAL(CoreIO.O_RDWR + ShareMode));
  1953. 1225 (*%E *)
  1954. 1226 (*%T _OS2 *)
  1955. 1227 H := CoreIO._os2_open(fn, CARDINAL(CoreIO.O_RDWR + ShareMode), 0, 1);
  1956. 1228 (*%E *)
  1957. 1229 IF H <> MAX(CARDINAL) THEN
  1958. 1230 CoreFile._openfd[H] := (CoreIO.O_RDWR+CoreIO.O_BINARY);
  1959. 1231 IF CoreIO.isatty(H) # 0 THEN
  1960. 1232 CoreFile._openfd[H] := CoreFile._openfd[H] + CoreIO.O_DEVICE;
  1961. 1233 END;
  1962. 1234 ELSE
  1963. 1235 ErrorCheck(2, 0, 'Open : ', fn);
  1964. 1236 END;
  1965. 1237 RETURN H;
  1966. 1238 END Open;
  1967. 1239
  1968. 1240 PROCEDURE OpenRead( Name: ARRAY OF CHAR) : File;
  1969. 1241 VAR
  1970. 1242 fn: PathStr;
  1971. 1243 H: File;
  1972. 1244 BEGIN
  1973. 1245 GetName(Name,fn);
  1974. 1246 (*%F _OS2 *)
  1975. 1247 H := CoreIO._open(fn, CARDINAL(CoreIO.O_RDONLY + ShareMode));
  1976. 1248 (*%E *)
  1977. 1249 (*%T _OS2 *)
  1978. 1250 H := CoreIO._os2_open(fn, CARDINAL(CoreIO.O_RDONLY + ShareMode), 1, 1);
  1979. 1251 (*%E *)
  1980. 1252 IF H <> MAX(CARDINAL) THEN
  1981. 1253 CoreFile._openfd[H] := (CoreIO.O_RDONLY+CoreIO.O_BINARY);
  1982. 1254 IF CoreIO.isatty(H) # 0 THEN
  1983. 1255 CoreFile._openfd[H] := CoreFile._openfd[H] + CoreIO.O_DEVICE;
  1984. 1256 END;
  1985. 1257 ELSE
  1986. 1258 ErrorCheck(3, 0, 'OpenRead : ', fn);
  1987. 1259 END;
  1988. 1260 RETURN H;
  1989. 1261 END OpenRead;
  1990. 1262
  1991. 1263 (*%F _OS2 *)
  1992. 1264 PROCEDURE Exists(Name: ARRAY OF CHAR) : BOOLEAN;
  1993. 1265 VAR
  1994. 1266 r : SYSTEM.Registers ;
  1995. 1267 fn: PathStr;
  1996. 1268 BEGIN
  1997. 1269 GetName(Name,fn);
  1998. 1270 r.AX := 4300H ; (* get file attr *)
  1999. 1271 r.DS := Seg(fn);
  2000. 1272 r.DX := Ofs(fn);
  2001. 1273 Lib.Dos(r);
  2002. 1274 RETURN NOT(SYSTEM.CarryFlag IN r.Flags);
  2003. 1275 END Exists;
  2004. 1276 (*%E *)
  2005. 1277
  2006. 1278 (*%T _OS2 *)
  2007. 1279 PROCEDURE Exists(Name: ARRAY OF CHAR) : BOOLEAN;
  2008. 1280 VAR a : CARDINAL ;
  2009. 1281 fn: PathStr;
  2010. 1282 BEGIN
  2011. 1283 GetName(Name,fn);
  2012. 1284 RETURN Dos.QFileMode(fn,a,0)=0;
  2013. 1285 END Exists;
  2014. 1286 (*%E *)
  2015. 1287
  2016. 1288
  2017. 1289 PROCEDURE Append(Name: ARRAY OF CHAR) : File;
  2018. 1290 VAR
  2019. 1291 fn: PathStr;
  2020. 1292 H: File;
  2021. 1293 BEGIN
  2022. 1294 GetName(Name,fn);
  2023. 1295 (*%F _OS2 *)
  2024. 1296 H := CoreIO._open(fn, CARDINAL(CoreIO.O_RDWR));
  2025. 1297 (*%E *)
  2026. 1298 (*%T _OS2 *)
  2027. 1299 H := CoreIO._os2_open(fn, CARDINAL(CoreIO.O_RDWR), 0, 1H);
  2028. 1300 (*%E *)
  2029. 1301 IF H <> MAX(CARDINAL) THEN
  2030. 1302 CoreFile._openfd[H] := (CoreIO.O_RDWR+CoreIO.O_BINARY+CoreIO.O_APPEND);
  2031. 1303 Seek(H, Size(H));
  2032. 1304 IF CoreIO.isatty(H) # 0 THEN
  2033. 1305 CoreFile._openfd[H] := CoreFile._openfd[H] + CoreIO.O_DEVICE;
  2034. 1306 END;
  2035. 1307 ELSE
  2036. 1308 ErrorCheck(4, 0, 'Append : ', fn);
  2037. 1309 END;
  2038. 1310 RETURN H;
  2039. 1311 END Append;
  2040. 1312
  2041. 1313 PROCEDURE Create(Name: ARRAY OF CHAR) : File;
  2042. 1314 VAR
  2043. 1315 fn: PathStr;
  2044. 1316 H: File;
  2045. 1317 BEGIN
  2046. 1318 GetName(Name,fn);
  2047. 1319 (*%F _OS2 *)
  2048. 1320 H := CoreIO._creat_trunc(fn, 0);
  2049. 1321 (*%E *)
  2050. 1322 (*%T _OS2 *)
  2051. 1323 H := CoreIO._os2_open(fn, CARDINAL(CoreIO.O_RDWR), 0, 12H);
  2052. 1324 (*%E *)
  2053. 1325 IF H <> MAX(CARDINAL) THEN
  2054. 1326 CoreFile._openfd[H] := (CoreIO.O_RDWR+CoreIO.O_BINARY);
  2055. 1327 ELSE
  2056. 1328 ErrorCheck(5, 0, 'Create : ', Name);
  2057. 1329 END;
  2058. 1330 RETURN H;
  2059. 1331 END Create;
  2060. 1332
  2061. 1333 PROCEDURE Close(F: File);
  2062. 1334 VAR
  2063. 1335 x : FileInf;
  2064. 1336 BEGIN
  2065. 1337 (*%T _mthread *)
  2066. 1338 SetIOR(0);
  2067. 1339 (*%E *)
  2068. 1340 (*%F _mthread *)
  2069. 1341 IOR := 0;
  2070. 1342 (*%E *)
  2071. 1343 IF F <= CoreFile._open_max THEN
  2072. 1344 IF CoreFile.BufInf[F] # NIL THEN
  2073. 1345 (*%T _mthread *)
  2074. 1346 (*%F _OS2 *)
  2075. 1347 Process.Lock();
  2076. 1348 (*%E *)
  2077. 1349 (*%T _OS2 *)
  2078. 1350 StreamLock(CoreFile.BufInf[F]);
  2079. 1351 (*%E *)
  2080. 1352 (*%E *)
  2081. 1353 Flush( F );
  2082. 1354 CoreFile.BufInf[F]^.Flag := {};
  2083. 1355 (*%T _mthread *)
  2084. 1356 (*%T _OS2 *)
  2085. 1357 x := CoreFile.BufInf[F];
  2086. 1358 (*%E *)
  2087. 1359 (*%E *)
  2088. 1360 CoreFile.BufInf[F] := NIL;
  2089. 1361 (*%T _mthread *)
  2090. 1362 (*%F _OS2 *)
  2091. 1363 Process.Unlock();
  2092. 1364 (*%E *)
  2093. 1365 (*%T _OS2 *)
  2094. 1366 StreamUnlock(x);
  2095. 1367 (*%E *)
  2096. 1368 (*%E *)
  2097. 1369 END;
  2098. 1370 CoreFile._openfd[F] := {};
  2099. 1371 END;
  2100. 1372 IF CoreIO._close(F) = -1 THEN
  2101. 1373 ErrorCheck(0, 0, 'Close : ', Lib.NilStr);
  2102. 1374 END;
  2103. 1375 RETURN;
  2104. 1376 END Close;
  2105. 1377
  2106. 1378 PROCEDURE GetPos(F: File) : LONGCARD;
  2107. 1379 VAR
  2108. 1380 Ret, Pos: LONGCARD;
  2109. 1381 BEGIN
  2110. 1382 (*%T _mthread *)
  2111. 1383 SetIOR(0);
  2112. 1384 (*%E *)
  2113. 1385 (*%F _mthread *)
  2114. 1386 IOR := 0;
  2115. 1387 (*%E *)
  2116. 1388 OK := TRUE;
  2117. 1389 (*%T _mthread *)
  2118. 1390 OKTable[CoreProc._getTID()] := TRUE;
  2119. 1391 (*%E *)
  2120. 1392 (*%T _mthread *)
  2121. 1393 (*%F _OS2 *)
  2122. 1394 Process.Lock();
  2123. 1395 (*%E *)
  2124. 1396 (*%E *)
  2125. 1397 IF (F > CoreFile._open_max) OR (CoreFile.BufInf[F] = NIL) OR (CoreFile.BufInf[F]^.Flag >= CoreIO._F_RST) THEN
  2126. 1398 Ret := CoreIO.tell(F);
  2127. 1399 ELSE
  2128. 1400 (*%T _mthread *)
  2129. 1401 (*%T _OS2 *)
  2130. 1402 StreamLock(CoreFile.BufInf[F]);
  2131. 1403 (*%E *)
  2132. 1404 (*%E *)
  2133. 1405 IF ( CoreFile.BufInf[F]^.Flag = {}) OR (CoreFile.BufInf[F]^.Flag >= CoreIO._F_ERR) THEN
  2134. 1406 ErrorCheck(9, CoreIO.EBADF, 'GetPos : ', Lib.NilStr);
  2135. 1407 Ret := MAX(LONGCARD);
  2136. 1408 END;
  2137. 1409 IF (CoreFile.BufInf[F]^.Flag >= CoreIO._F_OUT) THEN
  2138. 1410 IF FlsBuf(CoreFile.BufInf[F]) # -1 THEN (* flush stream *)
  2139. 1411 Ret := CoreIO.tell(F);
  2140. 1412 ELSE
  2141. 1413 Ret := MAX(LONGCARD);
  2142. 1414 END;
  2143. 1415 ELSE
  2144. 1416 Pos := CoreIO.tell(F); (* input stream *)
  2145. 1417 IF CoreFile.BufInf[F]^.Pback # 0 THEN
  2146. 1418 DEC(Pos);
  2147. 1419 END;
  2148. 1420 Ret := Pos-LONGCARD(CoreFile.BufInf[F]^.Cnt);
  2149. 1421 END;
  2150. 1422 (*%T _mthread *)
  2151. 1423 (*%T _OS2 *)
  2152. 1424 StreamUnlock(CoreFile.BufInf[F]);
  2153. 1425 (*%E *)
  2154. 1426 (*%E *)
  2155. 1427 END;
  2156. 1428 (*%T _mthread *)
  2157. 1429 (*%F _OS2 *)
  2158. 1430 Process.Unlock();
  2159. 1431 (*%E *)
  2160. 1432 (*%E *)
  2161. 1433 IF Ret = MAX(LONGCARD) THEN
  2162. 1434 ErrorCheck(9, 0, 'GetPos : ', Lib.NilStr);
  2163. 1435 OK := FALSE;
  2164. 1436 (*%T _mthread *)
  2165. 1437 OKTable[CoreProc._getTID()] := FALSE;
  2166. 1438 (*%E *)
  2167. 1439 END;
  2168. 1440 RETURN Ret;
  2169. 1441 END GetPos;
  2170. 1442
  2171. 1443
  2172. 1444 PROCEDURE Seek( F : File; pos:LONGCARD );
  2173. 1445 VAR Ret: LONGINT;
  2174. 1446 BEGIN
  2175. 1447 (*%T _mthread *)
  2176. 1448 SetIOR(0);
  2177. 1449 (*%E *)
  2178. 1450 (*%F _mthread *)
  2179. 1451 IOR := 0;
  2180. 1452 (*%E *)
  2181. 1453 (*%T _mthread *)
  2182. 1454 (*%F _OS2 *)
  2183. 1455 Process.Lock();
  2184. 1456 (*%E *)
  2185. 1457 (*%E *)
  2186. 1458 IF (F > CoreFile._open_max) OR (CoreFile.BufInf[F] = NIL) THEN
  2187. 1459 Ret := CoreIO.lseek(F, pos, CoreIO.SEEK_SET);
  2188. 1460 ELSE
  2189. 1461 (*%T _mthread *)
  2190. 1462 (*%T _OS2 *)
  2191. 1463 StreamLock(CoreFile.BufInf[F]);
  2192. 1464 (*%E *)
  2193. 1465 (*%E *)
  2194. 1466 WITH CoreFile.BufInf[F]^ DO
  2195. 1467 IF (Flag = {}) OR (Flag >= CoreIO._F_ERR) THEN
  2196. 1468 Ret := -1;
  2197. 1469 ELSE
  2198. 1470 IF (Flag >= CoreIO._F_OUT) THEN (* flush output buffer *)
  2199. 1471 IF FlsBuf(CoreFile.BufInf[F]) = -1 THEN
  2200. 1472 Ret := -1;
  2201. 1473 END;
  2202. 1474 END;
  2203. 1475 Pback := 0; (* reset buffer *)
  2204. 1476 Cnt := 0;
  2205. 1477 Flag := Flag + CoreIO._F_RST;
  2206. 1478 Ret := CoreIO.lseek(F, pos, CoreIO.SEEK_SET);
  2207. 1479 Flag := Flag - (CoreIO._F_IN + CoreIO._F_OUT +CoreIO._F_EOF +CoreIO._F_CTZ);
  2208. 1480 END;
  2209. 1481 END;
  2210. 1482 (*%T _mthread *)
  2211. 1483 (*%T _OS2 *)
  2212. 1484 StreamUnlock(CoreFile.BufInf[F]);
  2213. 1485 (*%E *)
  2214. 1486 (*%E *)
  2215. 1487 END;
  2216. 1488 CoreFile._openfd[F] := CoreFile._openfd[F] - (CoreIO._O_EOF);
  2217. 1489 (*%T _mthread *)
  2218. 1490 (*%F _OS2 *)
  2219. 1491 Process.Unlock();
  2220. 1492 (*%E *)
  2221. 1493 (*%E *)
  2222. 1494 IF Ret = -1 THEN
  2223. 1495 ErrorCheck(0AH, 0, 'Seek : ', Lib.NilStr);
  2224. 1496 END;
  2225. 1497 END Seek;
  2226. 1498
  2227. 1499
  2228. 1500 PROCEDURE Size(F: File) : LONGCARD;
  2229. 1501 VAR
  2230. 1502 Ret: LONGCARD;
  2231. 1503 CurPos: LONGCARD;
  2232. 1504 BEGIN
  2233. 1505 (*%T _mthread *)
  2234. 1506 Process.Lock();
  2235. 1507 (*%E *)
  2236. 1508 CurPos := GetPos(F);
  2237. 1509 IF NOT (*%T _mthread *) ThreadOK() (*%E *) (*%F _mthread *) OK (*%E *) THEN RETURN 0 END;
  2238. 1510 Ret := CoreIO.lseek(F, 0, CoreIO.SEEK_END);
  2239. 1511 Seek(F, CurPos);
  2240. 1512 (*%T _mthread *)
  2241. 1513 Process.Unlock();
  2242. 1514 (*%E *)
  2243. 1515 RETURN Ret;
  2244. 1516 END Size;
  2245. 1517
  2246. 1518
  2247. 1519 PROCEDURE Erase(Name:ARRAY OF CHAR);
  2248. 1520
  2249. 1521 VAR
  2250. 1522 fn : PathStr;
  2251. 1523 BEGIN
  2252. 1524 GetName(Name,fn);
  2253. 1525 IF(CoreIO.unlink(fn) = -1) THEN
  2254. 1526 ErrorCheck(0EH, 0, 'Erase : ', fn);
  2255. 1527 END;
  2256. 1528 END Erase;
  2257. 1529
  2258. 1530
  2259. 1531 PROCEDURE Rename(Name,newname: ARRAY OF CHAR);
  2260. 1532 VAR
  2261. 1533 fn: PathStr;
  2262. 1534 fn2: PathStr;
  2263. 1535 BEGIN
  2264. 1536 GetName(Name,fn);
  2265. 1537 GetName(newname,fn2);
  2266. 1538 IF(CoreIO.rename(fn, fn2) = -1) THEN
  2267. 1539 ErrorCheck(0FH, 0, 'Rename : ', fn);
  2268. 1540 END;
  2269. 1541 END Rename;
  2270. 1542
  2271. 1543 (*%F _OS2 *)
  2272. 1544 PROCEDURE ReadFirstEntry ( DirName : ARRAY OF CHAR;
  2273. 1545 Attr : FileAttr;
  2274. 1546 VAR D : DirEntry) : BOOLEAN;
  2275. 1547 VAR
  2276. 1548 r : SYSTEM.Registers;
  2277. 1549 fn : PathStr;
  2278. 1550 BEGIN
  2279. 1551 GetName(DirName,fn);
  2280. 1552 WITH r DO
  2281. 1553 AH := 1AH;
  2282. 1554 DS := Seg(D);
  2283. 1555 DX := Ofs(D);
  2284. 1556 Lib.Dos(r); (* set DTA *)
  2285. 1557 AH := 4EH;
  2286. 1558 DS := Seg(fn);
  2287. 1559 DX := Ofs(fn);
  2288. 1560 CL := SHORTCARD(Attr);
  2289. 1561 CH := SHORTCARD(0);
  2290. 1562 Lib.Dos(r);
  2291. 1563 IF (BITSET{SYSTEM.CarryFlag} * Flags) # BITSET{} THEN
  2292. 1564 IF (AX <> 18) THEN
  2293. 1565 ErrorCheck(14H, AX, 'ReadFirstEntry : ', DirName);
  2294. 1566 END;
  2295. 1567 RETURN FALSE;
  2296. 1568 END;
  2297. 1569 END;
  2298. 1570 RETURN TRUE;
  2299. 1571 END ReadFirstEntry;
  2300. 1572
  2301. 1573 PROCEDURE ReadNextEntry(VAR D: DirEntry) : BOOLEAN;
  2302. 1574 VAR
  2303. 1575 r : SYSTEM.Registers;
  2304. 1576 BEGIN
  2305. 1577 (*%T _mthread *)
  2306. 1578 SetIOR(0);
  2307. 1579 (*%E *)
  2308. 1580 (*%F _mthread *)
  2309. 1581 IOR := 0;
  2310. 1582 (*%E *)
  2311. 1583 WITH r DO
  2312. 1584 AH := 1AH;
  2313. 1585 DS := Seg(D);
  2314. 1586 DX := Ofs(D);
  2315. 1587 Lib.Dos(r); (* set DTA *)
  2316. 1588 AH := 4FH;
  2317. 1589 Lib.Dos(r);
  2318. 1590 IF (BITSET{SYSTEM.CarryFlag} * Flags) # BITSET{} THEN
  2319. 1591 IF (AX <> 18) THEN
  2320. 1592 ErrorCheck(15H, AX, 'ReadNextEntry : ', Lib.NilStr);
  2321. 1593 END;
  2322. 1594 RETURN FALSE;
  2323. 1595 END;
  2324. 1596 END;
  2325. 1597 RETURN TRUE;
  2326. 1598 END ReadNextEntry;
  2327. 1599 (*%E *)
  2328. 1600
  2329. 1601 (*%T _OS2 *)
  2330. 1602 CONST
  2331. 1603 GuardHandle = MAX(CARDINAL)-1;
  2332. 1604
  2333. 1605 PROCEDURE CopyResult(VAR D: DirEntry; VAR d: Dos.FILEFINDBUF);
  2334. 1606
  2335. 1607 BEGIN
  2336. 1608 D.attr:=FileAttr(d.attrFile);
  2337. 1609 D.time:=d.ftimeCreation;
  2338. 1610 D.date:=d.fdateCreation;
  2339. 1611 D.size:=d.fileSize;
  2340. 1612 Str.Copy(D.Name, d.name);
  2341. 1613 END CopyResult;
  2342. 1614
  2343. 1615
  2344. 1616 PROCEDURE ReadFirstEntry ( DirName : ARRAY OF CHAR;
  2345. 1617 Attr : FileAttr;
  2346. 1618 VAR D : DirEntry) : BOOLEAN;
  2347. 1619
  2348. 1620 PROCEDURE WildInName(): BOOLEAN;
  2349. 1621 BEGIN
  2350. 1622 RETURN (Str.CharPos(DirName, '*') # MAX(CARDINAL))
  2351. 1623 OR (Str.CharPos(DirName, '?') # MAX(CARDINAL));
  2352. 1624 END WildInName;
  2353. 1625
  2354. 1626 VAR
  2355. 1627 b : Dos.FILEFINDBUF;
  2356. 1628 fn : PathStr;
  2357. 1629 status: CARDINAL;
  2358. 1630 Handle, Count: CARDINAL;
  2359. 1631 BEGIN
  2360. 1632 GetName(DirName,fn);
  2361. 1633 Handle:=MAX(CARDINAL);
  2362. 1634 Count:=1;
  2363. 1635 status:=FindFirst(fn, Handle, CARDINAL(SHORTCARD(Attr)), b, SIZE(b), Count, LONGCARD(0));
  2364. 1636 IF status # 0 THEN
  2365. 1637 IF status <> Err.ERROR_NO_MORE_FILES THEN
  2366. 1638 ErrorCheck(14H, status, 'ReadFirstEntry : ', fn);
  2367. 1639 END;
  2368. 1640 RETURN FALSE;
  2369. 1641 END;
  2370. 1642 IF WildInName() THEN
  2371. 1643 D.Reserved_Handle:=Handle;
  2372. 1644 ELSE
  2373. 1645 D.Reserved_Handle:=GuardHandle;
  2374. 1646 Dos.FindClose(Handle);
  2375. 1647 END;
  2376. 1648 CopyResult(D, b);
  2377. 1649 RETURN TRUE;
  2378. 1650 END ReadFirstEntry;
  2379. 1651
  2380. 1652 PROCEDURE ReadNextEntry(VAR D: DirEntry) : BOOLEAN;
  2381. 1653
  2382. 1654 VAR
  2383. 1655 b : Dos.FILEFINDBUF;
  2384. 1656 status: CARDINAL;
  2385. 1657 Handle, Count: CARDINAL;
  2386. 1658 BEGIN
  2387. 1659 Handle:=(D.Reserved_Handle);
  2388. 1660 (*%T _mthread *)
  2389. 1661 SetIOR(0);
  2390. 1662 (*%E *)
  2391. 1663 (*%F _mthread *)
  2392. 1664 IOR := 0;
  2393. 1665 (*%E *)
  2394. 1666 IF Handle = GuardHandle THEN
  2395. 1667 RETURN FALSE;
  2396. 1668 END;
  2397. 1669 Count:=1;
  2398. 1670 status:=FindNext(Handle, b, SIZE(b), Count);
  2399. 1671 IF status # 0 THEN
  2400. 1672 Dos.FindClose(Handle);
  2401. 1673 IF status <> Err.ERROR_NO_MORE_FILES THEN
  2402. 1674 ErrorCheck(15H, status, 'ReadNextEntry : ', Lib.NilStr);
  2403. 1675 END;
  2404. 1676 RETURN FALSE;
  2405. 1677 END;
  2406. 1678 CopyResult(D, b);
  2407. 1679 RETURN TRUE;
  2408. 1680 END ReadNextEntry;
  2409. 1681 (*%E *)
  2410. 1682
  2411. 1683 PROCEDURE ChDir(Name: ARRAY OF CHAR);
  2412. 1684 VAR
  2413. 1685 fn : PathStr;
  2414. 1686 BEGIN
  2415. 1687 (*%T _mthread *)
  2416. 1688 SetIOR(0);
  2417. 1689 (*%E *)
  2418. 1690 (*%F _mthread *)
  2419. 1691 IOR := 0;
  2420. 1692 (*%E *)
  2421. 1693 GetName(Name,fn);
  2422. 1694 IF CoreIO.chdir(fn) = -1 THEN
  2423. 1695 ErrorCheck(10H, 0, 'ChDir : ', Name);
  2424. 1696 RETURN;
  2425. 1697 END;
  2426. 1698 IF (Str.Length(Name) > 1) AND (Name[1] = ':') THEN
  2427. 1699 IF SetDrive(SHORTCARD(CAP(Name[0]) - 'A') + 1) = 0 THEN
  2428. 1700 ErrorCheck(10H, 0, 'ChDir : ', Name);
  2429. 1701 END;
  2430. 1702 END;
  2431. 1703 END ChDir;
  2432. 1704
  2433. 1705 PROCEDURE MkDir(Name: ARRAY OF CHAR);
  2434. 1706 VAR
  2435. 1707 fn : PathStr;
  2436. 1708 BEGIN
  2437. 1709 (*%T _mthread *)
  2438. 1710 SetIOR(0);
  2439. 1711 (*%E *)
  2440. 1712 (*%F _mthread *)
  2441. 1713 IOR := 0;
  2442. 1714 (*%E *)
  2443. 1715 GetName(Name,fn);
  2444. 1716 IF CoreIO.mkdir(fn) = -1 THEN
  2445. 1717 ErrorCheck(11H, 0, 'MkDir : ', Name);
  2446. 1718 END;
  2447. 1719 END MkDir;
  2448. 1720
  2449. 1721 PROCEDURE RmDir(Name: ARRAY OF CHAR);
  2450. 1722 VAR
  2451. 1723 fn : PathStr;
  2452. 1724 BEGIN
  2453. 1725 (*%T _mthread *)
  2454. 1726 SetIOR(0);
  2455. 1727 (*%E *)
  2456. 1728 (*%F _mthread *)
  2457. 1729 IOR := 0;
  2458. 1730 (*%E *)
  2459. 1731 GetName(Name,fn);
  2460. 1732 IF CoreIO.rmdir(fn) = -1 THEN
  2461. 1733 ErrorCheck(12H, 0, 'RmDir : ', Name);
  2462. 1734 END;
  2463. 1735 END RmDir;
  2464. 1736
  2465. 1737 PROCEDURE GetDir(drive: SHORTCARD; VAR Name: ARRAY OF CHAR);
  2466. 1738 VAR
  2467. 1739 fn : PathStr;
  2468. 1740 BEGIN
  2469. 1741 (*%T _mthread *)
  2470. 1742 SetIOR(0);
  2471. 1743 (*%E *)
  2472. 1744 (*%F _mthread *)
  2473. 1745 IOR := 0;
  2474. 1746 (*%E *)
  2475. 1747 IF CoreIO.getcurdir(CARDINAL(drive), fn) = -1 THEN
  2476. 1748 ErrorCheck(13H, 0, 'GetDir : ', Lib.NilStr);
  2477. 1749 END;
  2478. 1750 Str.Concat(Name,'\',fn);
  2479. 1751 END GetDir;
  2480. 1752
  2481. 1753 PROCEDURE AssignBuffer(F:File;VAR Buf:ARRAY OF BYTE);
  2482. 1754
  2483. 1755 PROCEDURE FindFreeStream():FileInf;
  2484. 1756 VAR
  2485. 1757 n : CARDINAL;
  2486. 1758 BEGIN
  2487. 1759 n := 0;
  2488. 1760 (*%T _mthread *)
  2489. 1761 Process.Lock();
  2490. 1762 (*%E *)
  2491. 1763 WHILE n < CoreFile._open_max DO
  2492. 1764 IF CoreFile._iob[n].Flag = {} THEN
  2493. 1765 (*%T _mthread *)
  2494. 1766 Process.Unlock();
  2495. 1767 (*%E *)
  2496. 1768 RETURN FileInf(ADR(CoreFile._iob[n]));
  2497. 1769 END; (*IF*)
  2498. 1770 INC(n);
  2499. 1771 END; (*WHILE*)
  2500. 1772 (*%T _mthread *)
  2501. 1773 Process.Unlock();
  2502. 1774 (*%E *)
  2503. 1775 RETURN NIL;
  2504. 1776 END FindFreeStream;
  2505. 1777
  2506. 1778 BEGIN
  2507. 1779 (*%T _mthread *)
  2508. 1780 SetIOR(0);
  2509. 1781 (*%E *)
  2510. 1782 (*%F _mthread *)
  2511. 1783 IOR := 0;
  2512. 1784 (*%E *)
  2513. 1785 IF (F > CoreFile._open_max) (*%F _WINDOWS *) OR (CoreFile._openfd[F] = {}) (*%E *) THEN
  2514. 1786 ErrorCheck(19H,CoreIO.EBADF,'AssignBuffer : ',Lib.NilStr);
  2515. 1787 RETURN;
  2516. 1788 END; (*IF*)
  2517. 1789 IF (HIGH(Buf) = 0) OR (HIGH(Buf) > MAX(INTEGER)) THEN
  2518. 1790 ErrorCheck(1AH,CoreIO.EINVAL,'AssignBuffer : ',Lib.NilStr);
  2519. 1791 RETURN;
  2520. 1792 END; (*IF*)
  2521. 1793 (*%T _WINDOWS *)
  2522. 1794 IF (CoreFile._openfd[F] = {}) THEN
  2523. 1795 CoreFile._openfd[F] := (CoreIO.O_RDWR + CoreIO.O_BINARY);
  2524. 1796 END; (*IF*)
  2525. 1797 (*%E *)
  2526. 1798 IF CoreFile.BufInf[F] # NIL THEN
  2527. 1799 RETURN;
  2528. 1800 END; (*IF*)
  2529. 1801 CoreFile.BufInf[F] := FindFreeStream();
  2530. 1802 IF CoreFile.BufInf[F] = NIL THEN
  2531. 1803 ErrorCheck(1BH,CoreIO.EMFILE,'AssignBuffer : ',Lib.NilStr);
  2532. 1804 RETURN;
  2533. 1805 END; (*IF*)
  2534. 1806 WITH CoreFile.BufInf[F]^ DO
  2535. 1807 Ptr := CoreFile.StreamPtr(ADR(Buf));
  2536. 1808 Base := Ptr;
  2537. 1809 Size := HIGH(Buf) + 1;
  2538. 1810 Cnt := 0;
  2539. 1811 Pback := 0;
  2540. 1812 Handle := F;
  2541. 1813 IF (CoreFile._openfd[F] >= CoreIO.O_DEVICE) THEN
  2542. 1814 Flag := CoreIO._F_DEV;
  2543. 1815 ELSE
  2544. 1816 Flag := {};
  2545. 1817 END; (*IF*)
  2546. 1818 IF (CoreFile._openfd[F] * CoreIO.O_RDWR # {}) OR (CoreFile._openfd[F] * CoreIO.O_WRONLY # {}) THEN
  2547. 1819 Flag := Flag + CoreIO._F_RDWR;
  2548. 1820 ELSE
  2549. 1821 Flag := Flag + CoreIO._F_READ;
  2550. 1822 END; (*IF*)
  2551. 1823 IF CoreFile._openfd[F] >= CoreIO.O_APPEND THEN
  2552. 1824 Flag := Flag + CoreIO._F_APP;
  2553. 1825 END; (*IF*)
  2554. 1826 Flag := Flag + (CoreIO._F_BIN + CoreIO._F_UBUF + CoreIO._F_RST);
  2555. 1827 END; (*WITH*)
  2556. 1828 END AssignBuffer;
  2557. 1829
  2558. 1830 PROCEDURE AppendHandle(F: File; ReadOnly: BOOLEAN);
  2559. 1831
  2560. 1832 BEGIN
  2561. 1833 IF F < CoreFile._open_max THEN
  2562. 1834 IF ReadOnly THEN
  2563. 1835 CoreFile._openfd[F] := (CoreIO.O_RDONLY+CoreIO.O_BINARY);
  2564. 1836 ELSE
  2565. 1837 CoreFile._openfd[F] := (CoreIO.O_RDWR+CoreIO.O_BINARY);
  2566. 1838 END;
  2567. 1839 IF CoreIO.isatty(F) # 0 THEN
  2568. 1840 CoreFile._openfd[F] := CoreFile._openfd[F] + CoreIO.O_DEVICE;
  2569. 1841 END;
  2570. 1842 END;
  2571. 1843 END AppendHandle;
  2572. 1844
  2573. 1845
  2574. 1846 PROCEDURE AppendStream(St: FileInf): File;
  2575. 1847
  2576. 1848 VAR
  2577. 1849 F: File;
  2578. 1850 BEGIN
  2579. 1851 F := St^.Handle;
  2580. 1852 CoreFile.BufInf[F] := St;
  2581. 1853 RETURN F;
  2582. 1854 END AppendStream;
  2583. 1855
  2584. 1856 PROCEDURE GetStreamPointer(F: File): FileInf;
  2585. 1857
  2586. 1858 BEGIN
  2587. 1859 RETURN CoreFile.BufInf[F];
  2588. 1860 END GetStreamPointer;
  2589. 1861
  2590. 1862 (*%F _OS2 *)
  2591. 1863 PROCEDURE GetDrive() : SHORTCARD ;
  2592. 1864
  2593. 1865 (* Returns the currently selected drive *)
  2594. 1866 (* A=1,B=2,C=3 etc *)
  2595. 1867
  2596. 1868 VAR
  2597. 1869 r : SYSTEM.Registers;
  2598. 1870 BEGIN
  2599. 1871 (*%T _mthread *)
  2600. 1872 SetIOR(0);
  2601. 1873 (*%E *)
  2602. 1874 (*%F _mthread *)
  2603. 1875 IOR := 0;
  2604. 1876 (*%E *)
  2605. 1877 r.AH := 19H ;
  2606. 1878 Lib.Dos(r);
  2607. 1879 RETURN r.AL+1 ;
  2608. 1880 END GetDrive ;
  2609. 1881
  2610. 1882 PROCEDURE SetDrive(Drive: SHORTCARD): SHORTCARD;
  2611. 1883
  2612. 1884 (* Sets the default drive *)
  2613. 1885 (* A=1,B=2,C=3 etc *)
  2614. 1886
  2615. 1887 VAR
  2616. 1888 r : SYSTEM.Registers;
  2617. 1889 BEGIN
  2618. 1890 (*%T _mthread *)
  2619. 1891 SetIOR(0);
  2620. 1892 (*%E *)
  2621. 1893 (*%F _mthread *)
  2622. 1894 IOR := 0;
  2623. 1895 (*%E *)
  2624. 1896 r.AH := 0EH ;
  2625. 1897 r.DL := Drive-1;
  2626. 1898 Lib.Dos(r);
  2627. 1899 RETURN r.AL;
  2628. 1900 END SetDrive ;
  2629. 1901
  2630. 1902 PROCEDURE GetCurrentDate () : LONGCARD ;
  2631. 1903 VAR r : SYSTEM.Registers;
  2632. 1904 l : RECORD
  2633. 1905 CASE : BOOLEAN OF
  2634. 1906 TRUE : fl,fh : CARDINAL; |
  2635. 1907 FALSE : l : LONGCARD;
  2636. 1908 END;
  2637. 1909 END;
  2638. 1910 BEGIN
  2639. 1911 WITH r DO
  2640. 1912 AH := 2CH;
  2641. 1913 Lib.Dos(r);
  2642. 1914 l.fl := (VAL(CARDINAL,CH) << 11)+(VAL(CARDINAL,CL) << 5)+(VAL(CARDINAL,DH)>>1);
  2643. 1915 AH := 2AH ;
  2644. 1916 Lib.Dos(r);
  2645. 1917 l.fh := ((CX-1980)<< 9)+(VAL(CARDINAL,DH)<<5)+VAL(CARDINAL,DL);
  2646. 1918 END;
  2647. 1919 RETURN l.l;
  2648. 1920 END GetCurrentDate ;
  2649. 1921
  2650. 1922 PROCEDURE GetFileDate( f : File) : LONGCARD;
  2651. 1923 VAR r : SYSTEM.Registers;
  2652. 1924 l : RECORD
  2653. 1925 CASE : BOOLEAN OF
  2654. 1926 TRUE : fl,fh : CARDINAL; |
  2655. 1927 FALSE : l : LONGCARD;
  2656. 1928 END;
  2657. 1929 END;
  2658. 1930 BEGIN
  2659. 1931 WITH r DO
  2660. 1932 AX := 5700H;
  2661. 1933 BX := f;
  2662. 1934 Lib.Dos(r);
  2663. 1935 l.fl := CX;
  2664. 1936 l.fh := DX;
  2665. 1937 END;
  2666. 1938 RETURN l.l;
  2667. 1939 END GetFileDate;
  2668. 1940
  2669. 1941 PROCEDURE SetFileDate( f : File ; d : LONGCARD ) ;
  2670. 1942 VAR r : SYSTEM.Registers;
  2671. 1943 l : RECORD
  2672. 1944 CASE : BOOLEAN OF
  2673. 1945 TRUE : fl,fh : CARDINAL; |
  2674. 1946 FALSE : l : LONGCARD;
  2675. 1947 END;
  2676. 1948 END;
  2677. 1949 BEGIN
  2678. 1950 WITH r DO
  2679. 1951 l.l := d ;
  2680. 1952 AX := 5701H;
  2681. 1953 BX := f;
  2682. 1954 CX := l.fl ;
  2683. 1955 DX := l.fh ;
  2684. 1956 Lib.Dos(r);
  2685. 1957 END;
  2686. 1958 END SetFileDate;
  2687. 1959 (*%E *)
  2688. 1960
  2689. 1961 (*%T _OS2 *)
  2690. 1962 PROCEDURE GetDrive() : SHORTCARD ;
  2691. 1963
  2692. 1964 (* Returns the currently selected drive *)
  2693. 1965 (* A=1,B=2,C=3 etc *)
  2694. 1966
  2695. 1967 VAR
  2696. 1968 Dr : CARDINAL;
  2697. 1969 BitMap: LONGCARD;
  2698. 1970 BEGIN
  2699. 1971 SYSTEM.Eval(QCurDisk(Dr, BitMap));
  2700. 1972 RETURN SHORTCARD(Dr);
  2701. 1973 END GetDrive ;
  2702. 1974
  2703. 1975 PROCEDURE SetDrive(Drive: SHORTCARD): SHORTCARD;
  2704. 1976
  2705. 1977 (* Sets the default drive *)
  2706. 1978 (* A=1,B=2,C=3 etc *)
  2707. 1979
  2708. 1980 BEGIN
  2709. 1981 SYSTEM.Eval(Dos.SelectDisk(CARDINAL(Drive)));
  2710. 1982 RETURN MAX(SHORTCARD);
  2711. 1983 END SetDrive ;
  2712. 1984
  2713. 1985 PROCEDURE GetCurrentDate () : LONGCARD ;
  2714. 1986
  2715. 1987 VAR
  2716. 1988 l : RECORD
  2717. 1989 CASE : BOOLEAN OF
  2718. 1990 TRUE : fl,fh : CARDINAL; |
  2719. 1991 FALSE : l : LONGCARD;
  2720. 1992 END;
  2721. 1993 END;
  2722. 1994 Info: Dos.DATETIME;
  2723. 1995 BEGIN
  2724. 1996 SYSTEM.Eval(Dos.GetDateTime(Info));
  2725. 1997 l.fl := (CARDINAL(Info.hours) << 11)+(CARDINAL(Info.minutes) << 5)+(CARDINAL(Info.seconds)>>1);
  2726. 1998 l.fh := ((Info.year-1980)<< 9)+(CARDINAL(Info.month)<<5)+CARDINAL(Info.day);
  2727. 1999 RETURN l.l;
  2728. 2000 END GetCurrentDate ;
  2729. 2001
  2730. 2002 TYPE
  2731. 2003 FileInfo = RECORD
  2732. 2004 CDate, CTime, ADate, ATime, WDate, WTime: CARDINAL;
  2733. 2005 CBFile, CGFileA: LONGCARD;
  2734. 2006 Attr: SHORTCARD;
  2735. 2007 cchName: SHORTCARD;
  2736. 2008 achName: ARRAY [0..12] OF CHAR;
  2737. 2009 END;
  2738. 2010 DT = RECORD
  2739. 2011 CASE : BOOLEAN OF
  2740. 2012 TRUE : fl,fh : CARDINAL; |
  2741. 2013 FALSE : l : LONGCARD;
  2742. 2014 END;
  2743. 2015 END;
  2744. 2016
  2745. 2017 PROCEDURE GetFileDate( f : File) : LONGCARD;
  2746. 2018
  2747. 2019 VAR
  2748. 2020 Buffer: FileInfo;
  2749. 2021 T: DT;
  2750. 2022 BEGIN
  2751. 2023 IF Dos.QFileInfo(f, CARDINAL(1), FarADR(Buffer), SIZE(Buffer)) # 0 THEN
  2752. 2024 RETURN MAX(LONGCARD);
  2753. 2025 END;
  2754. 2026 T.fh := Buffer.WDate;
  2755. 2027 T.fl := Buffer.WTime;
  2756. 2028 RETURN T.l;
  2757. 2029 END GetFileDate;
  2758. 2030
  2759. 2031 PROCEDURE SetFileDate( f : File ; d : LONGCARD ) ;
  2760. 2032
  2761. 2033 VAR
  2762. 2034 Buffer: FileInfo;
  2763. 2035 T: DT;
  2764. 2036 BEGIN
  2765. 2037 IF Dos.QFileInfo(f, CARDINAL(1), FarADR(Buffer), SIZE(Buffer)) # 0 THEN RETURN END;
  2766. 2038 T.l:= d;
  2767. 2039 Buffer.WDate := T.fh;
  2768. 2040 Buffer.WTime := T.fl;
  2769. 2041 IF Dos.SetFileInfo(f, CARDINAL(1), FarADR(Buffer), SIZE(Buffer)) # 0 THEN END;
  2770. 2042 END SetFileDate;
  2771. 2043 (*%E *)
  2772. 2044
  2773. 2045 PROCEDURE ThreadEOF(): BOOLEAN;
  2774. 2046
  2775. 2047 BEGIN
  2776. 2048 (*%T _mthread *)
  2777. 2049 RETURN EOFTable[CoreProc._getTID()];
  2778. 2050 (*%E *)
  2779. 2051 (*%F _mthread *)
  2780. 2052 RETURN EOF;
  2781. 2053 (*%E *)
  2782. 2054 END ThreadEOF;
  2783. 2055
  2784. 2056 PROCEDURE ThreadOK(): BOOLEAN;
  2785. 2057
  2786. 2058 BEGIN
  2787. 2059 (*%T _mthread *)
  2788. 2060 RETURN OKTable[CoreProc._getTID()];
  2789. 2061 (*%E *)
  2790. 2062 (*%F _mthread *)
  2791. 2063 RETURN OK;
  2792. 2064 (*%E *)
  2793. 2065 END ThreadOK;
  2794. 2066
  2795. 2067 PROCEDURE GetFileStamp(f : File ; VAR b: FileStamp) : BOOLEAN;
  2796. 2068
  2797. 2069 VAR
  2798. 2070 DT : RECORD
  2799. 2071 CASE : BOOLEAN OF
  2800. 2072 TRUE : ft,fd : CARDINAL; |
  2801. 2073 FALSE : l : LONGCARD;
  2802. 2074 END;
  2803. 2075 END;
  2804. 2076 BEGIN
  2805. 2077 DT.l := GetFileDate(f);
  2806. 2078 IF DT.l = MAX(LONGCARD) THEN
  2807. 2079 RETURN FALSE;
  2808. 2080 ELSE
  2809. 2081 b.Year := SHORTCARD(DT.fd>>9+80) ;
  2810. 2082 b.Month := SHORTCARD((DT.fd>>5) MOD 16) ;
  2811. 2083 b.Day := SHORTCARD(DT.fd MOD 32) ;
  2812. 2084 b.Hour := SHORTCARD(DT.ft>>11) ;
  2813. 2085 b.Min := SHORTCARD((DT.ft>>5) MOD 64) ;
  2814. 2086 b.Sec := SHORTCARD(DT.ft MOD 32) ;
  2815. 2087 RETURN TRUE;
  2816. 2088 END;
  2817. 2089 END GetFileStamp;
  2818. 2090
  2819. 2091 (*# save,call(c_conv=>on) *)
  2820. 2092 PROCEDURE Cleanup();
  2821. 2093 VAR
  2822. 2094 n : CARDINAL;
  2823. 2095 BEGIN
  2824. 2096 FOR n := 0 TO CoreFile._open_max - 1 DO
  2825. 2097 IF CoreFile._iob[n].Flag # {} THEN
  2826. 2098 CoreFile.BufInf[n] := ADR(CoreFile._iob[n]);
  2827. 2099 Flush(n);
  2828. 2100 END; (*IF*)
  2829. 2101 END; (*FOR*)
  2830. 2102 END Cleanup;
  2831. 2103 (*# restore *)
  2832. 2104
  2833. 2105 (*%T _mthread *)
  2834. 2106 VAR
  2835. 2107 n : [1..Process.MaxProcess];
  2836. 2108 (*%E *)
  2837. 2109 BEGIN
  2838. 2110 (*%T _mthread *)
  2839. 2111 n := 1;
  2840. 2112 WHILE n <= Process.MaxProcess DO
  2841. 2113 IOR[n] := 0;
  2842. 2114 EOFTable[n] := FALSE;
  2843. 2115 OKTable[n] := TRUE;
  2844. 2116 INC(n);
  2845. 2117 END;
  2846. 2118 (*%E *)
  2847. 2119 (*%F _mthread *)
  2848. 2120 IOR := 0;
  2849. 2121 (*%E *)
  2850. 2122 Eng := FALSE;
  2851. 2123 IOcheck := TRUE;
  2852. 2124 OK := TRUE;
  2853. 2125 ChopOff := FALSE;
  2854. 2126 EOF := FALSE;
  2855. 2127 EOL := CHR (10);
  2856. 2128 PrefixChar := ' ';
  2857. 2129 SuffixChar := ' ';
  2858. 2130 ShareMode := ShareCompat;
  2859. 2131 Separators := Str.CHARSET{CHR(9),CHR(10),CHR(13),CHR(26),' '};
  2860. 2132 CoreFile.BufInf[StandardInput] := ADR(CoreFile._iob[StandardInput]);
  2861. 2133 CoreFile.BufInf[StandardOutput] := ADR(CoreFile._iob[StandardOutput]);
  2862. 2134 CoreMain._exit_io := Cleanup;
  2863. 2135 END FIO.
  2864. 2136
  2865. 727 errors