]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/file_directories/binary/class_BaseBinaryFile.php
Continued:
[core.git] / framework / main / classes / file_directories / binary / class_BaseBinaryFile.php
index 6d7cdecff1ec78b0c8fcb0d29938e8b8b8b68d63..a7a1dcfd3ff0de9c228b56e122f59dbacebf26af 100644 (file)
@@ -8,6 +8,8 @@ use Org\Mxchange\CoreFramework\EntryPoint\ApplicationEntryPoint;
 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
 use Org\Mxchange\CoreFramework\Filesystem\File\BaseAbstractFile;
 use Org\Mxchange\CoreFramework\Filesystem\FilePointer;
+use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
+use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
 use Org\Mxchange\CoreFramework\Traits\Index\IndexableTrait;
 use Org\Mxchange\CoreFramework\Traits\Stack\StackableTrait;
 
@@ -24,7 +26,7 @@ use \UnexpectedValueException;
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2021 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -258,6 +260,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                }
 
                // Very simple to do ...
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: self:configCache[%s_pre_allocate_count]()=%d', count(self::$configCache[$type . '_pre_allocate_count'])));
                for ($idx = 0; $idx < self::$configCache[$type . '_pre_allocate_count']; $idx++) {
                        // Calculate start/end positions
                        $startPosition = $idx * $minimumBlockLength;
@@ -457,7 +460,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: str=%s - CALLED!', $str));
                if (empty($str)) {
                        // Throw IAE
-                       throw new InvalidArgumentException('Parameter "str" is empty');
+                       throw new InvalidArgumentException('Parameter "str" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
 
                // Determine it
@@ -486,7 +489,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                        throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid', $seekPosition));
                } elseif (empty($data)) {
                        // Empty data is invalid, too
-                       throw new InvalidArgumentException('Parameter "data" is empty');
+                       throw new InvalidArgumentException('Parameter "data" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
 
                // Write data at given position
@@ -534,7 +537,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                        throw new OutOfBoundsException(sprintf('seekPosition=%d is not valid.', $seekPosition));
                } elseif (empty($dataStream)) {
                        // Empty dataStream
-                       throw new InvalidArgumentException('Parameter "dataStream" is empty');
+                       throw new InvalidArgumentException('Parameter "dataStream" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                }
 
                // Call pointer's method
@@ -596,7 +599,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: fileSize[%s]=%d', gettype($fileSize), $fileSize));
                if (!is_int($fileSize)) {
                        // Bad file?
-                       throw new UnexpectedValueException(sprintf('fileSize[]=%s is unexpected', gettype($fileSize)));
+                       throw new UnexpectedValueException(sprintf('fileSize[]=%s is unexpected', gettype($fileSize)), FrameworkInterface::EXCEPTION_UNEXPECTED_VALUE);
                }
 
                // Is more than 0 returned?
@@ -896,11 +899,11 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: type=%s,minimumBlockLength=%d - CALLED!', $type, $minimumBlockLength));
                if (empty($type)) {
                        // Empty type
-                       throw new InvalidArgumentException('Parameter "type" is empty');
+                       throw new InvalidArgumentException('Parameter "type" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
                } elseif ($minimumBlockLength < 1) {
                        // Invalid block length
                        throw new InvalidArgumentException(sprintf('Parameter minimumBlockLength=%d is not valid', $minimumBlockLength));
-               } elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($type . '_pre_allocate_enabled') != 'Y') {
+               } elseif (!FrameworkBootstrap::getConfigurationInstance()->isEnabled($type . '_pre_allocate')) {
                        // Don't continue here.
                        self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-BINARY-FILE: Not pre-allocating file.'));
                        return;
@@ -1026,7 +1029,7 @@ abstract class BaseBinaryFile extends BaseAbstractFile implements BinaryFile {
                }
 
                // @TODO Unfinished
-               $this->partialStub('length=' . $length);
+               DebugMiddleware::getSelfInstance()->partialStub('length=' . $length);
        }
 
 }