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 — Gets file type
설명
string filetype
( string $filename
)
Returns the type of the given file.
인수
- filename
-
Path to the file.
반환값
Returns the type of the file. Possible values are fifo, char, dir, block, link, file, socket and unknown.
Returns FALSE if an error occurs. filetype() will also produce an E_NOTICE message if the stat call fails or if the file type is unknown.
예제
Example #1 filetype() example
<?php
echo filetype('/etc/passwd'); // file
echo filetype('/etc/'); // dir
?>
주의
Note: 이 함수의 결과는 캐시에 저장합니다. 자세한 설명은 clearstatcache()를 참고하십시오.
Tip
PHP 5.0.0부터 이 함수는 몇몇 URL 래퍼를 사용할 수 있습니다. 기능적으로 stat() 패밀리를 지원하는 래퍼 목록은 지원 프로토콜/래퍼 목록를 참고하십시오.
참고
- is_dir() - Tells whether the filename is a directory
- is_file() - Tells whether the filename is a regular file
- is_link() - Tells whether the filename is a symbolic link
- file_exists() - Checks whether a file or directory exists
- stat() - Gives information about a file
- mime_content_type() - Detect MIME Content-type for a file (deprecated)
filetype
7r6ivyeo at mail dot com
22-Nov-2008 01:29
22-Nov-2008 01:29
ruach at chpc dot utah dot edu
11-Mar-2004 01:11
11-Mar-2004 01: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
