# HG changeset patch # User Matti Hamalainen # Date 1519905701 -7200 # Node ID da70f1c05ebe77ab2972ab407050513d72acea0f # Parent f48336b0e6a1f6600fd901f646eb1729de15ec07 Add few comments. diff -r f48336b0e6a1 -r da70f1c05ebe mgtool.php --- a/mgtool.php Thu Mar 01 13:39:07 2018 +0200 +++ b/mgtool.php Thu Mar 01 14:01:41 2018 +0200 @@ -247,6 +247,14 @@ } +// +// Parse a simple image captions file, with format of one entry per line. +// Lines starting with "# " are comments (note the whitespace), empty lines ignored. +// First continuous non-whitespace text is file/dirname, followed +// by caption text, which is separate with whitespace from the filename. +// Filenames starting with # will be made hidden entries. +// Filenames starging with % will hide contents. +// function mgReadCaptionsFile($galBasePath, $galPath) { $captions = []; @@ -276,6 +284,9 @@ } +// +// Create directory with specified permissions +// function mgMakeDir($path, $perm) { if (!file_exists($path)) @@ -287,6 +298,10 @@ } +// +// Print a simple yes/no prompt with given message +// and default value. +// function mgYesNoPrompt($msg, $default = FALSE) { echo $msg." [".($default ? "Y/n" : "y/N")."]? "; @@ -295,10 +310,13 @@ if ($default) return ($sprompt == "n"); else - return ($sprompt == "y"); + return $sprompt[0] == 'y'; } +// +// Delete given directory, with optional recursiveness. +// function mgDelete($path, $recurse) { global $flagDoDelete, $countDoDelete; @@ -332,6 +350,10 @@ } +// +// Check if we have received the quit signal +// and if yes, quit cleanly now. +// function mgCheckQuit($now = FALSE) { global $flagQuit;