C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[52705] Re:FirstFind()로 여러 확장자를 한꺼번에 검색할 수는 없나요?
o [] 1793 읽음    2008-03-15 14:03
DoyongID 님이 쓰신 글 :
: *.bmp;*.pcx;*.jpg 를 하위폴더까지 검색해서 파일 리스트를 얻어오는 프로그램을 짜려고 하는데요..
:
: 위의 확장자를 한꺼번에 검사하는 방법은 없을까요?
:
: 지금은 bmp파일을 다 찾고 나서 다시 처음부터 pcx파일 찾고, 다시 처음부터 jpg 찾고... 그런 식으로 하고 있습니다..

#include<Masks.hpp>

bool MatchesFilenameFilters(const AnsiString filename, const TStrings* filters)
{
  for(int i=0; i<filters->Count ;i++){
    if(MatchesMask(filename,filters->Strings[i])){
      return true;
    }
  }
  return false;
}

//---------------------------------------------------------------------------
void FindFiles(const AnsiString path, const TStrings* filters, bool recursive)
{
  TSearchRec sr;
  int iAttributes = ~(faSysFile|faVolumeID); // 찾을 파일 속성 지정
  if(FindFirst(path+".\\*.*", iAttributes, sr)==0){
    do{
      if(sr.Attr & faDirectory){
        if(recursive && sr.Name[1]!='.') FindFiles(path+".\\"+sr.Name,filters,recursive);
      }else{
        if(MatchesFilenameFilters(sr.Name,filters)) ; //파일필터에 맞음
        else ; //파일필터에 맞지 않음
      }
    } while(FindNext(sr)==0);
    FindClose(sr);
  }
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//Edit1에 찾을 디렉터리를, ListBox1에 파일필터들을 한줄에 하나씩, CheckBox1에 하위디렉터리검색여부를 지정한 후
FindFiles(Edit1->Text,ListBox1->Items,CheckBox1->Checked);
}

+ -

관련 글 리스트
52701 FirstFind()로 여러 확장자를 한꺼번에 검색할 수는 없나요? DoyongID 1242 2008/03/14
52705     Re:FirstFind()로 여러 확장자를 한꺼번에 검색할 수는 없나요? o 1793 2008/03/15
52704     Re:FirstFind()로 여러 확장자를 한꺼번에 검색할 수는 없나요? 방태윤 2003 2008/03/15
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.