# HG changeset patch # User Matti Hamalainen # Date 1417012405 -7200 # Node ID 25bcbd6d5682cc6cc5eb4906d52cac4491eeac67 # Parent 7c805dccd4f7ac38ab15e2ebf009149c275f1015 Moar work on the tool. diff -r 7c805dccd4f7 -r 25bcbd6d5682 faptool.php --- a/faptool.php Wed Nov 26 16:31:40 2014 +0200 +++ b/faptool.php Wed Nov 26 16:33:25 2014 +0200 @@ -6,6 +6,131 @@ stCheckCLIExec(); +function wtExecOrDie($exe, $args) +{ + echo "EXEC: ".$exe." ".$args."\n"; + //passthru($exe." ".$args) == 0 or die("Error executing ".$exe.":\n".$args); +} + + +function wtConvertImage($inFilename, $inFileType, $outFilename, $setDim, $setFormat, $setQuality, $thumb) +{ + global $setPreviewPath; + + if (($outDim = stGetSetting($setDim)) === FALSE || + ($outFormat = stGetSetting($osetFormat)) === FALSE || + ($outQuality = stGetSetting($setQuality)) === FALSE) + { + die("Missing one of res/format/quality settings for '".$outFilename."'\n"); + } + + // convert -resize 640x480 -background black -gravity center -extent 640x480 + // -unsharp "0x0.75+0.75+0.008" lol.lbm -quality 95 test.jpg +} + + +function wtRenderSample() +{ + $sfreq = intval(stGetSetting("sampleFreq", 44100)); + $sduration = intval(stGetSetting("sampleDuration", 30)); + $schannels = intval(stGetSetting("sampleChannels", 1)); + +} + + +function wtConvertSample() +{ + $sfreq = intval(stGetSetting("sampleFreq", 44100)); + $sduration = intval(stGetSetting("sampleDuration", 30)); + $schannels = intval(stGetSetting("sampleChannels", 1)); + +} + + +function wtPurgeDir($path) +{ + if (file_exists($path)) + wtExecOrDie("/bin/echo", "-fR ".escapeshellarg($path)); +} + + +function wtScanArchive($compo, $efile, $filename) +{ + global $setEntryPath; + + $path = stMakePath(FALSE, FALSE, array($setEntryPath, "UNPACKS", $filename)); + + echo "Attempting to scan archive file '".$filename."' ...\n"; + + // Check file type before doing anything + switch ($efile["id"]) + { + case "LHA": + $exe = "/usr/bin/lha"; + $args = "e ".escapeshellarg($filename); + break; + + case "ZIP": + $exe = "/usr/bin/unzip"; + $args = "-d ".escapeshellarg($path)." ".escapeshellarg($filename); + break; + + default: + die("Unsupported archive file type: ".$efile["id"]."\n"); + } + + // Create temporary directory + wtPurgeDir($path); + stMakeDir($path, 0700); + + if (!is_dir($path) || chdir($path) === false) + die("Failed to chdir to ".$path."\n"); + + // Unpack archive + wtExecOrDie($exe, $args); + + // Scan through files ... + $dir = opendir($path); + while (($dentry = readdir($dir)) !== false) + { + } + closedir($dir); + + wtPurgeDir($path); +} + + +function wtHandleEntryPreview($compo, $entry, $mode) +{ +/* + if (previewFile does not exist || previewFile older than entryFile) + { + if (entry is module file) + { + render sample + } + else + if (entry is image file) + { + convert image + } + } + + // Based on compo / entry preview type .. + + // Convert preview image file, if any + // Create thumbnail for it, too + wtConvertImage($inFilename, $outFilename, + "previewImageSize", "previewImageType", + "previewImageQuality", FALSE); + + wtConvertImage($inFilename, $outFilename, + "previewThumbSize", "previewThumbType", + "previewThumbQuality", TRUE); +*/ +} + + // // Create directories //