Read FTS file data from the configured source and return a populated ProjectFile instance.

@return ProjectFile instance
518012
private ProjectFile read() throws Exception
   {
      m_project = new ProjectFile();
      m_eventManager = m_project.getEventManager();

      ProjectConfig config = m_project.getProjectConfig();
      config.setAutoCalendarUniqueID(false);
      config.setAutoTaskID(false);
      config.setAutoTaskUniqueID(false);
      config.setAutoResourceUniqueID(false);
      config.setAutoWBS(false);
      config.setAutoOutlineNumber(false);

      m_project.getProjectProperties().setFileApplication("FastTrack");
      m_project.getProjectProperties().setFileType("FTS");

      m_eventManager.addProjectListeners(m_projectListeners);

      // processProject();
      // processCalendars();
      processResources();
      processTasks();
      processDependencies();
      processAssignments();

      return m_project;
   }
1242327
private function parseFiles()
    {
        $parser = $this->app['parser'];
        $builder = $this->app['descriptor.builder'];

        $builder->createProjectDescriptor();
        $projectDescriptor = $builder->getProjectDescriptor();
        $projectDescriptor->setName($this->title);

        $paths = [];

        // filesets
        foreach ($this->filesets as $fs) {
            $ds = $fs->getDirectoryScanner($this->project);
            $dir = $fs->getDir($this->project);
            $srcFiles = $ds->getIncludedFiles();

            foreach ($srcFiles as $file) {
                $paths[] = $dir . FileSystem::getFileSystem()->getSeparator() . $file;
            }
        }

        $this->project->log("Will parse " . count($paths) . " file(s)", Project::MSG_VERBOSE);

        $files = new \phpDocumentor\Fileset\Collection();
        $files->addFiles($paths);

        $mapper = new \phpDocumentor\Descriptor\Cache\ProjectDescriptorMapper($this->app['descriptor.cache']);
        $mapper->garbageCollect($files);
        $mapper->populate($projectDescriptor);

        $parser->setPath($files->getProjectRoot());
        $parser->setDefaultPackageName($this->defaultPackageName);

        $parser->parse($builder, $files);

        $mapper->save($projectDescriptor);

        return $mapper;
    }
1150603
public function getFileInfo() {
    // Create a build list tag from the filename.
    $filename_pieces = explode('.', $this->component_data['filename']);
    if ($filename_pieces[0] == '%module') {
      // Take off the module name from the front.
      array_shift($filename_pieces);
    }
    if (in_array(end($filename_pieces), ['php', 'inc'])) {
      // Take off a file extenstion.
      array_pop($filename_pieces);
    }
    // Implode whatever's left.
    $file_key_tag = implode('.', $filename_pieces);

    return array(
      'path' => '', // Means base folder.
      'filename' => $this->component_data['filename'],
      'body' => $this->fileContents(),
      'build_list_tags' => ['code', $file_key_tag],
    );
  }
269478
protected function downloadToTmpFile()
    {
        $conn = $this->getFtpConnection();
        $file = $this->getFilename();
        $tmpFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . basename($file);

        $fileSize = $this->getSize();

        $mode = $this->getMode() ? constant('FTP_' . strtoupper($this->getMode())) : FTP_ASCII;

        $ret = ftp_nb_get($conn, $tmpFile, $file, $mode);
        $currentBytes = 0;
        while ($ret === FTP_MOREDATA) {
            $ret = ftp_nb_continue($conn);
            clearstatcache();
            $bytes = filesize($tmpFile);
            $diff = $bytes - $currentBytes;
            $currentBytes = $bytes;

            $this->eventDispatcher->dispatch(
                FeedEvents::FETCH_PROGRESS,
                new FetchProgressEvent($currentBytes, $diff, $fileSize)
            );
        }

        if ($ret !== FTP_FINISHED) {
            throw new TransportException(sprintf('Error downloading feed to %s', $tmpFile));
        }

        return $tmpFile;
    }
227374
public Reader getFile(String prefix, String postfix)
      throws MtasParserException {
    String file = getString();
    if ((file != null) && !file.equals("")) {
      if (prefix != null) {
        file = prefix + file;
      }
      if (postfix != null) {
        file = file + postfix;
      }
      Path path = (new File(file)).toPath();
      if(Files.isReadable(path)) {
        try {
          return new InputStreamReader(new GZIPInputStream(new FileInputStream(file)), StandardCharsets.UTF_8);
        } catch (IOException e1) {
          log.debug(e1);
          try {
            String text = new String(Files.readAllBytes(Paths.get(file)),
                StandardCharsets.UTF_8);
            return new StringReader(text);
          } catch (IOException e2) {
            log.debug(e2);
            throw new MtasParserException(e2.getMessage());
          }
        } 
      } else {
        throw new MtasParserException("file '"+file+"' does not exists or not readable");
      }
    } else {
      throw new MtasParserException("no valid file: " + file);
    }
  }
1026679
public function getFileContents()
    {
        $result = null;
        $fsl = $this->getFile()->getFileStorageLocationObject();
        if ($fsl !== null) {
            $app = Application::getFacadeApplication();
            $cf = $app->make('helper/concrete/file');
            try {
                $result = $fsl->getFileSystemObject()->read($cf->prefix($this->fvPrefix, $this->fvFilename));
                if ($result === false) {
                    $result = null;
                }
            } catch (FileNotFoundException $x) {
            }
        }

        return $result;
    }
673289
@Override
    public File getFile() throws IOException {
        try {
            return this.path.toFile();
        } catch (UnsupportedOperationException ex) {
            // only Paths on the default file system can be converted to a File
            // do exception translation for cases where conversion is not possible
            throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
        }
    }
1123389
protected function getFile()
    {
        $file = new SplFileObject($this->reflection->getFileName());

        $file->seek($this->reflection->getStartLine() - 1);

        return $file;
    }
957658
protected function getAnyData()
	{
		$filepoll = new AnydatasetFilenameProcessor("poll_list");
		$this->_anyPoll = new AnyDataset($filepoll->FullQualifiedNameAndPath());
		$fileanswer = new AnydatasetFilenameProcessor("poll_" . $this->_poll . "_" . $this->_lang);
		$this->_anyAnswer = new AnyDataset($fileanswer->FullQualifiedNameAndPath());
	}
687851
public ProjectFileHandler getProjectFile(final int projectId, final int version) {
    log.info(
        String.format("Fetching project file. project ID: %d version: %d", projectId, version));
    // TODO spyne: remove huge hack ! There should not be any special handling for Database Storage.
    if (this.storage instanceof DatabaseStorage) {
      return ((DatabaseStorage) this.storage).get(projectId, version);
    }

    /* Fetch meta data from db */
    final ProjectFileHandler pfh = this.projectLoader.fetchProjectMetaData(projectId, version);

    /* Fetch project file from storage and copy to local file */
    final String resourceId = requireNonNull(pfh.getResourceId(),
        String.format("URI is null. project ID: %d version: %d",
            pfh.getProjectId(), pfh.getVersion()));
    try (InputStream is = this.storage.get(resourceId)) {
      final File file = createTempOutputFile(pfh);

      /* Copy from storage to output stream */
      try (FileOutputStream fos = new FileOutputStream(file)) {
        IOUtils.copy(is, fos);
      }

      /* Validate checksum */
      validateChecksum(file, pfh);

      /* Attach file to handler */
      pfh.setLocalFile(file);

      return pfh;
    } catch (final IOException e) {
      throw new StorageException(e);
    }
  }
618072
@Override
    public File getFullFile(String pRelativePath) throws TTIOException, IOException {
        MetaValue value = (MetaValue)mPageReadTrx.getMetaBucket().get(new MetaKey(pRelativePath));

        File file =
            new File(new StringBuilder().append(mTmpDir.getAbsolutePath()).append(File.separator).append(
                pRelativePath).toString());

        if (file.exists()) {
            file.delete();
        }

        file.createNewFile();

        if (value.getData() == emptyFileKey) {
            return file;
        }

        FileData node = (FileData)mPageReadTrx.getData(value.getData());

        OutputSupplier<FileOutputStream> supplier = Files.newOutputStreamSupplier(file, true);

        // Iterating as long as we didn't find the end of the file
        // and writing the bytes to a temporary file.
        do {
            supplier.getOutput().write(node.getVal());
            node = (FileData)mPageReadTrx.getData(node.getDataKey() + 1);
        } while (!node.isEof());

        supplier.getOutput().close();

        return file;
    }
745255
public function getFile()
    {
        $key = $this->getKey();

        $tags = $this->getTags();

        if (!$this->cache->has($key, $tags)) {
            $this->loadFile();
        }

        return simplexml_load_string($this->cache->get($key, $tags));
    }
727669
protected function readLine()
    {
        if (! $this->valid()) {
            throw new Error('End of stream reached, no data to read');
        }
        $this->currentData = fgetcsv($this->fp, null, $this->delimiter, $this->enclosure);
        // Check if EOF is reached
        if (false === $this->currentData) {
            return false;
        } elseif (array(null) == $this->currentData) {
            /*
             * An empty line in the csv file
             * is returned as an array containing a NULL value.
             */
            if (! $this->ignoreEmptyLines) {
                throw new Error('Empty line found in file');
            }
            return $this->readLine();
        }
        $this->curLine++;

        if ($this->inputEncoding != $this->outputEncoding) {
            $inEnc = $this->inputEncoding;
            $outEnc = $this->outputEncoding;
            array_walk($this->currentData, function (&$str) use ($inEnc, $outEnc) {
                $str = mb_convert_encoding($str, $outEnc, $inEnc);
            });
        }

        return $this->currentData;
    }
716254
public function read()
    {
        $result = '';
        $ht = $this->getHTaccessFilename();
        $fs = $this->getFilesystem();
        if (@$fs->isFile($ht)) {
            $result = @$fs->get($ht);
            if ($result === false) {
                throw new Exception("Failed to read from file $ht");
            }
        }

        return $result;
    }
251224
public FileDefinition read() {

		// Parse blocks
		try {
			fillIn();
			mergeContiguousRegions( this.definitionFile.getBlocks());

		} catch( IOException e ) {
			addModelError( ErrorCode.P_IO_ERROR, this.currentLineNumber, exception( e ));
		}

		// Determine file type
		boolean hasFacets = false, hasComponents = false, hasInstances = false, hasImports = false;
		int ignorableBlocksCount = 0;
		for( AbstractBlock block : this.definitionFile.getBlocks()) {

			if( block.getInstructionType() == AbstractBlock.COMPONENT )
				hasComponents = true;

			else if( block.getInstructionType() == AbstractBlock.FACET )
				hasFacets = true;

			else if( block.getInstructionType() == AbstractBlock.INSTANCEOF )
				hasInstances = true;

			else if( block.getInstructionType() == AbstractBlock.IMPORT )
				hasImports = true;

			else if( block instanceof AbstractIgnorableInstruction )
				ignorableBlocksCount ++;
		}

		if( hasInstances ) {
			if( ! hasFacets && ! hasComponents )
				this.definitionFile.setFileType( FileDefinition.INSTANCE );
			else
				addModelError( ErrorCode.P_INVALID_FILE_TYPE, 1 );

		} else if( hasFacets || hasComponents ) {
			this.definitionFile.setFileType( FileDefinition.GRAPH );

		} else if( hasImports ) {
			this.definitionFile.setFileType( FileDefinition.AGGREGATOR );

		} else if( ignorableBlocksCount == this.definitionFile.getBlocks().size()) {
			addModelError( ErrorCode.P_EMPTY_FILE, 1 );
			this.definitionFile.setFileType( FileDefinition.EMPTY );
		}

		return this.definitionFile;
	}
416044
public function gatherFileData()
    {
        $files = get_included_files();
        $data = array();
        foreach ($files as $file) {
            array_push($data, array(
                'name' => $file,
                'size' => filesize($file)
            ));
        }
        return $data;
    }
530029
protected function readDatas()
    {
        if (is_file($this->file)) {
            try {
                $datas = include $this->file;
                if (!is_array($datas)) {
                    $datas = array();
                }
            } catch (\Exception $ex) {
                $datas = array();
            }
        } else {
            throw new \InvalidArgumentException(sprintf('File %s not found !', $this->file));
        }

        return $datas;
    }