Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk capacity #27

Open
janbarasek opened this issue May 11, 2021 · 0 comments
Open

Disk capacity #27

janbarasek opened this issue May 11, 2021 · 0 comments
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request

Comments

@janbarasek
Copy link
Member

janbarasek commented May 11, 2021

V rámci nastavení CMS by se hodilo uživateli zobrazovat, jak je na tom kapacitně jeho disk na serveru.

Zkus připravit třídu, která bude poskytovat informace o discích a jakou mají kapacitu. Představuji si to tak, že zavolám něco jako:

Disk::getOverview();

A jako response dostanu pole dostupných disků a kapacity. Pozor, pole disků se liší podle operačního systému (na Windows jsou disky A-Z, na Linuxu se tzv. mountují).

Možná response:

[
   // disk => [dostupná kapacita, použitá, celková],
   'c' => ['available' => int, 'used' => int, 'total' => int],
]

Pomocné funkce:

  • free space: disk_free_space()
  • total space: disk_total_space()
  • Add disk total space detection by project root dir

Na Windows teoreticky takto (nevyzkoušeno):

function getDisks(): array
{
    if (str_contains(PHP_OS_FAMILY, 'WIN')) {
        $return = [];
        foreach (range('A', 'Z') as $disk) {
            $return[$disk] = disk_total_space($disk . ':');
        }

        return $return;
    }

    return [
        '/' => disk_total_space('/')
    ];
}
@janbarasek janbarasek self-assigned this May 11, 2021
@janbarasek janbarasek assigned filipjakub and unassigned janbarasek Aug 15, 2021
@janbarasek janbarasek added dependencies Pull requests that update a dependency file enhancement New feature or request labels Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants