changeset 942:7fa6c39ef851

Moar work.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 28 Nov 2014 06:11:30 +0200
parents f3c6c56098ed
children f1c2cce5a5d5
files faptool.php
diffstat 1 files changed, 36 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/faptool.php	Fri Nov 28 00:49:47 2014 +0200
+++ b/faptool.php	Fri Nov 28 06:11:30 2014 +0200
@@ -247,7 +247,7 @@
       return FALSE;
     }
 
-    $done = FALSE;
+    $found = FALSE;
     $edata = $fileTypeData[$efile["filetype"]];
 
     if ($edata["class"] == EFILE_ARCHIVE)
@@ -261,7 +261,6 @@
         return FALSE;
 
       // Scan through files ...
-      $done = FALSE;
       $dir = opendir($path);
       while (($dentry = readdir($dir)) !== false)
       {
@@ -269,12 +268,14 @@
         if (is_file($fname))
         {
           echo $fname."\n";
+          // check file type against entry's preview_type
+          // if match, render / convert / cp to as source and exit loop.
         }
       }
       closedir($dir);
 
       wtPurgeDir($path);
-    }
+    } // archive
 //    else
 //      $done = wtRenderConvertEntryToSource();
     
@@ -287,22 +288,26 @@
 
   // Either we now have a sourcefile or generated file
 /*
-  if (source == audio)
-  {
-    wtConvertSample();
-  }
-  else
-  if (source == image)
+  switch (source)
   {
-    wtConvertImage($inFilename,
-      stMakePath(FALSE, TRUE, array($setPreviewPath, $compo["cpath"], $filename)),
-      "previewImageSize", "previewImageType",
-      "previewImageQuality", FALSE);
+    case audio:
+      foreach (...)
+      {
+        wtConvertSample();
+      }
+      break;
+    
+    case image:
+      wtConvertImage($inFilename,
+        stMakePath(FALSE, TRUE, array($setPreviewPath, $compo["cpath"], $filename)),
+        "previewImageSize", "previewImageType",
+        "previewImageQuality", FALSE);
 
-    wtConvertImage($inFilename,
-      stMakePath(FALSE, TRUE, array($setPreviewPath, $compo["cpath"], $setThumbPath, $filename)),
-      "previewThumbSize", "previewThumbType",
-      "previewThumbQuality", TRUE);
+      wtConvertImage($inFilename,
+        stMakePath(FALSE, TRUE, array($setPreviewPath, $compo["cpath"], $setThumbPath, $filename)),
+        "previewThumbSize", "previewThumbType",
+        "previewThumbQuality", TRUE);
+      break;
   }
 */
   return TRUE;
@@ -343,10 +348,22 @@
 
 function wtPurgeDir($path)
 {
-  if (file_exists($path))
+  if ($path != "" && $path !== false && file_exists($path) && is_dir($path))
   {
     echo "PURGING: ".$path."\n";
-    //wtExecOrDie("/bin/echo", "-fR ".escapeshellarg($path));
+    foreach (scandir($path) as $file)
+    if ($file !== "." && $file !== "..")
+    {
+      $sub = $path."/".$file;
+      if (is_dir($sub))
+        wtPurgeDir($sub);
+      else
+      {
+        echo " - ".$sub."\n";
+        unlink($sub);
+      }
+    }
+    rmdir($path);
   }
 }