I use the CLI version of PHP on Windows Vista. Here's how to determine if a file is marked "hidden" by NTFS:
<?php
function is_hidden_file($fn) {
$attr = trim(exec('FOR %A IN ("'.$fn.'") DO @ECHO %~aA'));
if($attr[3] === 'h')
return true;
return false;
}
?>
Changing <?php if($attr[3] === 'h') ?> to <?php if($attr[4] === 's') ?> will check for system files.
This should work on any Windows OS that provides DOS shell commands.
filetype
(PHP 4, PHP 5)
filetype — Lê o tipo do arquivo
Descrição
Retorna o tipo do arquivo.
Parâmetros
- filename
-
Caminho até o arquivo.
Valor Retornado
Retorna o tipo do arquivo. Os valores possíveis são fifo, char, dir, block, link, file, socket e unknown (desconhecido).
Retorna FALSE se ocorrer algum erro. filetype() também produzirá uma mensagem E_NOTICE se a chamada stat falhar ou se o tipo do arquivo for desconhecido.
Exemplos
Exemplo #1 Exemplo de filetype()
<?php
echo filetype('/etc/passwd'); // file
echo filetype('/etc/'); // dir
?>
Notas
Nota: O resultado desta função é cacheada. Veja clearstatcache() para mais detalhes.
A partir do PHP 5.0.0, esta função também pode ser utilizada com alguns wrappers URL. Veja List of Supported Protocols/Wrappers para uma lista de quais wrappers são suportados pela família de funções stat().
Veja Também
- is_dir() - Diz se o caminho é um diretório
- is_file() - Informa se o arquivo é um arquivo comum (não é diretório)
- is_link() - Diz se o arquivo é um link simbólico (symbolic link)
- file_exists() - Checa se um arquivo ou diretório existe
- stat() - Obtem informações sobre um arquivo
- mime_content_type() - Detecta o tipo MIME de um arquivo
filetype
21-Nov-2008 11:29
10-Mar-2004 11:11
There are 7 values that can be returned. Here is a list of them and what each one means
block: block special device
char: character special device
dir: directory
fifo: FIFO (named pipe)
file: regular file
link: symbolic link
unknown: unknown file type
