protected function _globDir($aDir, RTArray &$results) { if (!is_dir($aDir)) { return; } $contents = scandir($aDir); $validator = FileNameValidator::alloc()->init(); $fullPathToNode = ""; foreach ($contents as $node) { $fullPathToNode = $aDir->stringByAppendingPathComponent(RTString::stringWithString($node)); // If the node represents a directory but does not start with a "." // character... if (is_dir($fullPathToNode) && strpos($node, ".") !== 0) { $arr = RTMutableArray::anArray(); $this->_globDir($fullPathToNode, $arr); $results->addObject(RTDictionary::dictionaryWithObject_forKey($arr, $node)); } else { if ($validator->isValidFileName($node) == YES) { try { // See if we can parse the plist file $dict = RTDictionary::dictionaryWithContentsOfFile(RTString::stringWithString($fullPathToNode)); // $node is a valid plist if ($dict->count() !== 0) { $results->addObject($node); } } catch (Exception $e) { // $node is not a valid plist $results->addObject("(PARSE_ERROR) " . $node); } } } } }
public function read() { if ($this->targetIsDirectory()) { throw new Exception("Class 'Read' cannot parse a directory '" . $this->fullPathToTarget() . "'", MFInvalidTargetForActionError); } try { $dict = RTDictionary::dictionaryWithContentsOfFile($this->fullPathToTarget()); if ($dict->allKeys()->count() == 0) { throw new Exception("Invalid plist specified in '" . $this->fullPathToTarget() . "'", MFParseError); } return $dict; } catch (Exception $e) { throw new Exception("Unable to parse plist at '" . $this->fullPathToTarget() . "'", MFParseError); } }