Ferreteria/v0.6/clade/IO/Aspect/Connx/Stream/Native/File

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | Aspect‎ | Connx‎ | Stream‎ | Native
Jump to navigation Jump to search
clade: IO\Aspect\Connx\Stream\Native\File
Clade Family
Native File Text
Clade Aliases
Alias Clade
Subpages

About

  • Purpose: streaming from a file -- a file as an I/O stream, which is different from a file as a filesystem node
    • This class contains a filesystem node, which can be accessed via FileNode().

History

  • 2025-12-17 started
  • 2025-12-19 moved from IO\Aspect\Connx\Stream\ to IO\Aspect\Connx\Stream\Finite\

Code

as of 2025-12-19 (not necessarily working yet):

interface iFile extends BaseIface {
    static function FromNode(FileIface $oNode) : self;
}
class cFile extends BaseClass implements iFile {
    // ++ CONFIG ++ //

    public function SType() : string { return 'streamed file'; }

    // -- CONFIG -- //
    // ++ SETUP ++ //

    protected function __construct(){}

    public static function FromNode(FileIface $oNode) : iFile {
        $oThis = new static;
        $oThis->FileNode($oNode);
        return $oThis;
    }

    // -- SETUP -- //
    // ++ ADMIN ++ //

    protected function ActualOpen() : ActionIface { return $this->FileNode()->InOut()->Open(); }
    protected function ActualShut() : ActionIface { return $this->FileNode()->InOut()->Shut(); }

    // -- ADMIN -- //
    // ++ OBJECTS ++ //

    protected $oNode = NULL;
    protected function FileNode(?FileIface $o=NULL) : FileIface { return is_null($o) ? $this->oNode : ($this->oNode = $o); }

    // -- OBJECTS -- //
    // ++ I/O ++ //

    public function PullBytes(int $nMax=NULL) : string {
        $oNodeIO = $this->FileNode()->InOut();
        $oAct = $oNodeIO->Read($nMax);
        $this->ItWent($oAct);
    }
    public function PushBytes(string $s) : int {
        $oNodeIO = $this->FileNode()->InOut();
    }
}