2
我有一個在Windows XP SP3上運行的PHP 5.3.4應用程序,我需要在遠程PC上索引目錄的內容。我索引的最大目錄包含大約18,000個項目。找到包含特定項目的目錄的最快方法
此調用將找到像\\somepc.mycorp.com\foo\mydir\bar\zoo.zip
這樣的項目。
// look in all the directories in \\somepc.mycorp.com\foo for directories containing a file \bar\zoo.zip
$item_list = GetFileList('\\\\somepc.mycorp.com\\foo', '\\bar\\zoo.zip');
它是這樣實現的:
function GetFileList($base_dir, $path_mask)
{
$result= array();
if ($handle = opendir($base_dir))
{
while (false !== ($entry = readdir($handle)))
{
// only add items that match the mask we're looking for
if ($entry != "." &&
$entry != ".." &&
file_exists($base_dir.'\\$entry\\$path_mask'))
{
array_push($result, $entry);
}
}
closedir($handle);
}
return $result;
}
不幸的是,最大的目錄結構,這個操作可能需要一個多小時。如果我刪除過濾器,並將每個看到的項目插入到數組中,它將在幾秒鐘內完成。
有沒有更快的方法來實現這個目標?
什麼是遠程PC操作系統? – 2012-01-13 15:33:46
@Ivan - 一個Windows文件共享。 (操作系統可能是一些Windows服務器的變種,我不確定哪個......可能是2003 Server) – PaulH 2012-01-13 15:47:33