changeset 882:25bcbd6d5682

Moar work on the tool.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 26 Nov 2014 16:33:25 +0200
parents 7c805dccd4f7
children 782c42dfc465
files faptool.php
diffstat 1 files changed, 125 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
 //