Ferreteria/v0.6/clade/Sys/FileSys/Aspect/Ident/spex/FSChain/@removed

From WoozleCodes
Jump to navigation Jump to search
Removed Code

Additional Clades

The following have also been removed:

2026-05-06 [ACTION]: Use FSLink::AddPrev() instead, if really necessary (need use-case).

#
    public function AddSegment(string $fn,?FSLinkIface $oPrev=NULL) : FSLinkIface {
        $oNew = new FSLinkClass($this,$fn,$oPrev);
        if (is_null($oPrev)) {
            $this->OBase = $oNew;
        }
        #$this->QOLeaf()->SetIt($oNew);
        $this->OLeaf = $oNew;
        return $oNew;
    }

2026-05-06 [ACTION]: moved to FSLink

#
    public function ParsePath(string $fpr) : FSLinkIface {
        $fpClean = trim($fpr,'/');  // make sure there are no extra slashes
        $arPath = explode('/',$fpClean);
        $oSeg = NULL;
        foreach ($arPath as $fnSeg) {
            $oSeg = $this->AddSegment($fnSeg,$oSeg);
        }
        return $oSeg;
    }

2026-05-05: replaced with properties

#
    private $qoBase;
    public function QOBase() : QObjIface { return $this->qoBase ?? ($this->qoBase = QObjClass::AsNew()); }
    private $qoLeaf;
    public function QOLeaf() : QObjIface { return $this->qoLeaf ?? ($this->qoLeaf = QObjClass::AsNew()); }

2026-05-05 old version

#
    public function QSPath() : QStrIface {
        $qsPath = $this->qsPath ?? ($this->qsPath = QStrClass::AsNew());
        $qoLeaf = $this->QOLeaf();
        if ($qoLeaf->HasIt()) {
            $oLeaf = $qoLeaf->GetIt();
            $fs = $oLeaf->SpecAbs();
            $qsPath->SetIt($fs);
        }
        return $qsPath; // 2025-11-08 This is returning as not set.
    }

Entire previous version, replaced 2025-11-06 (though apparently I did some tidying after that, not noticing that it was retired):

/* BaseClass */ use Woozalia\Ferret\Data\Mem\QVar\cStr as BaseClass;
/* BaseIface */ use Woozalia\Ferret\Data\Mem\QVar\iStr as BaseIface;
/* CapClass */ use Woozalia\Ferret\Sys\FileSys\Aspect\Ident\stringer\Chain\Nested\Named\cCap as CapClass;
/* CapIface */ use Woozalia\Ferret\Sys\FileSys\Aspect\Ident\stringer\Chain\Nested\Named\iCap as CapIface;
/* FileClass */ use Woozalia\Ferret\Sys\FileSys\Node\cFi as FileClass;
/* FileIface */ use Woozalia\Ferret\Sys\FileSys\Node\iFi as FileIface;
/* FldrClass */ use Woozalia\Ferret\Sys\FileSys\Node\cFo as FldrClass;
/* FldrIface */ use Woozalia\Ferret\Sys\FileSys\Node\iFo as FldrIface;
/* NodeClass */ use Woozalia\Ferret\Sys\FileSys\cNode as NodeClass;
/* NodeIface */ use Woozalia\Ferret\Sys\FileSys\iNode as NodeIface;
/* QObjClass */ use Woozalia\Ferret\Data\Mem\QVar\cObj as QObjClass;
/* QObjIface */ use Woozalia\Ferret\Data\Mem\QVar\iObj as QObjIface;
/* SelfIface */ use Woozalia\Ferret\Sys\FileSys\Aspect\Ident\stringer\iChain as SelfIface;

interface iChain extends BaseIface {
    function AddSegment(string $fn) : CapIface;
    function ParsePath(string $fpr) : CapIface;
    function QOBase() : QObjIface;
}
abstract class caChain extends BaseClass implements SelfIface {

    // ++ ACTION ++ //

    public function AddSegment(string $fn) : CapIface { return new CapClass($fn,$this); }
    // ACTION: Parse the given relative path and return a new PathPiece for the last segment
    public function ParsePath(string $fpr) : CapIface {
        $fpClean = trim($fpr,'/');  // make sure there are no extra slashes
        $arPath = explode('/',$fpClean);
        $oSeg = $this;
        foreach ($arPath as $fnSeg) {
            $oSeg = $oSeg->AddSegment($fnSeg);
        }
        return $oSeg;
    }

    // -- ACTION -- //
    // ++ FIGURING ++ //

    /* 2025-11-04 Removing these (for now) because of ambiguity with QSPath().
    // RETURNS entire filespec, including base
    public function GetSpec() : string { return $this->PathStatus()->GetAbsPath(); }
    /*----
      RETURNS relative filespec from base
      PUBLIC because sometimes we need that information
    * /
    public function GetPath() : string { return $this->PathStatus()->GetRelPath(); }
    */
    /**
      * INPUT:
      *  $fsa = absolute filespec within this repository's folder
      * NOTE: This functionality is basically tFolder::WhatRemains().
      *  Possibly that should be used instead of re-implementing here.
      * HISTORY:
      *   2023-12-05 moved from .\Kiosk\cRepository to .\Data\Stored\File\Path\caPiece
      */
    public function FigureRelative(string $fsFull) : string {
        // might as well do a sanity-check, even though it should already have been done
        $fpThis = $this->PathStatus()->GetAbsPath();
        // if $fsFull starts with the repo's base path...
        if (str_starts_with($fsFull,$fpThis)) {
            // get the part of $fsFull *after* that base path
            $nlThis = strlen($fpThis);
            $fpRemain = substr($fsFull,$nlThis);
        } else {
            // I think this still shouldn't happen...
            echo "NO MATCH: FULL=[$fsFull], THIS=[$fpThis]<br>";
            throw new \exception('Internal error: bad value in constructor');
        }
        return $fpRemain;
    }

    // -- FIGURING -- //
    // ++ OBJECTS ++ //

    private $qoBase = NULL;
    public function QOBase() : QObjIface { return $this->qoBase ?? ($this->qoBase = QObjClass::AsNew()); }

    // ++ OBJECTS: FILESYS ++ //

    /**
     * NOTE:
     *  2023-10-03 These used to return different classes (cFile and cFolder),
     *    but apparently the functionality we need is now in a class which
     *    doesn't differentiate like that. (Maybe that's work to be done yet?)
     */
    public function GetFileNode() : FileIface {
        $fs = $this->GetSpec();
        return new FileClass($fs);
    }
    public function GetFolderNode() : FolderIface {
        $fs = $this->GetSpec();
        return new FolderClass($fs);
    }

    public function Info() : NodeIface { return new SelfNodeClass($this->GetSpec()); }

    // -- OBJECTS -- //

}