*/ class ParTCP_Lots { public $fileSystem; public $baseDir; public $subdirDepth; public $subdirNameLength; public $config; public function __construct( $fileSystem, $config = [] ){ $this->fileSystem = $fileSystem; $this->config = $config; } public function set_base_dir( $baseDir, $estimatedTotal = NULL ){ if ( $estimatedTotal && function_exists('partcp_subdir_rules') ){ $rules = partcp_subdir_rules( $estimatedTotal ); $this->subdirDepth = $rules[0]; $this->subdirNameLength = $rules[1]; } $this->baseDir = trim( $baseDir, '/' ); } public function get_dir( $id ){ if ( ! empty( $this->subdirDepth ) ){ $parts = str_split( md5( $id ), $this->subdirNameLength ?? 2 ); $subdirs = implode( '/', array_slice( $parts, 0, $this->subdirDepth ) ); $id = "{$subdirs}/{$id}"; } return ( $this->baseDir ? "{$this->baseDir}/" : '' ) . "lots/{$id}"; } } // end of file models/lots.class.php