PHP code example of pendenga / file

1. Go to this page and download the library: Download pendenga/file library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pendenga / file example snippets


$batch = new Batch(new Scan(), $logger);
$batch->setOption('max_batch_bytes', 10737418240); // 10 gb
$batches = $batch->evaluate($tmp_dir);
// print_r($batches); // review before executing
$batch->execute($batches);


$dir = new Directory($logger);

// bool check if directory is empty
if ($dir->checkEmpty($tmp_dir)) { ... }

// array list of files
foreach ($dir->files($tmp_dir) as $file) { ... }

// delete all files in a directory (useful for unit tests)
$dir->deleteFiles($tmp_dir);

// delete all empty subdirectories in a directory (useful for unit tests)
$dir->deleteSubDirs($tmp_dir);

$gen = new Generate($logger);
$gen->setOption('file_base_dir', $tmp_dir)
    ->setManifest(new ManifestWriter($manifest))
    ->files();

$tmp_dir = Ini::get('TMP_DIRECTORY');

$chk = new Manifest(new ColumnMap(), $logger);
$chk->load($path_to_manifest_file);
$results = $chk->validateFiles($path_to_files, new Scan());

$prop = new Properties($path_to_file);
$prop->bytes();
$prop->checksum();
$prop->exists();
$prop->lines();

$scan = new Scan($logger);

// search directory for text files (recursive)
$scan->files($path_to_file_directory, '*.txt'))

// list subdirectories (not recursive)
$scan->directories($path_to_file_directory)