File Manager READ WORKS!!!

This commit is contained in:
Ruben Shekspir 2019-04-30 22:11:51 +04:00
parent 654ca13405
commit 955db770ca
4 changed files with 73 additions and 5 deletions

View file

@ -1,11 +1,35 @@
MODULE FileManager;
IMPORT Files, Out, Logger;
PROCEDURE Read();
PROCEDURE Read*(fileName: ARRAY OF CHAR; VAR returnString: ARRAY OF CHAR): BOOLEAN;
VAR
f: Files.File;
r: Files.Rider;
i: LONGINT;
BEGIN
f := Files.Old(fileName);
IF f = NIL THEN
Logger.Log("-------------------");
Logger.Log("File Name");
Logger.Log(fileName);
Logger.Log("File not found");
Logger.Log("-------------------");
RETURN FALSE
END;
Files.Set(r, f, 0);
i := 0;
REPEAT
Files.Read(r, returnString[i]);
INC(i);
UNTIL r.eof OR (i>=LEN(returnString));
RETURN TRUE;
END Read;
PROCEDURE Write();
PROCEDURE Write*();
BEGIN
END Write;

View file

@ -1,11 +1,22 @@
MODULE PackageFileParser;
IMPORT
JsonParser,
FileManager,
Logger;
CONST
MAXARRAYNUMBER = 1000;
PROCEDURE install*;
VAR
fileData: ARRAY MAXARRAYNUMBER OF CHAR;
successfullyParsed: BOOLEAN;
BEGIN
Logger.Log("Starting install process");
successfullyParsed := FileManager.Read("VersionFile.json", fileData);
IF ~successfullyParsed THEN Logger.Log("Some ERROR occured while reading VERSIONFILE") END;
ASSERT(successfullyParsed);
Logger.Log(fileData);
END install;
BEGIN

24
VersionFile.json Normal file
View file

@ -0,0 +1,24 @@
{
"Package": "Package-name",
"Author": "Author Name",
"License":"License name",
"Version": "1.0.0",
"Remote": "http://vishap.oberon.com",
"Files": [
"File1.Mod",
"File2.Mod",
"MakeFile"
],
"Dependencies": {
"Package-2-name": "2.5.*",
"Package-3-name": "2.*",
"Package-4-name": "2.1.4"
},
"Scripts": {
"build": "make build",
"test": "make test",
"run": "make run",
"compile": "make compile"
}
}

View file

@ -1,5 +1,11 @@
VOC = voc
VERSION_FILE = ./VersionFile.json
test: clean copy-version-file-to-build-dir all run
copy-version-file-to-build-dir:
cp ./$(VERSION_FILE) ./builds/$(VERSION_FILE)
all:
cd builds && \
@ -10,6 +16,7 @@ all:
../diaspora2hugo/src/lists/List.Mod \
../CharacterStack.Mod \
../JsonParser.Mod \
../FileManager.Mod \
../PackageFileParser.Mod \
../opium.Mod -m
@ -19,5 +26,7 @@ clean:
run:
./builds/opium install
test: clean all run
file:
cd builds && \
$(VOC) -s \
../FileManager.Mod -m