Ferreteria/v0.6/clade/Sys/FileSys/Aspect/Ident/stringer/Chain: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{page/clade/v2 |fam= {{!}} align=right {{!}} {{l/ver/clade|Data\Mem\QVar|Str}} {{!}} align=center {{!}} ⇒ {{l/ver/clade|Sys\FileSys\Aspect\Ident\stringer|Chain}} ⇒ {{!}} align=left {{!}} /Nested/<br> /Root/ |alia= {{!-!}} '''Base'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Data\Mem\QVar|Str}} {{!-!}} '''Cap'''* [c,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\FileSys\Aspect\Ident\stringer\Chain\Nested\Named|Cap}} {{!-!}} '''File'''* [c,i] {...") |
No edit summary |
||
| Line 3: | Line 3: | ||
{{!}} align=right {{!}} {{l/ver/clade|Data\Mem\QVar|Str}} | {{!}} align=right {{!}} {{l/ver/clade|Data\Mem\QVar|Str}} | ||
{{!}} align=center {{!}} ⇒ {{l/ver/clade|Sys\FileSys\Aspect\Ident\stringer|Chain}} ⇒ | {{!}} align=center {{!}} ⇒ {{l/ver/clade|Sys\FileSys\Aspect\Ident\stringer|Chain}} ⇒ | ||
{{!}} align=left {{ | {{!}} align=left {{!}} ''(none)'' | ||
}} | }} | ||
==About== | |||
* PURPOSE: Ident (filespec) which breaks the spec up into objects, one per path-segment (Piece), | |||
==History== | |||
* '''{{fmt/date|2023|11|03}}''' moved from ...\File\caPathPiece -> ...\File\Path\caPiece | |||
* '''{{fmt/date|2024|12|24}}''' moved from [WF]Data/Stored/File/Path -> [WF]IO/fsys/Path | |||
* '''{{fmt/date|2024|12|25}}''' updated: "Spec" stuff is now in [WF]IO/fsys/Info/Node.php | |||
* '''{{fmt/date|2024|12|30}}''' moved all Piece stuff ffom [WF]IO\fsys\Path -> [WF]Sys/FileSys | |||
* '''{{fmt/date|2024|12|31}}''' ...and thence to [WF]Sys/FileSys/Aspect/Ident/stringer and renamed Piece -> Chain | |||
** Chain now also descends from QStr. | |||
* '''{{fmt/date|2025|11|06}}''' Starting over with new file. Reusing iface, but Chain is now a holder and not a QStr. | |||
==Code== | ==Code== | ||
''as of {{fmt/date|2025|11|05}}'' | ''as of {{fmt/date|2025|11|05}} (obsolete v1)'' | ||
{{fmt/php/block|1= | {{fmt/php/block|1= | ||
interface iChain extends BaseIface { | interface iChain extends BaseIface { | ||
Latest revision as of 16:23, 6 November 2025
| ||||||||||||
About
- PURPOSE: Ident (filespec) which breaks the spec up into objects, one per path-segment (Piece),
History
- 2023-11-03 moved from ...\File\caPathPiece -> ...\File\Path\caPiece
- 2024-12-24 moved from [WF]Data/Stored/File/Path -> [WF]IO/fsys/Path
- 2024-12-25 updated: "Spec" stuff is now in [WF]IO/fsys/Info/Node.php
- 2024-12-30 moved all Piece stuff ffom [WF]IO\fsys\Path -> [WF]Sys/FileSys
- 2024-12-31 ...and thence to [WF]Sys/FileSys/Aspect/Ident/stringer and renamed Piece -> Chain
- Chain now also descends from QStr.
- 2025-11-06 Starting over with new file. Reusing iface, but Chain is now a holder and not a QStr.
Code
as of 2025-11-05 (obsolete v1)
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 NodeClass($this->GetSpec()); }
// -- OBJECTS -- //
}