Ferreteria/v0.6/clade/Sys/FileSys/Aspect/Ident
Jump to navigation
Jump to search
| ||||||||||||||||||||
Logic
- Each object starts with a full filespec and uses SplFileInfo to parse that into pieces as needed.
Status
Code
as of 2025-10-06
interface iIdent extends BaseIface {
// SETUP
static function FromSpec(string $fs) : self;
// ACCESS
function QSFullSpec() : QStrIface;
function Exists() : bool;
function SpecFull() : string; // path/filename.ext
function SpecPath() : string; // path
function SpecNameCore() : string; // filename (no path, no ext)
function SpecExtn() : string; // .ext
function SpecNameExt() : string; // filename.ext
}
class caIdent extends BaseClass implements iIdent {
// ++ SETUP ++ //
public static function FromSpec(string $fs) : iIdent {
$oThis = new static;
$oThis->QSFullSpec()->SetIt($fs);
return $oThis;
}
public static function FromQStr(QStrIface $os) : iIdent {
$oThis = new static;
$oThis->QSFullSpec($os);
return $oThis;
}
// -- SETUP -- //
// ++ ACCESS ++ //
private $osStr = NULL;
public function QSFullSpec(?QStrIface $os=NULL) : QStrIface {
if (is_object($os)) {
$this->osStr = $os;
} else {
if (is_null($this->osStr)) {
$this->osStr = QStrClass::AsNew();
}
$os = $this->osStr;
}
return $os;
}
public function Exists() : bool { return file_exists($this->QSFullSpec()->GetIt()); }
public function SpecFull() : string { return $this->QSFullSpec()->GetIt(); }
public function SpecPath() : string { return $this->NativeSplInfo()->getPath(); }
public function SpecNameCore() : string { return $this->NativeSplInfo()->getBasename('.'.$this->SpecExtn()); }
public function SpecExtn() : string { return $this->NativeSplInfo()->getExtension(); }
public function SpecNameExt() : string { return $this->NativeSplInfo()->getFilename(); }
// ++ ACCESS: internal ++ //
private $onInfo = NULL;
protected function NativeSplInfo() : SplFileInfo { return $this->onInfo ?? ($this->onInfo = new SplFileInfo($this->QSFullSpec()->GetIt())); }
public function Size() : int|false { return $this->NativeSplInfo()->getSize(); }
// -- ACCESS -- //
// ++ STRUCT ++ //
protected function NewNode() : NodeIface {
$oNode = new ($this->NodeClass());
$oNode->Ident($this);
return $oNode;
}
// -- STRUCT -- //
}