Пример #1
0
 /**
  *
  */
 protected function setHelperAppsDir()
 {
     // Needed for Windows only:
     // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
     //   as well as other helper functions such as head, tail, md5sum, etc
     // This path cannot contain spaces, but the below code will attempt to get the
     //   8.3-equivalent path automatically
     // IMPORTANT: This path must include the trailing slash
     if (self::$EnvironmentIsWindows && null === self::$HelperAppsDir) {
         $helperappsdir = self::$IncludePath . 'Resources' . DIRECTORY_SEPARATOR . 'helperapps';
         // must not have any space in this path
         if (!is_dir($helperappsdir)) {
             $this->startup_warning .= '"' . $helperappsdir . '" cannot be defined as self::getHelperAppsDir() because it does not exist';
         } elseif (strpos(realpath($helperappsdir), ' ') !== false) {
             $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
             $path_so_far = array();
             foreach ($DirPieces as $key => $value) {
                 if (strpos($value, ' ') !== false) {
                     if (!empty($path_so_far)) {
                         $commandline = 'dir /x ' . escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
                         $dir_listing = `{$commandline}`;
                         $lines = explode("\n", $dir_listing);
                         foreach ($lines as $line) {
                             $line = trim($line);
                             if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(<DIR>|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
                                 list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
                                 if (strtoupper($filesize) == '<DIR>' && strtolower($filename) == strtolower($value)) {
                                     $value = $shortname;
                                 }
                             }
                         }
                     } else {
                         $this->startup_warning .= 'self::getHelperAppsDir() must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
                     }
                 }
                 $path_so_far[] = $value;
             }
             $helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
         }
         self::$HelperAppsDir = $helperappsdir . DIRECTORY_SEPARATOR;
     }
 }