encoding === 'utf-8') { return $localname; } $textlib = textlib_get_instance(); $converted = $textlib->convert($localname, 'utf-8', $this->encoding); $original = $textlib->convert($converted, $this->encoding, 'utf-8'); if ($original === $localname) { $result = $converted; } else { // try ascci conversion $converted2 = $textlib->specialtoascii($localname); $converted2 = $textlib->convert($converted2, 'utf-8', $this->encoding); $original2 = $textlib->convert($converted, $this->encoding, 'utf-8'); if ($original2 === $localname) { //this looks much better $result = $converted2; } else { //bad luck - the file name may not be usable at all $result = $converted; } } $result = ereg_replace('\.\.+', '', $result); $result = ltrim($result); // no leadin / if ($result === '.') { $result = ''; } return $result; } /** * Tries to convert $localname into utf-8 * please note that it may fail really badly. * The resulting file name is cleaned. * * @param strin $localname in anothe encoding * @return string in utf-8 */ protected function unmangle_pathname($localname) { if ($this->encoding === 'utf-8') { return $localname; } $textlib = textlib_get_instance(); $result = $textlib->convert($localname, $this->encoding, 'utf-8'); $result = clean_param($result, PARAM_PATH); $result = ltrim($result); // no leadin / return $result; } /** * Returns current file info * @return object */ //public abstract function current(); /** * Returns the index of current file * @return int current file index */ //public abstract function key(); /** * Moves forward to next file * @return void */ //public abstract function next(); /** * Revinds back to the first file * @return void */ //public abstract function rewind(); /** * Did we reach the end? * @return boolean */ //public abstract function valid(); }