프로그래밍/윈도우 프로그래밍
[VS2005 C++] 파일인지 디렉토리인지 구분하기
체리
2007. 3. 31. 16:05
반응형
VS2005에 국한된 이야기가 아니다.
CFileStatus의 m_attribute enum은 아래와 같이 구성되어 있다.
enuenum Attribute {
normal = 0x00,
readOnly = 0x01,
hidden = 0x02,
system = 0x04,
volume = 0x08,
directory = 0x10,
archive = 0x20
};
normal = 0x00,
readOnly = 0x01,
hidden = 0x02,
system = 0x04,
volume = 0x08,
directory = 0x10,
archive = 0x20
};
따라서 다음과 같이 파일인지 디렉토리인지 구분할 수 있다.
CFileStatus fileStatus;
-생략-
if(fileStatus.m_attribute & 0x10)
디렉토리일 경우
else
파일일 경우
만일 CFileFind 클래스를 사용할 수 있다면 IsDirectory()함수를 사용할 수 있다.
반응형