From 67a280f5da4ab71fa5e66e5ddf596ee97fda5e91 Mon Sep 17 00:00:00 2001 From: mane Date: Thu, 2 Apr 2020 13:00:20 +0400 Subject: [PATCH] UserDetails and Vipack --- UserDetails.Mod | 16 ++++++++++++++++ Vipack.Mod | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 UserDetails.Mod create mode 100644 Vipack.Mod diff --git a/UserDetails.Mod b/UserDetails.Mod new file mode 100644 index 0000000..22d2fbf --- /dev/null +++ b/UserDetails.Mod @@ -0,0 +1,16 @@ +MODULE UserDetails; +IMPORT Platform; + +PROCEDURE GetUsername*(VAR str : ARRAY OF CHAR):BOOLEAN; +BEGIN + RETURN Platform.getEnv("USER", str); +END GetUsername; + + + + + + + + +END UserDetails. diff --git a/Vipack.Mod b/Vipack.Mod new file mode 100644 index 0000000..7b7dc2e --- /dev/null +++ b/Vipack.Mod @@ -0,0 +1,42 @@ +MODULE Vipack; +IMPORT Texts,Strings,In,Platform, Oberon, Out, Files, UserDetails; + +VAR user, str, fn: ARRAY 32 OF CHAR; + confDir, string : ARRAY 120 OF CHAR; + i : INTEGER; + f : Files.File; + r : Files.Rider; + ch : CHAR; + S: Texts.Scanner; +BEGIN +(* Getting 1 argument and outputting it *) +Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); +Texts.Scan(S); +Out.String(S.s); Out.Ln; + +confDir := "/home//.vipack/vipack.conf"; + +(* Getting username from input if there is no $USER variable *) +IF ~(UserDetails.GetUsername(user)) THEN + Out.String("username: "); In.Line(user); +END; + +(* Making the full path to vipack.conf *) +Strings.Insert(user,6,confDir); +Out.String(confDir);Out.Ln; + +(* Checking if vipack.conf already exists *) +IF Files.Old(confDir) = NIL THEN + Out.String("Creating the configuration file "); Out.String(confDir);Out.Ln; + f := Files.New(confDir); + Files.Set(r, f, 0); + Files.WriteInt(r, 8); Files.WriteString(r, "Configuration"); + Files.Register(f); +ELSIF Files.Old(confDir) # NIL THEN + Out.String("File already exists");Out.Ln; +END; + +Out.String(user); Out.Ln; + + +END Vipack.