/** * @return int|null */ public function getFileSize() { return $this->file->getSize(); }
/** * @param string $output * @param string $input * * @return bool */ private function handleExistingFile(FileInfo $output, FileInfo $input) { try { if ($this->smartOutputOverwrite === true && $input->getSize() > $output->getSize()) { $this->io()->info('Automatically overwriting smaller output filepath with larger input.'); return true; } if ($this->smartOutputOverwrite === true && $input->getSize() <= $output->getSize()) { unlink($input->getPathname()); $this->io()->info('Automatically removing input file path of less than or equal size to existing output filepath.'); return false; } } catch (\RuntimeException $e) { $this->io()->error('Could not use smart output mode! An error occurred while processing file sizes.'); } while (true) { $this->io()->comment('File already exists in output path'); $this->io()->writeln(' [ <em>o</em> ] Overwrite <info>(default)</info>', false); $this->io()->writeln(' [ <em>s</em> ] Skip', false); $this->io()->writeln(' [ <em>R</em> ] Delete Input', false); $action = $this->io()->ask('Enter action command shortcut name', 'o'); switch ($action) { case 'o': $this->io()->info('Overwriting smaller output filepath with larger input.'); return true; case 's': return false; case 'R': $this->io()->info(sprintf('Removing input file: %s', $input->getPathname())); unlink($input->getPathname()); return false; default: $this->io()->error(sprintf('Invalid command shortcut "%s"', $action)); sleep(3); } } }