Пример #1
0
 public function validateFile($path, $flags = self::MUST_EXIST)
 {
     $errorDetail = NULL;
     if (!empty($path)) {
         $file = File::factory($path);
         // workaround file
         if (self::RESOLVE_RELATIVE && !Dir::isAbsolutePath((string) $file->getDirectory()) && !$file->isRelative()) {
             $file->setDirectory(new Dir('.' . DIRECTORY_SEPARATOR . $file->getDirectory()));
         }
         $file->resolvePath();
         if (!($flags & self::MUST_EXIST) || $file->exists()) {
             return $file;
         } else {
             $errorDetail = ' It must exist!';
         }
     }
     throw $this->exitException(sprintf("File from path: '%s' cannot be found.%s", $path, $errorDetail));
 }