modifs.mineures sans commentaires
This commit is contained in:
parent
be6b7371e5
commit
278ffc7db1
@ -28,12 +28,16 @@ class file {
|
|||||||
* "file.yml" existe, alors <code>file::try("file.yaml", ".yml")</code>
|
* "file.yml" existe, alors <code>file::try("file.yaml", ".yml")</code>
|
||||||
* retourne "file.yml"
|
* retourne "file.yml"
|
||||||
*
|
*
|
||||||
|
* par défaut, $replace_ext est initialisé à l'extension de $file. utiliser []
|
||||||
|
* pour désactiver cette fonctionnalité
|
||||||
|
*
|
||||||
* @param string|array $exts
|
* @param string|array $exts
|
||||||
* @param string|array $replace_ext
|
* @param string|array $replace_ext
|
||||||
*/
|
*/
|
||||||
static function try_ext(string $file, $exts=null, $replace_ext=null): ?string {
|
static function try_ext(string $file, $exts=null, $replace_ext=null): ?string {
|
||||||
if (file_exists($file)) return $file;
|
if (file_exists($file)) return $file;
|
||||||
if ($exts !== null) {
|
if ($exts !== null) {
|
||||||
|
$replace_ext ??= path::ext($file);
|
||||||
foreach (cl::with($exts) as $ext) {
|
foreach (cl::with($exts) as $ext) {
|
||||||
$tmpfile = path::ensure_ext($file, $ext, $replace_ext);
|
$tmpfile = path::ensure_ext($file, $ext, $replace_ext);
|
||||||
if (file_exists($tmpfile)) return $tmpfile;
|
if (file_exists($tmpfile)) return $tmpfile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user