From 955db770ca36ad359c2db8690d61d102083f1e26 Mon Sep 17 00:00:00 2001 From: Ruben Shekspir Date: Tue, 30 Apr 2019 22:11:51 +0400 Subject: [PATCH] File Manager READ WORKS!!! --- FileManager.Mod | 28 ++++++++++++++++++++++++++-- PackageFileParser.Mod | 13 ++++++++++++- VersionFile.json | 24 ++++++++++++++++++++++++ makefile | 13 +++++++++++-- 4 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 VersionFile.json diff --git a/FileManager.Mod b/FileManager.Mod index 2696d7d..73d19a4 100644 --- a/FileManager.Mod +++ b/FileManager.Mod @@ -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; diff --git a/PackageFileParser.Mod b/PackageFileParser.Mod index 456b6e7..fb5aeab 100644 --- a/PackageFileParser.Mod +++ b/PackageFileParser.Mod @@ -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 diff --git a/VersionFile.json b/VersionFile.json new file mode 100644 index 0000000..78023f1 --- /dev/null +++ b/VersionFile.json @@ -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" + } + } + \ No newline at end of file diff --git a/makefile b/makefile index 68af25f..fd2e23d 100644 --- a/makefile +++ b/makefile @@ -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 - \ No newline at end of file +file: + cd builds && \ + $(VOC) -s \ + ../FileManager.Mod -m \ No newline at end of file