tdos2.pp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. {******************************************}
  2. { Used to check the DOS unit }
  3. {------------------------------------------}
  4. { Requirements for this unit can be }
  5. { found in testdos.htm }
  6. {******************************************}
  7. Program TestDos;
  8. Uses Dos;
  9. {**********************************************************************}
  10. { Some specific OS verifications : }
  11. { Mainly for file attributes: }
  12. { Read-Only }
  13. { Hidden }
  14. { System File }
  15. { only work on Win32, OS/2 and DOS }
  16. {$IFDEF MSDOS}
  17. {$DEFINE EXTATTR}
  18. {$ENDIF}
  19. {$IFDEF DPMI}
  20. {$DEFINE EXTATTR}
  21. {$ENDIF}
  22. {$IFDEF GO32V1}
  23. {$DEFINE EXTATTR}
  24. {$ENDIF}
  25. {$IFDEF GO32V2}
  26. {$DEFINE EXTATTR}
  27. {$ENDIF}
  28. {$IFDEF OS2}
  29. {$DEFINE EXTATTR}
  30. {$ENDIF}
  31. {$IFDEF WIN32}
  32. {$DEFINE EXTATTR}
  33. {$ENDIF}
  34. {$IFDEF ATARI}
  35. {$DEFINE EXTATTR}
  36. {$ENDIF}
  37. {$IFDEF WINCE}
  38. {$DEFINE EXTATTR}
  39. {$ENDIF}
  40. {$IFNDEF UNIX}
  41. {$IFDEF LINUX}
  42. {$DEFINE UNIX}
  43. {$ENDIF}
  44. {$IFDEF QNX}
  45. {$DEFINE UNIX}
  46. {$ENDIF}
  47. {$IFDEF SOLARIS}
  48. {$DEFINE UNIX}
  49. {$ENDIF}
  50. {$IFDEF FREEBSD}
  51. {$DEFINE UNIX}
  52. {$ENDIF}
  53. {$IFDEF BEOS}
  54. {$DEFINE UNIX}
  55. {$ENDIF}
  56. {$ENDIF}
  57. {**********************************************************************}
  58. CONST
  59. { what is the root path }
  60. {$ifdef UNIX}
  61. RootPath = '/';
  62. {$else UNIX}
  63. {$ifdef WINCE}
  64. RootPath = '\';
  65. {$else WINCE}
  66. RootPath = 'C:\';
  67. {$endif WINCE}
  68. {$ENDIF}
  69. Week:Array[0..6] of String =
  70. ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  71. TestFName = 'TESTDOS.DAT'; { CASE SENSITIVE DON'T TOUCH! }
  72. TestFName1 = 'TESTFILE'; { CASE SENSITIVE DON'T TOUCH! }
  73. TestDir = 'MYDIR'; { CASE SENSITIVE DON'T TOUCH! }
  74. TestExt = 'DAT';
  75. has_errors : boolean = false;
  76. Procedure PauseScreen;
  77. var
  78. ch: char;
  79. Begin
  80. { this is the non-interacting version
  81. so we disable this
  82. WriteLn('-- Press any key --');
  83. ReadLn;}
  84. end;
  85. { verifies that the DOSError variable is equal to }
  86. { the value requested. }
  87. Procedure CheckDosError(err: Integer);
  88. var
  89. x : integer;
  90. s :string;
  91. Begin
  92. Write('Verifying value of DOS Error...');
  93. x := DosError;
  94. case x of
  95. 0 : s := '(0): No Error.';
  96. 2 : s := '(2): File not found.';
  97. 3 : s := '(3): Path not found.';
  98. 5 : s := '(5): Access Denied.';
  99. 6 : s := '(6): Invalid File Handle.';
  100. 8 : s := '(8): Not enough memory.';
  101. 10 : s := '(10) : Invalid Environment.';
  102. 11 : s := '(11) : Invalid format.';
  103. 18 : s := '(18) : No more files.';
  104. else
  105. s := 'INVALID DOSERROR';
  106. end;
  107. if err <> x then
  108. Begin
  109. WriteLn('FAILURE. (Value should be ',err,' '+s+')');
  110. has_errors:=true;
  111. end
  112. else
  113. WriteLn('Success.');
  114. end;
  115. Procedure TestSystemDate;
  116. var
  117. Year,Month, DayOfWeek, Day: Word;
  118. Year1,Month1, DayOfWeek1, Day1: Word;
  119. s: string;
  120. Begin
  121. WriteLn('----------------------------------------------------------------------');
  122. WriteLn(' GETDATE ');
  123. WriteLn('----------------------------------------------------------------------');
  124. WriteLn(' Note: Number of week should be consistent (0 = Sunday) ');
  125. WriteLn(' Note: Year should contain full four digits. ');
  126. WriteLn('----------------------------------------------------------------------');
  127. CheckDosError(0);
  128. Month:=0;
  129. Day:=0;
  130. DayOfWeek:=0;
  131. Year:=0;
  132. GetDate(Year,Month,Day,DayOfWeek);
  133. CheckDosError(0);
  134. Write('DD-MM-YYYY : ',Day,'-',Month,'-',Year);
  135. WriteLn(' (',Week[DayOfWeek],')');
  136. PauseScreen;
  137. WriteLn('----------------------------------------------------------------------');
  138. WriteLn(' SETDATE ');
  139. WriteLn('----------------------------------------------------------------------');
  140. { normal call }
  141. SetDate(Year,Month,Day);
  142. CheckDosError(0);
  143. { setdate and settime is not supported on most platforms }
  144. {$ifdef go32v2}
  145. s:='Testing with invalid year....';
  146. SetDate(98,Month,Day);
  147. CheckDosError(0);
  148. GetDate(Year1,Month1,Day1,DayOfWeek1);
  149. CheckDosError(0);
  150. if (Year1 <> Year) or (Month1 <> month) or (Day1 <> Day) then
  151. Begin
  152. WriteLn(s+'FAILURE.');
  153. end
  154. else
  155. WriteLn(s+'Success.');
  156. SetDate(Year,Month,255);
  157. CheckDosError(0);
  158. s:='Testing with invalid day.....';
  159. GetDate(Year1,Month1,Day1,DayOfWeek1);
  160. CheckDosError(0);
  161. if (Year1 <> Year) or (Month1 <> month) or (Day1 <> Day) then
  162. Begin
  163. WriteLn(s+'FAILURE.');
  164. end
  165. else
  166. WriteLn(s+'Success.');
  167. SetDate(Year,13,Day);
  168. CheckDosError(0);
  169. s:='Testing with invalid month...';
  170. GetDate(Year1,Month1,Day1,DayOfWeek1);
  171. CheckDosError(0);
  172. if (Year1 <> Year) or (Month1 <> month) or (Day1 <> Day) then
  173. Begin
  174. WriteLn(s+'FAILURE.');
  175. end
  176. else
  177. WriteLn(s+'Success.');
  178. WriteLn('----------------------------------------------------------------------');
  179. WriteLn(' Note: Date should be 01-01-1998 ');
  180. WriteLn('----------------------------------------------------------------------');
  181. SetDate(1998,01,01);
  182. CheckDosError(0);
  183. GetDate(Year1,Month1,Day1,DayOfWeek1);
  184. CheckDosError(0);
  185. WriteLn('DD-MM-YYYY : ',Day1,'-',Month1,'-',Year1);
  186. SetDate(Year,Month,Day);
  187. CheckDosError(0);
  188. WriteLn('----------------------------------------------------------------------');
  189. WriteLn(' Note: Date should be restored to previous value ');
  190. WriteLn('----------------------------------------------------------------------');
  191. GetDate(Year1,Month1,Day1,DayOfWeek1);
  192. CheckDosError(0);
  193. WriteLn('DD-MM-YYYY : ',Day1,'-',Month1,'-',Year1);
  194. PauseScreen;
  195. {$endif}
  196. end;
  197. Procedure TestsystemTime;
  198. Var
  199. Hour, Minute, Second, Sec100: word;
  200. Hour1, Minute1, Second1, Sec1001: word;
  201. Begin
  202. WriteLn('----------------------------------------------------------------------');
  203. WriteLn(' GETTIME ');
  204. WriteLn('----------------------------------------------------------------------');
  205. WriteLn(' Note: Hours should be in military format (0..23), and MSec in 0..100 ');
  206. WriteLn('----------------------------------------------------------------------');
  207. CheckDosError(0);
  208. Hour:=0;
  209. Minute:=0;
  210. Second:=0;
  211. Sec100:=0;
  212. GetTime(Hour,Minute,Second,Sec100);
  213. CheckDosError(0);
  214. WriteLn('HH:MIN:SEC (MS): ',Hour,':',Minute,':',Second,' (',Sec100,')');
  215. WriteLn('----------------------------------------------------------------------');
  216. WriteLn(' SETTIME ');
  217. WriteLn('----------------------------------------------------------------------');
  218. WriteLn(' Note: GetTime should return the same value as the previous test. ');
  219. WriteLn('----------------------------------------------------------------------');
  220. {$ifndef beos}
  221. {This should be disabled under BeOS : maybe this is a BeOS bug (or a feature ?)
  222. in stime function.
  223. When you set 36 hours, the time AND the date are changed
  224. It seems it is a valid value under BeOS, but you have jump in the future :
  225. 36 hours in the future from the begining of the starting day, more or less
  226. depending on your timezone.
  227. For example in Paris, in summer (2 hours from GMT time zone),
  228. this call set the clock to 14:<Minute>:<Second>:<Sec100> the next day !}
  229. SetTime(36,Minute,Second,Sec100);
  230. CheckDosError(0);
  231. {$endif}
  232. GetTime(Hour1,Minute1,Second1,Sec1001);
  233. CheckDosError(0);
  234. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  235. { actual settime is only supported under DOS }
  236. {$ifdef go32v2}
  237. SetTime(Hour,32000,Second,Sec100);
  238. CheckDosError(0);
  239. GetTime(Hour1,Minute1,Second1,Sec1001);
  240. CheckDosError(0);
  241. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  242. WriteLn('----------------------------------------------------------------------');
  243. WriteLn(' Note: GetTime should return 0:0:0 ');
  244. WriteLn('----------------------------------------------------------------------');
  245. SetTime(0,0,0,0);
  246. CheckDosError(0);
  247. GetTime(Hour1,Minute1,Second1,Sec1001);
  248. CheckDosError(0);
  249. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  250. WriteLn('----------------------------------------------------------------------');
  251. WriteLn(' Note: GetTime should return approximately the original time ');
  252. WriteLn('----------------------------------------------------------------------');
  253. SetTime(Hour,Minute,Second,Sec1001);
  254. CheckDosError(0);
  255. GetTime(Hour1,Minute1,Second1,Sec1001);
  256. CheckDosError(0);
  257. WriteLn('HH:MIN:SEC ',Hour1,':',Minute1,':',Second1);
  258. {$endif}
  259. end;
  260. Procedure TestFTime;
  261. var
  262. s : string;
  263. F: File;
  264. Time: Longint;
  265. DT: DateTime;
  266. DT1 : Datetime; { saved values }
  267. Begin
  268. WriteLn('----------------------------------------------------------------------');
  269. WriteLn(' GETFTIME / SETFTIME ');
  270. WriteLn('----------------------------------------------------------------------');
  271. CheckDosError(0);
  272. {**********************************************************************}
  273. {********************** TURBO PASCAL BUG ******************************}
  274. { The File is not Open and DosError is still zero! THIS SHOULD NOT BE }
  275. { SO IN FPC! }
  276. {**********************************************************************}
  277. {********************** TURBO PASCAL BUG ******************************}
  278. Write('Assigning an invalid file...');
  279. Assign(f,'x');
  280. GetFTime(f,Time);
  281. {$ifndef macos}
  282. CheckDosError(6);
  283. {$else}
  284. CheckDosError(2); {Since on MacOS, GetFTime works even for non-opened files}
  285. {$endif}
  286. Write('Trying to open ',TestFName,'...');
  287. Assign(f,TestFName);
  288. Reset(f,1);
  289. GetFTime(f,Time);
  290. CheckDosError(0);
  291. UnpackTime(Time,Dt);
  292. WriteLn('----------------------------------------------------------------------');
  293. WriteLn(' Note: Hour should be in military format and year should be a 4 digit ');
  294. WriteLn(' number. ');
  295. WriteLn('----------------------------------------------------------------------');
  296. WriteLn('DD-MM-YYYY : ',DT.Day,'-',DT.Month,'-',DT.Year);
  297. WriteLn('HH:MIN:SEC ',DT.Hour,':',DT.Min,':',DT.Sec);
  298. { SETFTIME / GETFTIME No Range checking is performed so the tests are }
  299. { very limited. }
  300. s:='Setting '+TestFName+' date/time to 01-28-1998:0:0:0...';
  301. dt1.Year:=1998;
  302. dt1.Month:=1;
  303. dt1.Day:=28;
  304. Dt1.Hour:=0;
  305. Dt1.Min:=0;
  306. Dt1.Sec:=0;
  307. PackTime(DT1,Time);
  308. CheckDosError(0);
  309. SetFTime(f,Time);
  310. CheckDosError(0);
  311. GetFTime(f,Time);
  312. CheckDosError(0);
  313. { Re-initialize the date time file }
  314. FillChar(Dt1,sizeof(dt1),#0);
  315. UnpackTime(Time,Dt1);
  316. if (Dt1.Year <> 1998) or (Dt1.Month<>1) or (Dt1.Day<>28) or
  317. (Dt1.Hour<>0) or (Dt1.Min <>0) or (Dt1.Sec<>0) then
  318. Begin
  319. WriteLn(s+'FAILURE.');
  320. end
  321. else
  322. WriteLn(s+'Success.');
  323. s:='Restoring old file time stamp...';
  324. Move(Dt,Dt1,sizeof(Dt));
  325. PackTime(DT1,Time);
  326. CheckDosError(0);
  327. SetFTime(f,Time);
  328. CheckDosError(0);
  329. GetFTime(f,Time);
  330. CheckDosError(0);
  331. { Re-initialize the date time file }
  332. FillChar(Dt1,sizeof(dt),#0);
  333. UnpackTime(Time,Dt1);
  334. if (Dt1.Year <> Dt.Year) or (Dt1.Month<>Dt.Month) or (Dt1.Day<>Dt.Day) or
  335. (Dt1.Hour<>Dt.Hour) or (Dt1.Min <> Dt.Min) or (Dt1.Sec<>Dt.Sec) then
  336. Begin
  337. WriteLn(s+'FAILURE.');
  338. end
  339. else
  340. WriteLn(s+'Success.');
  341. Close(f);
  342. end;
  343. Procedure TestFind;
  344. var
  345. Search: SearchRec;
  346. DT: Datetime;
  347. Year, Month, Day, DayOfWeek: Word;
  348. Failure : Boolean;
  349. FoundDot, FoundDotDot: boolean;
  350. FoundDir : boolean;
  351. s : string;
  352. Begin
  353. WriteLn('----------------------------------------------------------------------');
  354. WriteLn(' FINDFIRST/ FINDNEXT ');
  355. WriteLn('----------------------------------------------------------------------');
  356. WriteLn(' Note: The full path should NOT be displayed. ');
  357. WriteLn('----------------------------------------------------------------------');
  358. CheckDosError(0);
  359. WriteLn('Trying to find an invalid file ('''') with Any Attribute...');
  360. FindFirst('',AnyFile,Search);
  361. CheckDosError(3);
  362. {$IFDEF FPC}
  363. FindClose(Search);
  364. {$ENDIF}
  365. {$ifdef go32v2}
  366. WriteLn('Trying to find an invalid file ('''') with VolumeID attribute...');
  367. FindFirst('',VolumeID,Search);
  368. CheckDosError(3);
  369. {$IFDEF FPC}
  370. FindClose(Search);
  371. {$ENDIF}
  372. {$endif go32v2}
  373. WriteLn('Trying to find an invalid file (''''zz.dat'''') with Any Attribute...');
  374. FindFirst('zz.dat',AnyFile,Search);
  375. CheckDosError(18);
  376. {$IFDEF FPC}
  377. FindClose(Search);
  378. {$ENDIF}
  379. WriteLn('Trying to find an invalid file (''''zz.dat'''') with VolumeID attribute...');
  380. FindFirst('zz.dat',VolumeID,Search);
  381. CheckDosError(18);
  382. {$IFDEF FPC}
  383. FindClose(Search);
  384. {$ENDIF}
  385. WriteLn('Trying to find an invalid file (''''zz.dat'''') with Directory attribute...');
  386. FindFirst('zz.dat',Directory,Search);
  387. CheckDosError(18);
  388. {$IFDEF FPC}
  389. FindClose(Search);
  390. {$ENDIF}
  391. s:='Looking for '+TestFName +' with Any Attribute...';
  392. FindFirst('*.DAT',AnyFile,Search);
  393. if Search.Name <> TestFName then
  394. Begin
  395. repeat
  396. FindNext(Search);
  397. until (DosError <> 0) OR (Search.Name = TestFName);
  398. end;
  399. if Search.Name <> TestFName then
  400. { At least testdos.dat should appear }
  401. WriteLn(s+'FAILURE. ',TestFName,' should be found.')
  402. else
  403. WriteLn(s+'Success.');
  404. {$IFDEF FPC}
  405. FindClose(Search);
  406. {$ENDIF}
  407. { In addition to normal files }
  408. { directory files should also be found }
  409. s:='Looking for '+TestFName +' with Directory Attribute...';
  410. FindFirst('*.DAT',Archive+Directory,Search);
  411. if DosError<> 0 then
  412. WriteLn(s+'FAILURE. ',TestFName,' should be found.')
  413. else
  414. WriteLn(s+'Success.');
  415. if Search.Name <> TestFName then
  416. Begin
  417. repeat
  418. FindNext(Search);
  419. until (DosError <> 0) OR (Search.Name = TestFName);
  420. end;
  421. {$IFDEF FPC}
  422. FindClose(Search);
  423. {$ENDIF}
  424. Write('Checking file stats of ',TestFName,'...');
  425. UnpackTime(Search.Time,DT);
  426. GetDate(Year, Month, Day, DayOfWeek);
  427. if (Search.Size <> Sizeof(week)) OR (DT.Year <> Year) OR (DT.Month <> Month)
  428. OR (DT.Day <> Day)
  429. then
  430. Begin
  431. WriteLn('FAILURE. Size/Date is different.')
  432. end
  433. else
  434. WriteLn('Success.');
  435. Write('Looking for ',TestFName,'...');
  436. FindFirst('*.D??',AnyFile,Search);
  437. { At least testdos.dat should appear }
  438. if DosError <> 0 then
  439. WriteLn('FAILURE. ',Testfname,' should be found.')
  440. else
  441. WriteLn('Success.');
  442. if Search.Name <> TestFName then
  443. Begin
  444. repeat
  445. FindNext(Search);
  446. until (DosError <> 0) OR (Search.Name = TestFName);
  447. end;
  448. {$IFDEF FPC}
  449. FindClose(Search);
  450. {$ENDIF}
  451. Write('Checking file stats of ',TestFName,'...');
  452. UnpackTime(Search.Time,DT);
  453. GetDate(Year, Month, Day, DayOfWeek);
  454. if (Search.Size <> Sizeof(week)) OR (DT.Year <> Year) OR (DT.Month <> Month)
  455. OR (DT.Day <> Day)
  456. then
  457. Begin
  458. WriteLn('FAILURE. Size/Date is different.')
  459. end
  460. else
  461. WriteLn('Success.');
  462. { Should show all possible files }
  463. FoundDot := False;
  464. FoundDotDot := False;
  465. Failure := True;
  466. FoundDir := False;
  467. s:='Searching using * wildcard (normal files + directories)...';
  468. FindFirst('*',Archive+Directory,Search);
  469. WriteLn(#9'Resources found (full path should not be displayed):');
  470. while DosError = 0 do
  471. Begin
  472. If Search.Name = TestDir then
  473. Begin
  474. If Search.Attr and Directory <> 0 then
  475. FoundDir := TRUE;
  476. end;
  477. If Search.Name = '.' then
  478. Begin
  479. If Search.Attr and Directory <> 0 then
  480. FoundDot := TRUE;
  481. End;
  482. if Search.Name = '..' then
  483. Begin
  484. If Search.Attr and Directory <> 0 then
  485. FoundDotDot := TRUE;
  486. End;
  487. { check for both . and .. special files }
  488. If Search.Name = TestFName1 then
  489. Failure := FALSE;
  490. WriteLn(#9+Search.Name);
  491. FindNext(Search);
  492. end;
  493. {$IFDEF FPC}
  494. FindClose(Search);
  495. {$ENDIF}
  496. if not FoundDir then
  497. WriteLn(s+'FAILURE. Did not find '+TestDir+' directory')
  498. else
  499. {$ifndef wince}
  500. if not FoundDot then
  501. WriteLn(s+'FAILURE. Did not find special ''''.'''' directory')
  502. else
  503. if not FoundDotDot then
  504. WriteLn(s+'FAILURE. Did not find special ''''..'''' directory')
  505. else
  506. {$endif wince}
  507. if Failure then
  508. WriteLn(s+'FAILURE. Did not find special '+TestFName1+' directory')
  509. else
  510. WriteLn(s+'Success.');
  511. {$ifdef go32v2}
  512. s:='Searching using ??? wildcard (normal files + all special files)...';
  513. FindFirst('???',AnyFile,Search);
  514. FoundDot := False;
  515. FoundDotDot := False;
  516. WriteLn(#9'Resources found (full path should not be displayed):');
  517. while DosError = 0 do
  518. Begin
  519. If Search.Name = '.' then
  520. Begin
  521. If Search.Attr and Directory <> 0 then
  522. FoundDot := TRUE;
  523. End;
  524. if Search.Name = '..' then
  525. Begin
  526. If Search.Attr and Directory <> 0 then
  527. FoundDotDot := TRUE;
  528. End;
  529. WriteLn(#9+Search.Name);
  530. FindNext(Search);
  531. end;
  532. if not FoundDot then
  533. WriteLn(s+'FAILURE. Did not find special ''''.'''' directory')
  534. else
  535. if not FoundDotDot then
  536. WriteLn(s+'FAILURE. Did not find special ''''..'''' directory')
  537. else
  538. WriteLn(s+'Success.');
  539. {$IFDEF FPC}
  540. FindClose(Search);
  541. {$ENDIF}
  542. { search for volume ID }
  543. s:='Searching using * wildcard in ROOT (normal files + volume ID)...';
  544. FindFirst(RootPath+'*',Directory+VolumeID,Search);
  545. Failure := TRUE;
  546. WriteLn(#9'Resources found (full path should not be displayed):');
  547. while DosError = 0 do
  548. Begin
  549. If Search.Attr and VolumeID <> 0 then
  550. Begin
  551. Failure := FALSE;
  552. WriteLn(#9'Volume ID: '+Search.Name);
  553. End
  554. else
  555. WriteLn(#9+Search.Name);
  556. FindNext(Search);
  557. end;
  558. If Failure then
  559. WriteLn(s+'FAILURE. Did not find volume name')
  560. else
  561. WriteLn(s+'Success.');
  562. {$IFDEF FPC}
  563. FindClose(Search);
  564. {$ENDIF}
  565. {$endif}
  566. end;
  567. Procedure TestSplit;
  568. var
  569. P: PathStr;
  570. D: DirStr;
  571. N: NameStr;
  572. E: ExtStr;
  573. temp : string;
  574. Begin
  575. WriteLn('----------------------------------------------------------------------');
  576. WriteLn(' FSPLIT ');
  577. WriteLn('----------------------------------------------------------------------');
  578. Write('Testing invalid filename...');
  579. { Initialize names ot invalid values! }
  580. D:='Garbage';
  581. N:='Garbage';
  582. E:='GAR';
  583. { This is the path to be split }
  584. P:='';
  585. FSPlit(P,D,N,E);
  586. IF (length(D) <> 0) OR (length(N) <>0) OR (length(E) <> 0) THEN
  587. WriteLn('FAILURE. Same length as PATH (now length 0) should be returned.')
  588. else
  589. WriteLn('Success.');
  590. Write('Testing paramstr(0)...');
  591. { Initialize names ot invalid values! }
  592. D:='Garbage';
  593. N:='Garbage';
  594. E:='GAR';
  595. { This is the path to be split }
  596. P:=paramstr(0);
  597. FSPlit(P,D,N,E);
  598. IF length(p) <> (length(d)+length(n)+length(e)) then
  599. WriteLn('FAILURE. Same length as PATH should be returned.')
  600. else
  601. WriteLn('Success.');
  602. temp:=d+n+e;
  603. Write('Testing paramstr(0)...');
  604. if temp <> p then
  605. WriteLn('FAILURE. Concatenated string should be the same.')
  606. else
  607. WriteLn('Success.');
  608. WriteLn('PARAMSTR(0) = ', ParamStr(0));
  609. WriteLn('DRIVE + NAME + EXT = ',d+n+e);
  610. {$ifdef go32v2}
  611. Write('Testing invalid path (..)...');
  612. P:='..';
  613. FSPlit(P,D,N,E);
  614. IF (length(D) <> 0) OR (length(N) <>0) OR (E <> P) THEN
  615. WriteLn('FAILURE. Length of drive and name should be zero and Ext should return Path')
  616. else
  617. WriteLn('Success.');
  618. {$endif}
  619. Write('Testing invalid path (*)...');
  620. P:='*';
  621. FSPlit(P,D,N,E);
  622. IF (length(D) <> 0) OR (length(e) <>0) OR (N <> P) THEN
  623. WriteLn('FAILURE. Length of drive and name should be zero and Name should return Path')
  624. else
  625. WriteLn('Success.');
  626. end;
  627. var
  628. F: File;
  629. Attr : Word;
  630. Begin
  631. {$IFDEF MACOS}
  632. pathTranslation:= true;
  633. {$ENDIF}
  634. TestSystemDate;
  635. TestSystemTime;
  636. { Now the file I/O functions }
  637. { Let us create a file that we will play with }
  638. Assign(f,TestFName);
  639. Rewrite(f,1);
  640. BlockWrite(f,Week,sizeof(Week));
  641. Close(f);
  642. Assign(f,TestFName1);
  643. Rewrite(f,1);
  644. Close(F);
  645. MkDir(TestDir);
  646. TestFTime;
  647. TestFind;
  648. PauseScreen;
  649. TestSplit;
  650. RmDir(TestDir);
  651. PauseScreen;
  652. { Cleanup }
  653. {$I-}
  654. assign(f,TestFName);
  655. erase(f);
  656. assign(f,TestFName1);
  657. erase(f);
  658. {$I+}
  659. if ioresult<>0 then;
  660. if has_errors then
  661. halt(1);
  662. end.