From 8df1b65d7888e2baca790e1b66d6dfbb088c2b27 Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 12:54:58 +0200 Subject: [PATCH 1/7] Document global filesystem functions --- Utils/Functions/Filesystem/Files/script.js | 99 +++++++++++++++++++--- 1 file changed, 88 insertions(+), 11 deletions(-) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index be6056b9ad..9add5bca6b 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -1,81 +1,158 @@ var fileAnalyser = Bean("fileAnalyser"); var fileUtilities = Bean("fileUtilities"); -/* exported mkdir */ +/** +* creates directory +* @param {string} directory path +* +* exported mkdir */ var mkdir = function (directoryPath) { fileUtilities.mkdir(new java.io.File(directoryPath)) }; -/* exported fileExists */ +/** +* check if file exists +* @param {string} file path +* @returns {boolean} true if file exists +* +* exported fileExists */ var fileExists = function (filePath) { return new java.io.File(filePath).exists(); }; +/** +* returns file content +* @param {string} file path +* @returns {string} content /* exported cat */ var cat = function(filePath) { return Bean("fileUtilities").getFileContent(new java.io.File(filePath)); }; -/* exported cp */ +/** +* copies file +* @param {string} source +* @param {string} target +* +* exported cp */ var cp = function(source, target) { return Bean("fileUtilities").copy(new java.io.File(source), new java.io.File(target)); }; -/* exported getFileSize */ +/** +* returns file size +* @param {string} file path +* @returns {number} file size +* +* exported getFileSize */ var getFileSize = function(filePath) { return Bean("fileUtilities").getSize(new java.io.File(filePath)); }; -/* exported fileName */ +/** +* returns file name +* @param {string} file path +* @returns {string} file name +* +* exported fileName */ var fileName = function(filePath) { return new java.io.File(filePath).getName(); }; -/* exported lns */ +/** +* creates link +* @param {string} target +* @param {string} destination +* +* exported lns */ var lns = function(target, destination) { return Bean("fileUtilities").createSymbolicLink(new java.io.File(destination), new java.io.File(target)); }; -/* exported remove */ +/** +* removes file +* @param {string} file path +* +* exported remove */ var remove = function(filePath) { return Bean("fileUtilities").remove(new java.io.File(filePath)); }; -/* exported touch */ +/** +* creates empty file +* @param {string} file path +* +* exported touch */ var touch = function(filePath) { if (!fileExists(filePath)) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), ""); } }; -/* exported writeToFile */ +/** +* writes content into file +* @param {string} file path +* @param {string} content +* +* exported writeToFile */ var writeToFile = function(filePath, content) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), content); }; -/* exported createTempFile */ +/** +* creates temporary file +* @param {string} file extension +* @returns {string} file path of created temporary file +* +* exported createTempFile */ var createTempFile = function (extension) { var tmpFile = Bean("fileUtilities").createTmpFile(extension); return tmpFile.getAbsolutePath(); }; -/* exported Checksum */ +/** +* checksum utilities +* +* exported Checksum */ var Checksum = function () { var that = this; that._method = "SHA"; that._checksumCalculator = Bean("checksumCalculator"); + + /** + * sets wizard + * @param {SetupWizard} wizard + * @returns {Checksum} + */ that.wizard = function (wizard) { that._wizard = wizard; return that; }; + + /** + * sets algorithm + * @param {string} algorithm (e.g. "SHA") + * @returns {Checksum} + */ that.method = function (algorithm) { that._method = algorithm; return that; }; + + /** + * sets file for which the checksum shall be computed + * @param {string} file path + * @returns {Checksum} + */ that.of = function (file) { that._file = file; return that; }; + + /** + * returns checksum + * @returns {number} checksum + */ that.get = function () { if(that._wizard) { var progressBar = that._wizard.progressBar(tr("Checking file consistency ...")); From 3ddb13762b479f8979da2d0868ba3888cc657c24 Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 19:36:23 +0200 Subject: [PATCH 2/7] Add missing arguments for @param --- Utils/Functions/Filesystem/Files/script.js | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index 9add5bca6b..d23ca09399 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -3,7 +3,7 @@ var fileUtilities = Bean("fileUtilities"); /** * creates directory -* @param {string} directory path +* @param {string} directoryPath directory path * * exported mkdir */ var mkdir = function (directoryPath) { @@ -12,7 +12,7 @@ var mkdir = function (directoryPath) { /** * check if file exists -* @param {string} file path +* @param {string} filePath file path * @returns {boolean} true if file exists * * exported fileExists */ @@ -22,7 +22,7 @@ var fileExists = function (filePath) { /** * returns file content -* @param {string} file path +* @param {string} filePath file path * @returns {string} content /* exported cat */ var cat = function(filePath) { @@ -31,8 +31,8 @@ var cat = function(filePath) { /** * copies file -* @param {string} source -* @param {string} target +* @param {string} source source +* @param {string} target target * * exported cp */ var cp = function(source, target) { @@ -41,7 +41,7 @@ var cp = function(source, target) { /** * returns file size -* @param {string} file path +* @param {string} filePath file path * @returns {number} file size * * exported getFileSize */ @@ -51,7 +51,7 @@ var getFileSize = function(filePath) { /** * returns file name -* @param {string} file path +* @param {string} filePath file path * @returns {string} file name * * exported fileName */ @@ -61,8 +61,8 @@ var fileName = function(filePath) { /** * creates link -* @param {string} target -* @param {string} destination +* @param {string} target target +* @param {string} destination destination * * exported lns */ var lns = function(target, destination) { @@ -71,7 +71,7 @@ var lns = function(target, destination) { /** * removes file -* @param {string} file path +* @param {string} filePath file path * * exported remove */ var remove = function(filePath) { @@ -80,7 +80,7 @@ var remove = function(filePath) { /** * creates empty file -* @param {string} file path +* @param {string} filePath file path * * exported touch */ var touch = function(filePath) { @@ -91,8 +91,8 @@ var touch = function(filePath) { /** * writes content into file -* @param {string} file path -* @param {string} content +* @param {string} filePath file path +* @param {string} content content which shall be written * * exported writeToFile */ var writeToFile = function(filePath, content) { @@ -101,7 +101,7 @@ var writeToFile = function(filePath, content) { /** * creates temporary file -* @param {string} file extension +* @param {string} extension file extension * @returns {string} file path of created temporary file * * exported createTempFile */ From 579664b963650c6ea46672499a0091d8c4e98a8a Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 19:37:42 +0200 Subject: [PATCH 3/7] Leave Checksum for other PR --- Utils/Functions/Filesystem/Files/script.js | 27 ---------------------- 1 file changed, 27 deletions(-) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index d23ca09399..e3f855540b 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -110,49 +110,22 @@ var createTempFile = function (extension) { return tmpFile.getAbsolutePath(); }; -/** -* checksum utilities -* -* exported Checksum */ var Checksum = function () { var that = this; that._method = "SHA"; that._checksumCalculator = Bean("checksumCalculator"); - - /** - * sets wizard - * @param {SetupWizard} wizard - * @returns {Checksum} - */ that.wizard = function (wizard) { that._wizard = wizard; return that; }; - - /** - * sets algorithm - * @param {string} algorithm (e.g. "SHA") - * @returns {Checksum} - */ that.method = function (algorithm) { that._method = algorithm; return that; }; - - /** - * sets file for which the checksum shall be computed - * @param {string} file path - * @returns {Checksum} - */ that.of = function (file) { that._file = file; return that; }; - - /** - * returns checksum - * @returns {number} checksum - */ that.get = function () { if(that._wizard) { var progressBar = that._wizard.progressBar(tr("Checking file consistency ...")); From ed0d24da38c2ade692b2cc52deb653f86a11748f Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 19:57:04 +0200 Subject: [PATCH 4/7] Use different function style --- Utils/Functions/Filesystem/Files/script.js | 76 ++++++++++------------ 1 file changed, 33 insertions(+), 43 deletions(-) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index e3f855540b..16fc4a7ff2 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -4,111 +4,101 @@ var fileUtilities = Bean("fileUtilities"); /** * creates directory * @param {string} directoryPath directory path -* -* exported mkdir */ -var mkdir = function (directoryPath) { +*/ +function mkdir(directoryPath) { fileUtilities.mkdir(new java.io.File(directoryPath)) -}; +} /** * check if file exists * @param {string} filePath file path * @returns {boolean} true if file exists -* -* exported fileExists */ -var fileExists = function (filePath) { +*/ +function fileExists(filePath) { return new java.io.File(filePath).exists(); -}; +} /** * returns file content * @param {string} filePath file path * @returns {string} content -/* exported cat */ -var cat = function(filePath) { +*/ +function cat(filePath) { return Bean("fileUtilities").getFileContent(new java.io.File(filePath)); -}; +} /** * copies file * @param {string} source source * @param {string} target target -* -* exported cp */ -var cp = function(source, target) { +*/ +function cp(source, target) { return Bean("fileUtilities").copy(new java.io.File(source), new java.io.File(target)); -}; +} /** * returns file size * @param {string} filePath file path * @returns {number} file size -* -* exported getFileSize */ -var getFileSize = function(filePath) { +*/ +function getFileSize(filePath) { return Bean("fileUtilities").getSize(new java.io.File(filePath)); -}; +} /** * returns file name * @param {string} filePath file path * @returns {string} file name -* -* exported fileName */ -var fileName = function(filePath) { +*/ +function fileName(filePath) { return new java.io.File(filePath).getName(); -}; +} /** * creates link * @param {string} target target * @param {string} destination destination -* -* exported lns */ -var lns = function(target, destination) { +*/ +function lns(target, destination) { return Bean("fileUtilities").createSymbolicLink(new java.io.File(destination), new java.io.File(target)); -}; +} /** * removes file * @param {string} filePath file path -* -* exported remove */ -var remove = function(filePath) { +*/ +function remove(filePath) { return Bean("fileUtilities").remove(new java.io.File(filePath)); -}; +} /** * creates empty file * @param {string} filePath file path -* -* exported touch */ -var touch = function(filePath) { +*/ +function touch(filePath) { if (!fileExists(filePath)) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), ""); } -}; +} /** * writes content into file * @param {string} filePath file path * @param {string} content content which shall be written -* -* exported writeToFile */ -var writeToFile = function(filePath, content) { +*/ +function writeToFile(filePath, content) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), content); -}; +} /** * creates temporary file * @param {string} extension file extension * @returns {string} file path of created temporary file -* -* exported createTempFile */ -var createTempFile = function (extension) { +*/ +function createTempFile(extension) { var tmpFile = Bean("fileUtilities").createTmpFile(extension); return tmpFile.getAbsolutePath(); -}; +} var Checksum = function () { var that = this; From 39c7f17b6b567ce7679428d8a29014fe70a00913 Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 20:16:57 +0200 Subject: [PATCH 5/7] Add "exported" --- Utils/Functions/Filesystem/Files/script.js | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index 16fc4a7ff2..742ac72c6a 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -4,7 +4,8 @@ var fileUtilities = Bean("fileUtilities"); /** * creates directory * @param {string} directoryPath directory path -*/ +* +* exported mkdir */ function mkdir(directoryPath) { fileUtilities.mkdir(new java.io.File(directoryPath)) } @@ -13,7 +14,8 @@ function mkdir(directoryPath) { * check if file exists * @param {string} filePath file path * @returns {boolean} true if file exists -*/ +* +* exported fileExists */ function fileExists(filePath) { return new java.io.File(filePath).exists(); } @@ -22,7 +24,8 @@ function fileExists(filePath) { * returns file content * @param {string} filePath file path * @returns {string} content -*/ +* +* exported cat */ function cat(filePath) { return Bean("fileUtilities").getFileContent(new java.io.File(filePath)); } @@ -31,7 +34,8 @@ function cat(filePath) { * copies file * @param {string} source source * @param {string} target target -*/ +* +* exported cp */ function cp(source, target) { return Bean("fileUtilities").copy(new java.io.File(source), new java.io.File(target)); } @@ -40,7 +44,8 @@ function cp(source, target) { * returns file size * @param {string} filePath file path * @returns {number} file size -*/ +* +* exported getFileSize */ function getFileSize(filePath) { return Bean("fileUtilities").getSize(new java.io.File(filePath)); } @@ -49,7 +54,8 @@ function getFileSize(filePath) { * returns file name * @param {string} filePath file path * @returns {string} file name -*/ +* +* exported fileName */ function fileName(filePath) { return new java.io.File(filePath).getName(); } @@ -58,7 +64,8 @@ function fileName(filePath) { * creates link * @param {string} target target * @param {string} destination destination -*/ +* +* exported lns */ function lns(target, destination) { return Bean("fileUtilities").createSymbolicLink(new java.io.File(destination), new java.io.File(target)); } @@ -66,7 +73,8 @@ function lns(target, destination) { /** * removes file * @param {string} filePath file path -*/ +* +* exported remove */ function remove(filePath) { return Bean("fileUtilities").remove(new java.io.File(filePath)); } @@ -74,7 +82,8 @@ function remove(filePath) { /** * creates empty file * @param {string} filePath file path -*/ +* +* exported touch */ function touch(filePath) { if (!fileExists(filePath)) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), ""); @@ -85,7 +94,8 @@ function touch(filePath) { * writes content into file * @param {string} filePath file path * @param {string} content content which shall be written -*/ +* +* exported touch */ function writeToFile(filePath, content) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), content); } @@ -94,7 +104,8 @@ function writeToFile(filePath, content) { * creates temporary file * @param {string} extension file extension * @returns {string} file path of created temporary file -*/ +* +* exported createTempFile */ function createTempFile(extension) { var tmpFile = Bean("fileUtilities").createTmpFile(extension); return tmpFile.getAbsolutePath(); From 769dcff31fd4a33a35aadf69b207e83ebdf2ef14 Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 20:51:16 +0200 Subject: [PATCH 6/7] Use "// eslint-disable-line no-unused-vars" --- Utils/Functions/Filesystem/Files/script.js | 55 +++++++++------------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index 742ac72c6a..31e6cf67ba 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -4,9 +4,8 @@ var fileUtilities = Bean("fileUtilities"); /** * creates directory * @param {string} directoryPath directory path -* -* exported mkdir */ -function mkdir(directoryPath) { +*/ +function mkdir(directoryPath) { // eslint-disable-line no-unused-vars fileUtilities.mkdir(new java.io.File(directoryPath)) } @@ -14,9 +13,8 @@ function mkdir(directoryPath) { * check if file exists * @param {string} filePath file path * @returns {boolean} true if file exists -* -* exported fileExists */ -function fileExists(filePath) { +*/ +function fileExists(filePath) { // eslint-disable-line no-unused-vars return new java.io.File(filePath).exists(); } @@ -24,9 +22,8 @@ function fileExists(filePath) { * returns file content * @param {string} filePath file path * @returns {string} content -* -* exported cat */ -function cat(filePath) { +*/ +function cat(filePath) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").getFileContent(new java.io.File(filePath)); } @@ -34,9 +31,8 @@ function cat(filePath) { * copies file * @param {string} source source * @param {string} target target -* -* exported cp */ -function cp(source, target) { +*/ +function cp(source, target) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").copy(new java.io.File(source), new java.io.File(target)); } @@ -44,9 +40,8 @@ function cp(source, target) { * returns file size * @param {string} filePath file path * @returns {number} file size -* -* exported getFileSize */ -function getFileSize(filePath) { +*/ +function getFileSize(filePath) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").getSize(new java.io.File(filePath)); } @@ -54,9 +49,8 @@ function getFileSize(filePath) { * returns file name * @param {string} filePath file path * @returns {string} file name -* -* exported fileName */ -function fileName(filePath) { +*/ +function fileName(filePath) { // eslint-disable-line no-unused-vars return new java.io.File(filePath).getName(); } @@ -64,27 +58,24 @@ function fileName(filePath) { * creates link * @param {string} target target * @param {string} destination destination -* -* exported lns */ -function lns(target, destination) { +*/ +function lns(target, destination) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").createSymbolicLink(new java.io.File(destination), new java.io.File(target)); } /** * removes file * @param {string} filePath file path -* -* exported remove */ -function remove(filePath) { +*/ +function remove(filePath) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").remove(new java.io.File(filePath)); } /** * creates empty file * @param {string} filePath file path -* -* exported touch */ -function touch(filePath) { +*/ +function touch(filePath) { // eslint-disable-line no-unused-vars if (!fileExists(filePath)) { Bean("fileUtilities").writeToFile(new java.io.File(filePath), ""); } @@ -94,9 +85,8 @@ function touch(filePath) { * writes content into file * @param {string} filePath file path * @param {string} content content which shall be written -* -* exported touch */ -function writeToFile(filePath, content) { +*/ +function writeToFile(filePath, content) { // eslint-disable-line no-unused-vars Bean("fileUtilities").writeToFile(new java.io.File(filePath), content); } @@ -104,9 +94,8 @@ function writeToFile(filePath, content) { * creates temporary file * @param {string} extension file extension * @returns {string} file path of created temporary file -* -* exported createTempFile */ -function createTempFile(extension) { +*/ +function createTempFile(extension) { // eslint-disable-line no-unused-vars var tmpFile = Bean("fileUtilities").createTmpFile(extension); return tmpFile.getAbsolutePath(); } From 33ebbece0838041b6c95e0b3688b001fa2fa40b5 Mon Sep 17 00:00:00 2001 From: Plata Date: Sat, 7 Apr 2018 21:00:44 +0200 Subject: [PATCH 7/7] Add missing @returns --- Utils/Functions/Filesystem/Files/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Utils/Functions/Filesystem/Files/script.js b/Utils/Functions/Filesystem/Files/script.js index 31e6cf67ba..b0caa569bd 100644 --- a/Utils/Functions/Filesystem/Files/script.js +++ b/Utils/Functions/Filesystem/Files/script.js @@ -4,6 +4,7 @@ var fileUtilities = Bean("fileUtilities"); /** * creates directory * @param {string} directoryPath directory path +* @returns {void} */ function mkdir(directoryPath) { // eslint-disable-line no-unused-vars fileUtilities.mkdir(new java.io.File(directoryPath)) @@ -31,6 +32,7 @@ function cat(filePath) { // eslint-disable-line no-unused-vars * copies file * @param {string} source source * @param {string} target target +* @returns {void} */ function cp(source, target) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").copy(new java.io.File(source), new java.io.File(target)); @@ -58,6 +60,7 @@ function fileName(filePath) { // eslint-disable-line no-unused-vars * creates link * @param {string} target target * @param {string} destination destination +* @returns {void} */ function lns(target, destination) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").createSymbolicLink(new java.io.File(destination), new java.io.File(target)); @@ -66,6 +69,7 @@ function lns(target, destination) { // eslint-disable-line no-unused-vars /** * removes file * @param {string} filePath file path +* @returns {void} */ function remove(filePath) { // eslint-disable-line no-unused-vars return Bean("fileUtilities").remove(new java.io.File(filePath)); @@ -74,6 +78,7 @@ function remove(filePath) { // eslint-disable-line no-unused-vars /** * creates empty file * @param {string} filePath file path +* @returns {void} */ function touch(filePath) { // eslint-disable-line no-unused-vars if (!fileExists(filePath)) { @@ -85,6 +90,7 @@ function touch(filePath) { // eslint-disable-line no-unused-vars * writes content into file * @param {string} filePath file path * @param {string} content content which shall be written +* @returns {void} */ function writeToFile(filePath, content) { // eslint-disable-line no-unused-vars Bean("fileUtilities").writeToFile(new java.io.File(filePath), content);