Пример #1
1
 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);
                 }
             }
         }
     }
 }
Пример #2
0
 public function testInsertObject_atIndex()
 {
     $array = RTMutableArray::arrayWithArray(array("42", 42, YES, NO));
     try {
         $array->insertObject_atIndex(null, 0);
         $this->fail("Should not be able to insert a null object");
     } catch (InvalidArgumentException $e) {
         try {
             $array->insertObject_atIndex("object", $array->count() + 1);
             $this->fail("Should not be able to add an object using an out of bounds index.");
         } catch (RTRangeException $e) {
             return;
         }
     }
     return fail("Expected specific exceptions to be thrown.");
 }
Пример #3
0
 /**
 		Returns the components of the URLs path as an array.
 		\returns RTArray
 */
 public function pathComponents()
 {
     $path = RTString::stringWithString($this->path());
     $components = RTMutableArray::arrayWithArray($path->componentsSeparatedByString("/"));
     if ($components->count() > 0) {
         $components->removeObjectAtIndex(0);
     }
     return RTArray::arrayWithArray($components);
 }