Hi,

Wishes.

I am not comfortable with shell scripting though know a bit here and there. I believe the listing of a directory using php logic alone would not give appreciable performance if i have lots of nested directories.

I really believe a shell commands would solve this and would be short and sweet also. I request help to convert the below to make use of shell commands

function filesNameFromDirectory( $path = '.', $level = 0 )
	{
		$filenames = '';
		$ignore = array( 'cgi-bin', '.', '..' );
		$dh = @opendir( $path );
		while( false !== ( $file = readdir( $dh ) ) )
		{
			if( !in_array( $file, $ignore ) )
			{    
				$spaces = str_repeat( ' ', ( $level * 4 ) ); 
				if( is_dir( "$path/$file" ) )
				{
					$this->filesNameFromDirectory( "$path/$file", ($level+1) );                      
				} else 
				{
					if($filenames == '')
					{
						  $filenames = substr($file,0,-4);
					}
					else
					{
						  $filenames .= ','.substr($file,0,-4);
					}
				}
			}    
		}
		closedir( $dh );
		return $filenames;
	}

With regards

Harish

Hi,

Any help or pointers please. I am really stuck with here.The application works fine but i am reviewing and thought of gettting the shell commands for better performance.

Regards.

This article has been dead for over six months. Start a new discussion instead.