mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
Hurray, it downloads
This commit is contained in:
parent
173fd486fe
commit
e896987c66
5 changed files with 62 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
MODULE FileManager;
|
||||
IMPORT Files, Out, Logger, Strings;
|
||||
IMPORT Files, Out, Logger, Strings, Platform;
|
||||
|
||||
PROCEDURE WriteString(VAR r : Files.Rider; str : ARRAY OF CHAR);
|
||||
BEGIN
|
||||
|
|
@ -62,4 +62,20 @@ BEGIN
|
|||
RETURN TRUE;
|
||||
END Write;
|
||||
|
||||
PROCEDURE CreateDirectory*(name, path: ARRAY OF CHAR): BOOLEAN;
|
||||
VAR
|
||||
command, path0: ARRAY 100 OF CHAR;
|
||||
errorCode: LONGINT;
|
||||
BEGIN
|
||||
COPY(path, path0);
|
||||
COPY("mkdir -p ", command);
|
||||
Strings.Append("/", path0);
|
||||
Strings.Append(name, path0);
|
||||
Strings.Append(path0, command);
|
||||
errorCode := Platform.System(command);
|
||||
|
||||
IF errorCode = 0 THEN RETURN TRUE
|
||||
ELSE RETURN FALSE END;
|
||||
END CreateDirectory;
|
||||
|
||||
END FileManager.
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
MODULE PackageResolver;
|
||||
IMPORT FileManager, http, Strings, Logger;
|
||||
IMPORT FileManager, http, Strings, Logger, Settings;
|
||||
|
||||
CONST ArrayMaxNumber = 10000;
|
||||
|
||||
|
|
@ -10,7 +10,8 @@ END Resolve;
|
|||
|
||||
PROCEDURE ResolveFile *(host, port, packageName, version, fileName : ARRAY OF CHAR; VAR returnValue : ARRAY OF CHAR);
|
||||
VAR
|
||||
filePath: ARRAY ArrayMaxNumber OF CHAR;
|
||||
filePath, localPath: ARRAY ArrayMaxNumber OF CHAR;
|
||||
isSuccessfull: BOOLEAN;
|
||||
BEGIN
|
||||
filePath := "";
|
||||
Strings.Append("/", filePath);
|
||||
|
|
@ -22,9 +23,15 @@ BEGIN
|
|||
|
||||
http.get(host, port, filePath, returnValue);
|
||||
http.getClean(returnValue, returnValue);
|
||||
(* TODO: introduce write to file functionality *)
|
||||
(* FileManager.CreateDirectory(packageName); *)
|
||||
(* FileManager.Write(packageName + fileName, returnValue); *)
|
||||
isSuccessfull := FileManager.CreateDirectory(packageName, Settings.installPath);
|
||||
|
||||
COPY(Settings.installPath, localPath);
|
||||
Strings.Append("/", localPath);
|
||||
Strings.Append(packageName, localPath);
|
||||
Strings.Append("/", localPath);
|
||||
Strings.Append(fileName, localPath);
|
||||
|
||||
isSuccessfull := FileManager.Write(localPath, returnValue);
|
||||
|
||||
END ResolveFile;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,4 +3,6 @@ CONST
|
|||
packageFileName* = "VersionFile.json";
|
||||
host* = "localhost";
|
||||
port* = "80";
|
||||
installPath* = "dependencies";
|
||||
|
||||
END Settings.
|
||||
15
dependencies/dep1/VersionFile.json
vendored
Normal file
15
dependencies/dep1/VersionFile.json
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
'Package': 'dep1',
|
||||
'Author': 'Author Name',
|
||||
'License':'License name',
|
||||
'Version': '1.0.0',
|
||||
'Remote': 'vishap.oberon.com',
|
||||
'Port': '80',
|
||||
'Files': {
|
||||
'0': 'File1.Mod',
|
||||
'1': 'File2.Mod',
|
||||
'2': 'MakeFile'
|
||||
},
|
||||
'Dependencies': {
|
||||
}
|
||||
}
|
||||
16
dependencies/dep2/VersionFile.json
vendored
Normal file
16
dependencies/dep2/VersionFile.json
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
'Package': 'dep2',
|
||||
'Author': 'Author Name',
|
||||
'License':'License name',
|
||||
'Version': '1.0.0',
|
||||
'Remote': 'vishap.oberon.com',
|
||||
'Port': '80',
|
||||
'Files': {
|
||||
'0': 'File1.Mod',
|
||||
'1': 'File2.Mod',
|
||||
'2': 'MakeFile'
|
||||
},
|
||||
'Dependencies': {
|
||||
'dep1': '1.0.0'
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue