예제 #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 testRemoveObjectsInArrayWithRTArray()
 {
     $mArray = RTMutableArray::anArray();
     $mArray->addObjectsFromArray(array("42", 42, TRUE, FALSE));
     $mArray->removeObjectsInArray(RTArray::arrayWithObjects("42", TRUE));
     $this->assertEquals(2, $mArray->count());
     $this->assertSame(42, $mArray->objectAtIndex(0));
     $this->assertEquals(FALSE, $mArray->objectAtIndex(1));
 }