|
Posted by Jean Pierre Daviau on 02/16/07 18:18
Hi everyone,
I am trying to create a class that find a file in its subfolders.
See the results below
==================== classe import_class
============================
<?php
// php -check-f import_class.php
/*
class import_class {
var $safepath;
var $basepath;
var $classe;
function import_class($input){
if(strstr($input, ".php")){
$this->classe = $input;
$this->path = str_replace('\\', '/', __FILE__);
$fichier = substr($this->path, 0, strrpos($this->path, "/"));
$this->basepath = $fichier . "/";
$this->safepath = $this->basepath;
print "construct: $this->safepath\n";
}else{
$this->basepath = $input;
print "construct: $input\n";
}
}
function OpenAllDir()
{
$cpt = 0;
// On ouvre le dossier
$dossier = opendir($this->safepath);
// On parcourt le dossier
while($dir = readdir($dossier))
{
if(is_dir($dir) && $dir != '.' && $dir != '..')
{
$PathToRepertoire = str_replace($PathToRepertoire, '.', '' );
$this->safepath = $this->safepath . $PathToRepertoire . $dir .
"/";
//print "OpenAllDir: $this->safepath\n";
$instance = new import_class ($this->safepath);
$instance->OpenAllDir();
}
if ($dir === $this->classe) {
$this->basepath = $this->basepath;
print "Le fichier $dir existe\n";
break;
}
print "$dir\n";
}
closedir($dossier);
}
}//fin de class
$nw = new import_class("haha.php");
$nw->OpenAllDir();
================================= end class ==================
C:/PHP/commandLine/
| +Part_1
| +Part_2
| +node
| +file to find
construct: C:/PHP/commandLine/
..
...
cmdline.php
import_class.php
import_class_back.php
incl_class.php
info.php
construct: C:/PHP/commandLine/Part_1/
Warning: readdir(): supplied argument is not a valid Directory
resource in C:\PHP\commandLine\import_class.php on line 45
Warning: closedir(): supplied argument is not a valid Directory
resource in C:\PHP\commandLine\import_class.php on line 66
Part_1
Part_1.htm
construct: C:/PHP/commandLine/Part_1/Part_2/
Warning: readdir(): supplied argument is not a valid Directory
resource in C:\PHP\commandLine\import_class.php on line 45
Warning: closedir(): supplied argument is not a valid Directory
resource in C:\PHP\commandLine\import_class.php on line 66
Part_2
Part_2.htm
PHpLine.cmd
Thanks for your attention.
Jean Pierre Daviau
--
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Processor Radeon7000 0x5159 agp
Navigation:
[Reply to this message]
|