mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
UserDetails and Vipack
This commit is contained in:
parent
56b1c31a3e
commit
67a280f5da
2 changed files with 58 additions and 0 deletions
16
UserDetails.Mod
Normal file
16
UserDetails.Mod
Normal file
|
|
@ -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.
|
||||
42
Vipack.Mod
Normal file
42
Vipack.Mod
Normal file
|
|
@ -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.
|
||||
Loading…
Add table
Add a link
Reference in a new issue