mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
compiles, needs cleanup
This commit is contained in:
parent
82d79b4647
commit
400e80b116
1 changed files with 51 additions and 0 deletions
51
src/vpkSyncer.Mod
Normal file
51
src/vpkSyncer.Mod
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
MODULE vpkSyncer;
|
||||
IMPORT Strings, Out,
|
||||
vpkSettings, vpkConf, vpkFsHelper, vpkFileManager, vpkJsonParser, vpkGit;
|
||||
|
||||
PROCEDURE mkTreePath(VAR path: ARRAY OF CHAR);
|
||||
BEGIN
|
||||
vpkConf.getConfDir(path);
|
||||
Strings.Append(vpkSettings.vpkConfDir, path);
|
||||
Strings.Append('/', path);
|
||||
Strings.Append(vpkSettings.vpkTreeDir, path);
|
||||
END mkTreePath;
|
||||
|
||||
PROCEDURE sync*;
|
||||
VAR
|
||||
dir : vpkFsHelper.fileInfo;
|
||||
jsonData: ARRAY 256 OF CHAR;
|
||||
jsonURL: ARRAY 64 OF CHAR;
|
||||
jsonType: ARRAY 8 OF CHAR;
|
||||
b: BOOLEAN;
|
||||
confPath, treePath : ARRAY 256 OF CHAR;
|
||||
jsonRecord : vpkJsonParser.JsonTypePointer;
|
||||
BEGIN
|
||||
mkTreePath(treePath);
|
||||
Out.String("*****************************************"); Out.Ln;
|
||||
Out.String("TreePath = "); Out.String(treePath);
|
||||
(* Check tree directory if doesn't exist create*)
|
||||
dir.name := treePath;
|
||||
IF ~vpkFsHelper.Exists(dir) THEN
|
||||
Out.String(treePath); Out.String(" directory doesn't exist, creating"); Out.Ln;
|
||||
b := vpkFsHelper.mkDir(treePath);
|
||||
ELSE
|
||||
IF ~(vpkFsHelper.dir IN dir.attr) THEN
|
||||
Out.String(treePath); Out.String(" exists but is not a directory"); Out.Ln;
|
||||
HALT(1);
|
||||
END;
|
||||
(* Syncing *)
|
||||
vpkConf.getConfPath(confPath);
|
||||
b := vpkFileManager.Read(confPath, jsonData);
|
||||
jsonRecord := vpkJsonParser.Create(jsonData);
|
||||
b := vpkJsonParser.GetTerminal(jsonRecord, vpkSettings.confTermPath, jsonURL);
|
||||
Out.String("URL = "); Out.String(jsonURL); Out.Ln;
|
||||
b := vpkJsonParser.GetTerminal(jsonRecord, vpkSettings.confType, jsonType);
|
||||
IF jsonType = vpkSettings.confTypGit THEN
|
||||
vpkGit.pull(jsonURL, treePath)
|
||||
ELSE
|
||||
Out.String("not a git url"); Out.Ln
|
||||
END;
|
||||
END;
|
||||
END sync;
|
||||
|
||||
END vpkSyncer.
|
||||
Loading…
Add table
Add a link
Reference in a new issue