# HG changeset patch # User Matti Hamalainen # Date 1417147890 -7200 # Node ID 7fa6c39ef851c74de9a183914be96e2cda570897 # Parent f3c6c56098edf4a297a9fc41d831731a31d40048 Moar work. diff -r f3c6c56098ed -r 7fa6c39ef851 faptool.php --- 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); } }