Beispiel #1
0
 function lists($filenameFilter = NULL)
 {
     $path = StringBuffer::toStringBuffer($this->getFilePath());
     if (!isset($path)) {
         return array();
     }
     $filter = FilenameFilter::validClass($filenameFilter) ? $filenameFilter : new FilenameFilter();
     $files = array();
     $folders = array();
     if ($this->exists() && $this->isDirectory()) {
         $path = $path->replace('/', DIRECTORY_SEPARATOR);
         if (!$path->endsWith(DIRECTORY_SEPARATOR)) {
             $path->append(DIRECTORY_SEPARATOR);
         }
         $handle = opendir($path->toString());
         while ($file = readdir($handle)) {
             $filename = new StringBuffer($file);
             if (!$filename->equals('.') && !$filename->equals('..')) {
                 $filename->prepend($path);
                 $validfile = new File($filename);
                 if ($filter->accept($validfile, $validfile->getParentDirectory())) {
                     if ($validfile->isFile()) {
                         $files[] = $filename->toString();
                     } else {
                         if ($validfile->isDirectory()) {
                             $folders[] = $filename->toString();
                         }
                     }
                 }
             }
         }
         closedir($handle);
     }
     return array_merge($folders, $files);
 }
Beispiel #2
0
 public function toString()
 {
     $sb = new StringBuffer("package ");
     $sb->append($this->name . " ");
     if ($this->specTitle) {
         $sb->append($this->specTitle . " ");
     }
     if ($this->specVersion) {
         $sb->append($this->specVersion . " ");
     }
     return $sb->toString();
 }
 function loadFromStream($filename)
 {
     $buffers = new StringBuffer();
     $file = NULL;
     if (File::validClass($filename)) {
         $file = $filename;
     } else {
         $file = new File($filename);
     }
     $filereader = new FileReader($file);
     while ($c = $filereader->read()) {
         $buffers->append($c);
     }
     $this->str = $buffers->toString();
 }
Beispiel #4
0
 function loadFromFile()
 {
     $configname = new StringBuffer();
     $buffers = new StringBuffer();
     $conf = NULL;
     $key = '';
     $value = '';
     $skipline = 0;
     $c = '';
     if ($this->reader->ready()) {
         while (($c = $this->reader->read()) != '') {
             if ($c == CONFIG_END_KEY) {
                 if (isset($conf) && $buffers->length() > 0) {
                     $buffers = $buffers->trimAll();
                     if (!$buffers->startsWith(CONFIG_COMMENT)) {
                         $key_separator_pos = $buffers->indexOf('=');
                         if ($buffers->startsWith(MULTICONFIG_START) && $buffers->endsWith(MULTICONFIG_END)) {
                             if ($conf->size() > 0) {
                                 $this->put($configname->toString(), $conf);
                             }
                             $i = $buffers->indexOf(':') + 1;
                             $configname = $buffers->substring($i, $buffers->length() - 1);
                             $conf = new Hashtable();
                         } else {
                             if ($key_separator_pos > 0) {
                                 $key = $buffers->substring(0, $key_separator_pos);
                                 $key = $key->trimAll();
                                 $value = $buffers->substring($key_separator_pos + 1);
                                 $value = $value->trimAll();
                                 if ($key->length() > 0 && $value->length() > 0) {
                                     $str = $conf->get($key->toString()) . $value->toString();
                                     $conf->put($key->toString(), $str);
                                 }
                             }
                         }
                     }
                 } else {
                     $buffers = $buffers->trimAll();
                     if ($buffers->startsWith(MULTICONFIG_START) && $buffers->endsWith(MULTICONFIG_END)) {
                         $i = $buffers->indexOf(':') + 1;
                         $configname = $buffers->substring($i, $buffers->length() - 1);
                         $conf = new Hashtable();
                     }
                 }
                 $buffers = new StringBuffer();
             } else {
                 $buffers->append($c);
             }
         }
         if ($buffers->length() > 0) {
             $key_separator_pos = $buffers->indexOf('=');
             if ($key_separator_pos > 0) {
                 $key = $buffers->substring(0, $key_separator_pos);
                 $key = $key->trimAll();
                 $value = $buffers->substring($key_separator_pos + 1);
                 $value = $value->trimAll();
                 if ($key->length() > 0 && $value->length() > 0) {
                     $conf->put($key->toString(), $value->toString());
                 }
             }
         }
         if (isset($conf) && $conf->size() > 0) {
             $this->put($configname, $conf);
         }
     }
 }