Helper to get the parent file for a given file.

@param PhingFile $file

@return PhingFile Parent file or null if none
326335
private function _getParentFile(PhingFile $file)
    {
        $filename = $file->getAbsolutePath();
        $file = new PhingFile($filename);
        $filename = $file->getParent();

        return ($filename === null) ? null : new PhingFile($filename);
    }
384588
protected function loadFile($file)
    {
        if (class_exists('Symfony\Component\Config\Util\XmlUtils')) {
            $dom = XmlUtils::loadFile($file);
            $this->validate($dom);

            return $dom;
        }

        return parent::loadFile($file);
    }
63624
public function getResourceByFile(File $file) {
        if (isset($this->resources[md5($file->getAbsolutePath())])) {
            return $this->resources[md5($file->getAbsolutePath())];
        } else {
            return null;
        }
    }
270990
public function findOriginalFileToVersion(File $file)
    {
        if(!$this->containsFile($file)){
            return null;
        }

        preg_match("/([^-]+)(-.*)?/", $file->getBasename(), $matches);
        $ext = $file->getExtension() == ""?"":".".$file->getExtension();
        return new FileImpl($file->getParentFolder()->getAbsolutePath()."/".$matches[1].$ext);
    }
842693
static function find_file($file, $base = '/')
	{
		if(file_exists($file) && is_readable($file))
			return $file;

		foreach(bors_dirs() as $dir)
			if(file_exists($fn = $dir.$base.'/'.$file) && is_readable($fn))
				return $fn;

		return NULL;
	}
212748
public function get($type, $file = null)
    {
        if (!isset($this->paths[$type])) {
            $method = 'get'.Utils::camelize($type).'Dir';

            if (!method_exists($this, $method)) {
                return null;
            }

            $this->set($type, $this->$method());
        }

        $path = $this->paths[$type];
        if ($file) {
            if ($path instanceof pathmanager\FallbackInterface) {
                $path = $path->resolve($file);
            } else {
                $path .= '/' . ltrim($file, '/');
            }
        }

        return $path;
    }
1156692
public File getParentFile() {
        String tempParent = getParent();
        if (tempParent == null) {
            return null;
        }
        return new File(tempParent);
    }
754553
public function getParent()
    {
        $parentID = $this->getField("ParentID");
        if ($parentID) {
            return SiteTree::get_by_id(self::class, $parentID);
        }
        return null;
    }
994951
private function getProperties(PhingFile $file)
    {
        // load() already made sure that file is readable
        // but we'll double check that when reading the file into
        // an array

        if ((@file($file)) === false) {
            throw new IOException("Unable to parse contents of $file");
        }

        $prop = new Properties();

        $xml = simplexml_load_string(file_get_contents($file));

        if ($xml === false) {
            throw new IOException("Unable to parse XML file $file");
        }

        $path = [];

        if ($this->keepRoot) {
            $path[] = dom_import_simplexml($xml)->tagName;

            $prefix = implode('.', $path);

            if (!empty($prefix)) {
                $prefix .= '.';
            }

            // Check for attributes
            foreach ($xml->attributes() as $attribute => $val) {
                if ($this->collapseAttr) {
                    $prop->setProperty($prefix . (string) $attribute, (string) $val);
                } else {
                    $prop->setProperty($prefix . "($attribute)", (string) $val);
                }
            }
        }

        $this->addNode($xml, $path, $prop);

        return $prop;
    }
1267114
protected final function getParent()
	{
		if($this->parent === false)
		{
			if(NULL === ($file = $this->getExtended()))
			{
				$this->parent = NULL;
			}
			else
			{
				$typeName = $this->factory->createView($this->renderer, $this->resolveResource($file));
				
				$this->parent = new $typeName($this->factory, $this->renderer);
				$this->parent->inherit($this->context, $this->exp);
			}
		}
		
		return $this->parent;
	}
676819
protected function importFile(PhingFile $file)
    {
        $ctx = $this->project->getReference(ProjectConfigurator::PARSING_CONTEXT_REFERENCE);
        $cfg = $ctx->getConfigurator();
        // Import xml file into current project scope
        // Since this is delayed until after the importing file has been
        // processed, the properties and targets of this new file may not take
        // effect if they have alreday been defined in the outer scope.
        $this->log(
            "Importing file {$file->getAbsolutePath()} from "
            . $this->getLocation()->getFileName(),
            Project::MSG_VERBOSE
        );
        ProjectConfigurator::configureProject($this->project, $file);
    }
1238352
public static function getRoot(NodeInterface $parent): ?PhpFileModelInterface
    {
        while ($parent !== null) {
            if ($parent instanceof PhpFileModelInterface) {
                return $parent;
            }
            $parent = $parent->getParentNode();
        }
        return null;
    }
233642
protected function loadFile(PhingFile $file)
    {
        $fileParser = $this->fileParserFactory->createParser($file->getFileExtension());
        $props = new Properties(null, $fileParser);
        $this->log("Loading " . $file->getAbsolutePath(), $this->logOutput ? Project::MSG_INFO : Project::MSG_VERBOSE);
        try { // try to load file
            if ($file->exists()) {
                $props->load($file);
                $this->addProperties($props);
            } else {
                $this->log(
                    "Unable to find property file: " . $file->getAbsolutePath() . "... skipped",
                    $this->quiet ? Project::MSG_VERBOSE : Project::MSG_WARN
                );
            }
        } catch (IOException $ioe) {
            throw new BuildException("Could not load properties from file.", $ioe);
        }
    }
88180
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
229445
protected function getFileContents($file)
    {
        if ($file instanceof ModuleResource) {
            $path = $file->getPath();
        } else {
            $path = Director::baseFolder() . '/' . $file;
        }
        if (!file_exists($path)) {
            return null;
        }
        $content = file_get_contents($path);

        // Remove UTF-8 BOM
        if (substr($content, 0, 3) === pack("CCC", 0xef, 0xbb, 0xbf)) {
            $content = substr($content, 3);
        }

        return $content;
    }
422279
def GetParentFileEntry(self):
    
    location = getattr(self.path_spec, 'location', None)
    if location is not None:
      parent_location = self._file_system.DirnamePath(location)
      if parent_location == '':
        parent_location = self._file_system.PATH_SEPARATOR

    parent_file_reference = None
    mft_attribute = getattr(self.path_spec, 'mft_attribute', None)
    if mft_attribute is not None:
      parent_file_reference = (
          self._fsntfs_file_entry.get_parent_file_reference_by_attribute_index(
              mft_attribute))
    else:
      parent_file_reference = (
          self._fsntfs_file_entry.get_parent_file_reference())

    if parent_file_reference is None:
      return None

    parent_mft_entry = (
        parent_file_reference & _FILE_REFERENCE_MFT_ENTRY_BITMASK)

    parent_path_spec = getattr(self.path_spec, 'parent', None)
    # TODO: determine and pass the mft_attribute of the parent
    # for a faster resolve of the file entry.
    path_spec = ntfs_path_spec.NTFSPathSpec(
        location=parent_location, mft_entry=parent_mft_entry,
        parent=parent_path_spec)

    # TODO: handle parent correctly use attribute index?
    is_root = bool(
        parent_location == self._file_system.LOCATION_ROOT or
        parent_mft_entry == self._file_system.MFT_ENTRY_ROOT_DIRECTORY)

    return NTFSFileEntry(
        self._resolver_context, self._file_system, path_spec, is_root=is_root)
65776
public function setDestFile(PhingFile $file)
    {
        $this->cmd->createArgument()->setValue('-o');
        $this->cmd->createArgument()->setFile($file);
    }