freebox_api_php/freebox/api/v3/services/FileSystem/FileSystemListing.php

51 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace alphayax\freebox\api\v3\services\FileSystem;
use alphayax\freebox\api\v3\models;
use alphayax\freebox\api\v3\Service;
/**
* Class FileSystemListing
* @package alphayax\freebox\api\v3\services\FileSystem
*/
class FileSystemListing extends Service {
const API_FS_LS = '/api/v3/fs/ls/';
const API_FS_INFO = '/api/v3/fs/info/';
/**
* Get all files in a given directory
* @param string $DirectoryName
* @param bool $onlyFolder Only list folders
* @param bool $countSubFolder Return files and sub-folder count for folders
* @param bool $removeHidden Dont return hidden files in directory listing
* @return models\FileSystem\FileInfo[]
*/
public function getFilesFromDirectory( $DirectoryName = '/Disque dur/', $onlyFolder = true, $countSubFolder = false, $removeHidden = true){
$Directory_b64 = base64_encode( $DirectoryName);
$rest = $this->getAuthService( self::API_FS_LS . $Directory_b64);
$rest->GET();
// $rest->GET([
// 'onlyFolder' => $onlyFolder,
// 'countSubFolder' => $countSubFolder,
// 'removeHidden' => $removeHidden,
// ]);
return $rest->getResultAsArray( models\FileSystem\FileInfo::class);
}
/**
* Get file information
* @param string $DirectoryName
* @return models\FileSystem\FileInfo
*/
public function getFileInformation( $DirectoryName){
$Directory_b64 = base64_encode( $DirectoryName);
$rest = $this->getAuthService( self::API_FS_INFO . $Directory_b64);
$rest->GET();
return $rest->getResult( models\FileSystem\FileInfo::class);
}
}