mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-06 04:52:26 +00:00
checking conf file and dir
This commit is contained in:
parent
c5b750daba
commit
a36f236bb3
3 changed files with 66 additions and 13 deletions
34
Vipack.Mod
34
Vipack.Mod
|
|
@ -1,9 +1,12 @@
|
|||
MODULE Vipack;
|
||||
IMPORT vpkLogger, vpkPackageFileParser,Texts,Strings,In,Platform, Oberon, Out, Files, vpkUserDetails;
|
||||
IMPORT vpkConf, vpkFsHelper, vpkLogger, vpkPackageFileParser, Texts, Strings, In, Platform, Oberon, Out, Files, vpkUserDetails;
|
||||
|
||||
PROCEDURE main();
|
||||
|
||||
CONST confFileName = "/vipack.conf";
|
||||
|
||||
VAR user, str, fn: ARRAY 32 OF CHAR;
|
||||
confDir, string : ARRAY 120 OF CHAR;
|
||||
confPath, string : ARRAY 120 OF CHAR;
|
||||
i : INTEGER;
|
||||
f : Files.File;
|
||||
r : Files.Rider;
|
||||
|
|
@ -23,7 +26,7 @@ Texts.Scan(S);
|
|||
Out.String(S.s); Out.Ln;
|
||||
|
||||
|
||||
(* Vipack installation or help) *)
|
||||
(* Vipack installation or help *)
|
||||
command := S.s;
|
||||
IF Strings.Match(command, "") OR Strings.Match(command, "--help")THEN
|
||||
help;
|
||||
|
|
@ -32,7 +35,7 @@ ELSIF Strings.Match(command, "install") THEN
|
|||
END;
|
||||
|
||||
|
||||
confDir := "/home//.vipack/vipack.conf";
|
||||
confPath := "/home//.vipack";
|
||||
|
||||
(* Getting username from input if there is no $USER variable *)
|
||||
IF ~(vpkUserDetails.GetUsername(user)) THEN
|
||||
|
|
@ -40,17 +43,22 @@ IF ~(vpkUserDetails.GetUsername(user)) THEN
|
|||
END;
|
||||
|
||||
(* Making the full path to vipack.conf *)
|
||||
Strings.Insert(user,6,confDir);
|
||||
Out.String(confDir);Out.Ln;
|
||||
Strings.Insert(user,6,confPath);
|
||||
Out.String(confPath);Out.Ln;
|
||||
|
||||
(* Checking if ~/.vipack directory already exists *)
|
||||
IF ~(vpkFsHelper.mkDir(confPath)) THEN
|
||||
Out.String(confPath); Out.String(" already exists or path is wrong");Out.Ln;
|
||||
ELSE Out.String("Creating directory "); Out.String(confPath);Out.Ln;
|
||||
END;
|
||||
|
||||
(* 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
|
||||
Strings.Append(confFileName,confPath);
|
||||
|
||||
IF ~(vpkConf.confExists(confPath)) THEN
|
||||
Out.String("Creating the configuration file "); Out.String(confPath);Out.Ln;
|
||||
vpkConf.makeConf(confPath);
|
||||
ELSE
|
||||
Out.String("File already exists");Out.Ln;
|
||||
END;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue