티스토리 뷰
프로그램의 솔루션 디렉토리를 선택 하면
해당 프로그램에 들어간 소스의 라인 수를 계산하여 출력해 주는 프로그램.
현재 c, cpp, h, java, cs, py 확장자만 지원한다.
소스는 너무 간단해서.. 걍 대충 주석써서 올리겠음.
void CCodeLineSearcherDlg::FindLine( int &nTotalLine, CString strPath )
{
CFileFind finder;
finder.FindFile( strPath );
int res = 1;
while( res )
{
res = finder.FindNextFile();
if( ( m_bC && finder.GetFileName().Right(2) == _T(".c") ) ||
( m_bCPP && finder.GetFileName().Right(4) == _T(".cpp") ) ||
( m_bH && finder.GetFileName().Right(2) == _T(".h") ) ||
( m_bJava && finder.GetFileName().Right(5) == _T(".java") ) ||
( m_bCS && finder.GetFileName().Right(3) == _T(".cs") ) ||
( m_bPY && finder.GetFileName().Right(3) == _T(".py") ) ||
( m_bALL )
)
{
CStdioFile file;
if( file.Open( finder.GetFilePath(), CFile::modeRead ) )
{
int nRead = 1;
CString strTmp = _T("");
//한줄한줄 읽음
while( file.ReadString( strTmp ) )
nRead++;
//전체 라인수에 더해줌
nTotalLine += nRead;
}
}
if( m_bIncludeSubDirectory &&
finder.IsDirectory() &&
finder.GetFileName() != _T(".") &&
finder.GetFileName() != _T("..") )
{
CString strSubPath = _T("\\*.*");
strSubPath = finder.GetFilePath() + strSubPath;
FindLine( nTotalLine, strSubPath );
}
}
}
void CCodeLineSearcherDlg::OnBnClickedButton1()
{
UpdateData();
TCHAR strPath[MAX_PATH];
BROWSEINFO browse;
browse.hwndOwner = this->m_hWnd;
browse.pidlRoot = NULL;
browse.pszDisplayName = NULL;
browse.lpszTitle = _T("솔루션 폴더를 선택하세요");
browse.ulFlags = BIF_RETURNONLYFSDIRS;
browse.lpfn = NULL;
browse.lParam = 0;
LPITEMIDLIST pidl = SHBrowseForFolder(&browse);
if(pidl == NULL) return;
if( SHGetPathFromIDList(pidl,strPath) )
{
CFileFind finder;
CString strTotalPath = _T("");
strTotalPath.Format( _T("%s\\*.*"),strPath );
finder.FindFile( strTotalPath );
int nTotalLine = 0;
FindLine( nTotalLine, strTotalPath );
CString strOutput = _T("");
strOutput.Format(_T("Total Line Count : %d"), nTotalLine );
AfxMessageBox( strOutput );
}
}
'Development > Windows' 카테고리의 다른 글
| [MFC] class에서 static 멤버 변수 쓰기 (0) | 2011.07.28 |
|---|---|
| [MFC] 유니코드와 멀티바이트로 작성된 프로그램과 DLL 사용 안됨. (0) | 2011.07.28 |
| [MFC] 일본어 폰트 지원 문제에 관련해서 (0) | 2011.07.26 |
| [MFC] CTreeCtrl font 관련 설정 바꾸기. (0) | 2011.07.01 |
| [MFC] MFC에서 argv 받기 (0) | 2011.06.02 |
| [API/MFC] 레지스트리 읽고 쓰는 함수 (1) | 2011.06.02 |
| [Visual C++] MultiByteToWideChar와 WidecharToMultiByte의 사용. (0) | 2011.05.12 |
| [Visual C++] shift_jis 인코딩 문제 (0) | 2011.05.11 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- source
- jni강좌
- 안드로이드
- MFC
- Python
- algorithm
- C++
- kering
- android
- driver
- database
- 프로그래밍
- it
- C
- 드라이버
- NDK
- db
- Visual C++
- Quiz
- 리눅스
- winapi
- API
- jni
- Troubleshooting
- java
- linux
- Cloud
- AWS
- gcc
- 음악
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함
CodeLineSearcher.zip