From 64b8300c1dc561bd0254bb6ed107cd340b4042e7 Mon Sep 17 00:00:00 2001 From: Doni Pracner Date: Mon, 17 Feb 2014 19:37:49 +0100 Subject: [PATCH] Zad3 zamenjuje Zad5 kao jednostavniji primer citanja direktorijuma bez stat --- skripta-os2.tex | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/skripta-os2.tex b/skripta-os2.tex index 1a6ae56..d1e6837 100644 --- a/skripta-os2.tex +++ b/skripta-os2.tex @@ -467,20 +467,16 @@ END Lib32. \end{codeblock} \begin{codeblock} -MODULE Zad5; +MODULE Zad3; -FROM SYSTEM IMPORT - ADR; FROM StrIO IMPORT WriteString, WriteLn; FROM NumberIO IMPORT WriteInt; -FROM StrLib IMPORT - StrLen, StrConCat; FROM Args IMPORT Narg, GetArg; -FROM Lib32 IMPORT - opendir, readdir, closedir, stat, PDir, PDirEnt, Stat; + FROM Lib32 IMPORT + opendir, readdir, closedir, PDir, PDirEnt; FROM errno IMPORT geterrno; @@ -496,35 +492,18 @@ PROCEDURE Listaj(Ime: ARRAY OF CHAR); VAR dir: PDir; entry: PDirEnt; - info: Stat; c: INTEGER; - Len: CARDINAL; - Putanja: String; BEGIN + WriteString("Folder "); WriteString(Ime); WriteLn; dir:= opendir(Ime); IF dir = NIL THEN - WriteString("Folder "); WriteString(Ime); WriteLn; WriteString(" Greska broj "); WriteInt(geterrno(), 0); WriteString("."); WriteLn(); WriteString(" Ne mogu da otvorim direktorijum."); WriteLn(); ELSE - Len:= StrLen(Ime); - IF Ime[Len - 1] # "/" THEN - StrConCat(Ime, "/", Ime); - END; - WriteString("Folder "); WriteString(Ime); WriteLn; entry:= readdir(dir); WHILE entry # NIL DO IF entry^.name[0] # "." THEN - StrConCat(Ime, entry^.name, Putanja); - c:= stat(Putanja, ADR(info)); - WriteString(" "); - IF c = -1 THEN - WriteString("? ? KB"); - ELSE - WriteInt(info.nlink, 3); - WriteInt((info.size + 512) DIV 1024, 5); WriteString(" KB "); - END; - WriteString(" "); WriteString(entry^.name); WriteLn; + WriteString(" "); WriteString(entry^.name); WriteLn; END; entry:= readdir(dir); END; @@ -544,7 +523,7 @@ BEGIN Listaj(Putanja); END; WriteLn; -END Zad5. +END Zad3. \end{codeblock} \subsection{Stvaranje novih procesa} -- 2.25.1