Finds files attached to "uploads" content elements
returns them as file reference objects array
@author Christian Bülter <buelter@kennziffer.com>
@since 24.09.13
@param array $ttContentRow content element
@return array
487895
public function findAttachedFiles($ttContentRow)
    {
        // Set current data
        $this->cObj->data = $ttContentRow;

        // Get files by filesProcessor
        $processedData = [];
        $processedData = $this->filesProcessor->process($this->cObj, [], $this->filesProcessorConfiguration, $processedData);
        $fileReferenceObjects = $processedData['files'];

        return $fileReferenceObjects;
    }
1323446
public function getIncludedFiles(): array
    {
        if ($this->filesIncluded === null) {
            throw new UnexpectedValueException('Must call scan() first');
        }

        sort($this->filesIncluded);

        return $this->filesIncluded;
    }
441306
public function attachPostFiles($files)
    {
        if (is_array($files)) {
            foreach ($files as $file) {
                // Check whether file has been posted.
                if (is_uploaded_file($file['tmp_name'])) {
                    // Get file from its location.
                    $fileContents = file_get_contents($file['tmp_name']);
                    if ($fileContents) {
                        $this->addAttachment(
                                $file['name'], $file['type'], $fileContents
                        );
                    } else {
                        throw new Exception('Empty attachment');
                    }
                } else {
                    switch ($file['error']) {
                        case 0:
                            throw new Exception('Illegal file: ' . $file['name']);
                            break;
                        case 1:
                        case 2:
                            throw new Exception('File too large');
                            break;
                        case 3:
                            throw new Exception('File truncated');
                            break;
                        case 4:
                            // File slot is empty. Just skip it.
                            break;
                        default:
                            throw new EixMailMessageBadAttachmentException();
                            break;
                    }
                }
            }
        } else {
            throw new Exception('Unrecognised format');
        }
    }
61023
public function getFileContent()
    {
        $file = $this->getAttribute('file');
        if (empty($file) && !$this->getIsNewRecord()) {
            $file = $this->refreshFile();
        }

        if (empty($file)) {
            return null;
        } elseif ($file instanceof Download) {
            $fileSize = $file->getSize();
            return empty($fileSize) ? null : $file->toString();
        } elseif ($file instanceof UploadedFile) {
            return file_get_contents($file->tempName);
        } elseif (is_string($file)) {
            if (file_exists($file)) {
                return file_get_contents($file);
            }
            throw new InvalidParamException("File '{$file}' does not exist.");
        }

        throw new InvalidParamException('Unsupported type of "file" attribute.');
    }
201046
public function listContents($path = '', $recursive = false)
    {
        $location = $this->applyPathPrefix($path);

        try {
            $files = $this->share->dir($location);
        } catch (InvalidTypeException $e) {
            return [];
        } catch (NotFoundException $e) {
            return [];
        }

        $result = [];

        foreach ($files as $file) {
            $result[] = $this->normalizeFileInfo($file);

            if ($file->isDirectory() && $recursive) {
                $result = array_merge($result, $this->listContents($this->getFilePath($file), true));
            }
        }

        return $result;
    }
869772
public function extractContentAndSaveToIndex($files)
    {
        $counter = 0;
        if (is_array($files) && count($files)) {
            foreach ($files as $file) {
                if ($this->fileInfo->setFile($file)) {
                    // get file content, check if we have a FAL resource or a simple
                    // string containing the path to the file
                    if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
                        $content = $this->getFileContent($file->getForLocalProcessing(false));
                    } else {
                        $content = $this->getFileContent($file);
                    }

                    if (!($content === false)) {
                        $this->storeToIndex($file, $content);
                        $counter++;
                    }
                }
            }
        }

        return $counter;
    }
497931
public function parseAnnotations($fileContents)
    {
        $ret = array();
        if (preg_match('/^#\s*@(\w+)[:=]?\s+([\'"])?(.*)\2\s*$/m', $fileContents, $m)) {
            $ret[$m[1]] = $m[3];
        }
        return $ret;
    }
651592
private function _getFileContent()
	{
		if ( !isset( $this->_index_file_content ) )
		{
			if ( !( $this->_index_file_content = file_get_contents( $this->_root_page_path ) ) )
			{
				trigger_error( "Root file not found. Please, validate the path.", E_USER_ERROR );
			}
		}

		return $this->_index_file_content;
	}
166837
public function extractModelInfoFromSource($fileContents)
    {
        $stream = new PhpSourceStream($fileContents);

        $result = [];

        while ($stream->forward()) {
            $tokenCode = $stream->getCurrentCode();

            if ($tokenCode == T_NAMESPACE) {
                $namespace = $this->extractNamespace($stream);
                if ($namespace === null) {
                    return null;
                }

                $result['namespace'] = $namespace;
            }

            if ($tokenCode == T_CLASS && !isset($result['class'])) {
                $className = $this->extractClassName($stream);
                if ($className === null) {
                    return null;
                }

                $result['class'] = $className;
            }

            if ($tokenCode == T_PUBLIC || $tokenCode == T_PROTECTED) {
                $tableName = $this->extractTableName($stream);
                if ($tableName === false) {
                    continue;
                }

                if ($tableName === null) {
                    return null;
                }

                $result['table'] = $tableName;
            }
        }

        if (!$result) {
            return null;
        }

        return $result;
    }
145732
public function getFileList()
    {
        $allfiles = [];

        foreach ($this->filesets as $fs) {
            $ds = $fs->getDirectoryScanner($this->project);

            $files = $ds->getIncludedFiles();

            // We need to store these files keyed by the basedir from DirectoryScanner
            // so that we can resolve the fullpath of the file later.
            if (isset($allfiles[$ds->getBasedir()])) {
                $allfiles[$ds->getBasedir()] = array_merge($allfiles[$ds->getBasedir()], $files);
            } else {
                $allfiles[$ds->getBasedir()] = $files;
            }
        }

        $struc = [];

        foreach ($allfiles as $basedir => $files) {
            foreach ($files as $file) {
                // paths are relative to $basedir above
                $path = strtr(dirname($file), DIRECTORY_SEPARATOR, '/');

                if (!$path || $path == '.') {
                    $path = '/'; // for array index
                }

                $parts = explode('.', basename($file));
                $ext = array_pop($parts);
                if (strlen($ext) == strlen($file)) {
                    $ext = '';
                }

                $f = new PhingFile($basedir, $file);

                $struc[$path][] = [
                    'file' => basename($file),
                    'ext' => $ext,
                    'path' => (($path == '/') ? basename($file) : $path . '/' . basename($file)),
                    'fullpath' => $f->getAbsolutePath()
                ];
            }
        }

        uksort($struc, 'strnatcasecmp');
        foreach ($struc as $key => $ind) {
            usort($ind, [$this, 'sortfiles']);
            $struc[$key] = $ind;
        }

        $tempstruc = $struc;
        $struc = ['/' => $tempstruc['/']];
        $bv = 0;
        foreach ($tempstruc as $key => $ind) {
            $save = $key;
            if ($key != '/') {
                $struc['/'] = $this->setupDirs($struc['/'], explode('/', $key), $tempstruc[$key]);
            }
        }
        uksort($struc['/'], [$this, 'mystrucsort']);

        return $struc;
    }
652160
public function getUploadFileNames($systemArray=false)
	{
		if ($systemArray)
		{
			return $_FILES;
		}
		else
		{
			$ret = array();
			foreach($_FILES as $file => $property)
			{
				$ret[$file] = $property["name"];
			}
		}
		return $ret;
	}
193895
public function getFileContents() : string
    {
        // No point in continuing if there is no file assigned to this frame.
        if (!$this->file || $this->file === 'Unknown') {
            return '';
        }

        // If the contents aren't cached yet, grab them into our rudimentary in-memory cache.
        // Note: This may cache a boolean false if the retrieval fails for whatever reason. We're gonna handle
        // that afterwards and return an empty string instead.
        if (!isset(static::$files[$this->file])) {
            static::$files[$this->file] = file_get_contents($this->file);
        }

        // Return the cached contents of the file or an empty string if no contents could be fetched.
        return static::$files[$this->file] ?: '';
    }
174928
public function getFiles($extension = NULL) {

		$result = [];
		$glob = $this->path . '*';

		if(!is_null($extension)) {
			$glob .= ".$extension";
		}

		foreach(array_filter(glob($glob), 'is_file') as $f) {
			$result[] = FilesystemFile::getInstance($f, $this);
		}

		return $result;
	}
522103
public function get_files($includedirs = true, $updatedsince = 0) {
        $fs = get_file_storage();
        return $fs->get_area_files($this->lesson->context->id, 'mod_lesson', 'page_contents', $this->properties->id,
                                    'itemid, filepath, filename', $includedirs, $updatedsince);
    }
956045
public function getFiles() : array
    {
        $files = [];

        if (!empty($_FILES)) {
            foreach ($_FILES as $inputName => $phpFile) {
                if (!is_array($phpFile['name'])) {

                    // When this was a single file
                    $files[$inputName] = $this->handleUniqueFile($phpFile);
                } else {

                    //When the input has a 'multiple' attribute
                    $files[$inputName] = $this->handleMultipleFile($phpFile);
                }
            }
        }

        return $files;
    }
1259216
public function getUploadParams()
    {
        if ($this->type === self::TYPE_URL) {
            return [
                'json' => array_merge($this->getAdditionalAttributes(), ['file' => $this->file]),
            ];
        }

        if ($this->type === self::TYPE_MULTIPART) {
            $params[] = [
                'name' => 'file',
                'contents' => fopen($this->file, 'r'),
            ];

            foreach ($this->getAdditionalAttributes() as $key => $value) {
                $params[] = [
                    'name' => $key,
                    'contents' => $value,
                ];
            }

            return [
                'multipart' => $params
            ];
        }

        return null;
    }
819909
protected function getSourcesContent()
    {
        if (empty($this->sources)) {
            return null;
        }

        $content = array();

        foreach ($this->sources as $sourceFile) {
            $content[] = file_get_contents($sourceFile);
        }

        return $content;
    }