<commit_before><?php

/**
 * Copyright (C) 2012  <NAME>
 *
 * @author <NAME>
 * @license GPL 3 http://www.gnu.org/copyleft/gpl.html
 *
 * This class manages anything related to 'Files'.
 * For precise return values see put.io's documentation here:
 *
 * https://api.put.io/v2/docs/#files
 *
**/

namespace PutIO\Engines\PutIO;
use PutIO\Helpers\PutIO\PutIOHelper;


class FilesEngine extends PutIOHelper
{
    
    /**
     * Returns an array of files. False on error.
     *
     * @param integer $parentID  OPTIONAL - Only returns files of $parentID if supplied
     * @return mixed
     *
    **/
    public function listall($parentID = 0)
    {
        return $this->get('files/list', array('parent_id' => $parentID), false, 'files');
    }
    
    
    /**
     * Returns an array of files matching the given search query.
     *
     * @param string  $query   Search query
     * @param integer $page    OPTIONAL - Page number
     * @return array
     *
    **/
    public function search($query, $page = 1)
    {
        return $this->get('files/search/' . rawurlencode(trim($query)) . '/page/' . $page, array());
    }
    
    
    /**
     * Uploads a local file to your account. Returns false if the file does not exist.
     *
     * NOTE 1: The response differs based on the uploaded file. For regular files, the
     * array key containing the info is 'file', but for torrents it's 'transfer'.
     * @see https://api.put.io/v2/docs/#files-upload
     *
     * NOTE 2: Files need to be read into the memory when using native functions. Keep
     * that in mind when uploading large files or running multiple instances.
     *
     * @param string  $file        Path to local file.
     * @param integer $parentID    OPTIONAL - ID of upload folder.
     * @return mixed
     *
    **/
    public function upload($file, $parentID = 0)
    {
        if (!$file = realpath($file))
        {
            return false;
        }
        
        return $this->uploadFile('files/upload', array('parent_id', $parentID, 'file' => '@' . $file));
    }
    
    
    /**
     * Creates a new folder. Returns folder info on success, false on error.
     *
     * @param string  $name        Name of the new folder.
     * @param integer $parentID    OPTIONAL - ID of the parent folder.
     * @return mixed
     *
    **/
    public function makeDir($name, $parentID = 0)
    {
        return $this->post('files/create-folder', array('name' => $name, 'parent_id' => $parentID), false, 'file');
    }
    
    
    /**
     * Returns an array of information about given file. False on error.
     *
     * @param integer $fileID   ID of the file.
     * @return mixed
     *
    **/
    public function info($fileID)
    {<commit_msg>Turns out realpath() wan't needed<commit_after><?php

/**
 * Copyright (C) 2012  <NAME>
 *
 * @author <NAME>
 * @license GPL 3 http://www.gnu.org/copyleft/gpl.html
 *
 * This class manages anything related to 'Files'.
 * For precise return values see put.io's documentation here:
 *
 * https://api.put.io/v2/docs/#files
 *
**/

namespace PutIO\Engines\PutIO;
use PutIO\Helpers\PutIO\PutIOHelper;


class FilesEngine extends PutIOHelper
{
    
    /**
     * Returns an array of files. False on error.
     *
     * @param integer $parentID  OPTIONAL - Only returns files of $parentID if supplied
     * @return mixed
     *
    **/
    public function listall($parentID = 0)
    {
        return $this->get('files/list', array('parent_id' => $parentID), false, 'files');
    }
    
    
    /**
     * Returns an array of files matching the given search query.
     *
     * @param string  $query   Search query
     * @param integer $page    OPTIONAL - Page number
     * @return array
     *
    **/
    public function search($query, $page = 1)
    {
        return $this->get('files/search/' . rawurlencode(trim($query)) . '/page/' . $page, array());
    }
    
    
    /**
     * Uploads a local file to your account.
     *
     * NOTE 1: The response differs based on the uploaded file. For regular files, the
     * array key containing the info is 'file', but for torrents it's 'transfer'.
     * @see https://api.put.io/v2/docs/#files-upload
     *
     * NOTE 2: Files need to be read into the memory when using NATIVE functions. Keep
     * that in mind when uploading large files or running multiple instances.
     *
     * @param string  $file        Path to local file.
     * @param integer $parentID    OPTIONAL - ID of upload folder.
     * @return mixed
     *
    **/
    public function upload($file, $parentID = 0)
    {
        return $this->uploadFile('files/upload', array('parent_id', $parentID, 'file' => '@' . $file));
    }
    
    
    /**
     * Creates a new folder. Returns folder info on success, false on error.
     *
     * @param string  $name        Name of the new folder.
     * @param integer $parentID    OPTIONAL - ID of the parent folder.
     * @return mixed
     *
    **/
    public function makeDir($name, $parentID = 0)
    {
        return $this->post('files/create-folder', array('name' => $name, 'parent_id' => $parentID), false, 'file');
    }
    
    
    /**
     * Returns an array of information about given file. False on error.
     *
     * @param integer $fileID   ID of the file.
     * @return mixed
     *
    **/
    public function info($fileID)
    {
{'fraction_non_alphanumeric': 0.12371711140138085, 'fraction_numerical': 0.004851651427505131, 'mean_word_length': 2.1734754292480756, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '651458', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1612, 'n_words': 529}