作成日:2006/05/10
1X.5.3 ディレクトリ操作
| 構文 | 説明 |
|---|---|
resource opendir ( string path ) |
path で指定されたディレクトリをオープンします。 ディレクトリが オープンできない場合、opendir() は FALSE を返します。 ※ readdir() の用例を参照。 |
string readdir ( resource dir_handle ) |
ディレクトリハンドルから次のファイル名を返します。 ファイル名はファイルシステム上に格納されている順番で返されます。 返すファイルが無くなる(EOFに達する)と FALSE を返します。 EOFの判定には === (または !== ) を使用します。 (なぜなら、'0'と言うファイル名があるかもしれません) 用例:
$dir = "./";
($dh = opendir($dir)) or die("Open Error: $dir");
while (($file = readdir($dh)) !== false) {
if (($file!='.')&&($file!='..')){
print "$file : " . filetype($dir . $file) . "
※ readdir() は、 . と .. を返します。 |
void closedir ( resource dir_handle ) |
ディレクトリハンドルをクローズします。 ※ readdir() の用例を参照。 |
string getcwd ( void ) |
カレントのワーキングディレクトリを返します。 |
bool chdir ( string directory ) |
カレントのワーキングディレクトリを directory に変 更します。 成功した場合に TRUE を、失敗した場合に FALSE を返します。 |
bool mkdir ( string pathname [,int mode [,bool recursive [,resource context]]] ) |
pathname で指定されたディレクトリを作成します。 成功した場合に TRUE を、失敗した場合に FALSE を返します。 mode は 8進数 で指定します。省略した場合は、0777 が適用されます。 mode はカレントの umask で修正されます。umask を変更するには、umask() 関数を使用します。 用例:
mkdir ("./test", 0700);
|
bool rmdir ( string dirname ) |
dirname で指定されたディレクトリを削除します。 この場合、ディレクトリは空である必要があります。 成功した場合に TRUE を、失敗した場合に FALSE を返します。 |
