FileView.cpp
上传用户:gzboli
上传日期:2013-04-10
资源大小:471k
文件大小:18k
- // FileView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "QuickImage.h"
- #include "FileView.h"
- //#include <Lmshare.h>
- #include "DirFrm.h"
- #include "QuickView.h"
- #include "DirView.h"
- #include "Global.h"
- #include "resource.h"
- #include "DlgRename.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern bool g_bShowHide;
- extern CString g_strCurrentDir;
- extern int g_iSortColumn;
- /////////////////////////////////////////////////////////////////////////////
- // CFileView
- IMPLEMENT_DYNCREATE(CFileView, CListView)
- CFileView::CFileView()
- {
- g_iSortColumn = 0;
- }
- CFileView::~CFileView()
- {
- }
- BEGIN_MESSAGE_MAP(CFileView, CListView)
- ON_WM_CONTEXTMENU()
- //{{AFX_MSG_MAP(CFileView)
- ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnItemchanged)
- ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
- ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
- ON_COMMAND(ID_FILE_RENAME, OnFileRename)
- ON_UPDATE_COMMAND_UI(ID_FILE_RENAME, OnUpdateFileRename)
- ON_NOTIFY_REFLECT(LVN_ENDLABELEDIT, OnEndlabeledit)
- ON_WM_KEYDOWN()
- //}}AFX_MSG_MAP
- ON_COMMAND_RANGE(ID_DIR_UP, ID_DIR_END, OnDirButtons)
- ON_UPDATE_COMMAND_UI_RANGE(ID_DIR_UP, ID_DIR_END, OnUpdateDirButtons)
- END_MESSAGE_MAP()
- //////////////////////
- ///////////////////////////////////////////////////////
- // CFileView drawing
- void CFileView::OnDraw(CDC* pDC)
- {
- CDocument* pDoc = GetDocument();
- // TODO: add draw code here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CFileView diagnostics
- #ifdef _DEBUG
- void CFileView::AssertValid() const
- {
- CListView::AssertValid();
- }
- void CFileView::Dump(CDumpContext& dc) const
- {
- CListView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CFileView message handlers
- BOOL CFileView::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.lpszName = WC_LISTVIEW;
- cs.style &= ~LVS_TYPEMASK;
- cs.style |= LVS_REPORT;
- cs.style |= LVS_EDITLABELS;
- // cs.style |= LVS_OWNERDATA;
-
- return CListView::PreCreateWindow(cs);
- }
- void CFileView::OnInitialUpdate()
- {
- CListView::OnInitialUpdate();
-
- CListCtrl &rListCtrl = GetListCtrl();
- HIMAGELIST hImageList;
- SHFILEINFO sfi;
- hImageList = (HIMAGELIST)SHGetFileInfo((LPCSTR)"C:\",
- 0,
- &sfi,
- sizeof(SHFILEINFO),
- SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
- // Attach ImageList to TreeView
- if (hImageList)
- ::SendMessage(rListCtrl.m_hWnd, LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL,
- (LPARAM)hImageList);
- /* SHFILEINFO ssfi;
- HIMAGELIST hSystemSmallImageList, him;
- // CImageList imList;
-
- hSystemSmallImageList = (HIMAGELIST)SHGetFileInfo("C:\", 0, &ssfi,
- sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
-
- him = ImageList_Duplicate(hSystemSmallImageList);
- m_ImageList.Create(CImageList::FromHandle(him));
- m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_FILE));
- m_ImageList.SetBkColor(CLR_NONE);
- // ImageList_SetBkColor(him, CLR_NONE);
-
- rListCtrl.SetImageList(&m_ImageList, LVSIL_SMALL);
- */
- // DWORD dwExStyle = LVS_EX_FULLROWSELECT| LVS_SHOWSELALWAYS | ES_NOHIDESEL| LVS_EX_SUBITEMIMAGES |//LVS_EX_GRIDLINES |
- // LVS_EDITLABELS;//LVS_EX_HEADERDRAGDROP | | LVS_EX_TRACKSELECT | LVS_OWNERDRAWFIXED;
- DWORD dwExStyle = LVS_EX_SUBITEMIMAGES | LVS_EDITLABELS | LVS_EX_HEADERDRAGDROP;
-
- rListCtrl.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LPARAM(dwExStyle));
- CRect rcClient;
- GetClientRect(&rcClient);
- rListCtrl.InsertColumn( 0, "Name", LVCFMT_LEFT, rcClient.Width() / 4, 0 );
- rListCtrl.InsertColumn( 1, "Size", LVCFMT_LEFT, rcClient.Width() / 4, 0 );
- rListCtrl.InsertColumn( 2, "Type", LVCFMT_LEFT, rcClient.Width() / 4, 0 );
- rListCtrl.InsertColumn( 3, "Date", LVCFMT_LEFT, rcClient.Width() / 4, 0 );
- }
- void CFileView::ListFiles()
- {
- ASSERT(g_strCurrentDir.GetLength() > 0);
- char szStartDir[MAX_PATH];
- sprintf(szStartDir, "%s*.*", g_strCurrentDir);
- int iItem = 0;
- HANDLE hFile; // Handle to found file
- WIN32_FIND_DATA stFindData; // Info about the found file
- double dFileSize;
- SYSTEMTIME systime;
- char szTime[20];
- char szTemp[MAX_PATH];
- SHFILEINFO sfi;
- LVITEM lvi;
- CListCtrl &rListCtrl = GetListCtrl();
- rListCtrl.DeleteAllItems();
- hFile = FindFirstFile((LPCTSTR)szStartDir, &stFindData);
- if (INVALID_HANDLE_VALUE == hFile)
- {
- // MessageBox("FindFirstFile() returned INVALID_HANDLE_VALUE", "DEBUG", MB_OK);
- MessageBox("Access denied by system!", "DEBUG", MB_OK);
- return;
- }
- // iImages = rListCtrl.GetImageList(LVSIL_SMALL)->GetImageCount() -1;
- do//while (INVALID_HANDLE_VALUE != hFile)
- {
- if ((0 == strcmp(stFindData.cFileName, "."))
- || (0 == strcmp(stFindData.cFileName, ".."))
- || (stFindData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
- || ((stFindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) && !g_bShowHide)
- )
- {// 跳过"." 和 ".." 和 “系统" 和 "隐藏"
- }
- else
- {//file
- sprintf(szTemp, "%s%s", g_strCurrentDir, stFindData.cFileName);
- SHGetFileInfo(szTemp, 0, &sfi,sizeof(SHFILEINFO),
- SHGFI_SYSICONINDEX | SHGFI_SMALLICON |
- SHGFI_ATTRIBUTES | SHGFI_TYPENAME);
-
- lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
- lvi.iItem = iItem;
- lvi.iSubItem = 0;
- lvi.iImage = sfi.iIcon;// > iImages ? iImages : sfi.iIcon;
- lvi.pszText = stFindData.cFileName;
- lvi.cchTextMax = MAX_PATH;
- // lvi.lParam = (LPARAM)pfi;
- rListCtrl.InsertItem(&lvi);
-
- if(!(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- dFileSize = (double)stFindData.nFileSizeHigh * (double)(MAXDWORD+1.0)
- + (double)stFindData.nFileSizeLow;
- if(int(dFileSize / 1024) > 0)
- {
- sprintf(szTemp, "%d K", int(dFileSize / 1024) + 1);
- }
- else
- {
- sprintf(szTemp, "%d bytes", (int)dFileSize);
- }
- rListCtrl.SetItemText(iItem, 1, szTemp);
- }
-
- rListCtrl.SetItemText(iItem, 2, sfi.szTypeName);
-
- FileTimeToSystemTime(&stFindData.ftLastWriteTime, &systime);
- GetDateFormat(LOCALE_SYSTEM_DEFAULT,
- LOCALE_NOUSEROVERRIDE | DATE_USE_ALT_CALENDAR,
- &systime,
- NULL,
- szTime,
- 64);
- strcat(szTime, _T(" "));
- GetTimeFormat(LOCALE_SYSTEM_DEFAULT,
- LOCALE_NOUSEROVERRIDE|TIME_NOSECONDS,
- &systime,
- NULL,
- szTemp,
- 32);
- strcat(szTime, szTemp);
- rListCtrl.SetItemText(iItem, 3, szTime);
- iItem++;
- }
- }while(FindNextFile(hFile, &stFindData));
-
- FindClose(hFile);
- GetQuickView()->SetFileName();
- rListCtrl.SortItems((PFNLVCOMPARE)SortFunc, (LPARAM)&rListCtrl);
- /* LVCOLUMN lvColumn;
- int 0, 1, 2, 3;
- lvColumn.mask = LVCF_TEXT;
- lvColumn.cchTextMax = 5;
- lvColumn.pszText = szStartDir;
- for(iItem = 0; iItem < 4; iItem++)
- {
- if(!rListCtrl.GetColumn(iItem, &lvColumn))
- break;
- if(stricmp(lvColumn.pszText, "name") == 0)
- {
- 0 = iItem;
- }
- else if(stricmp(lvColumn.pszText, "size") == 0)
- {
- 1 = iItem;
- }
- else if(stricmp(lvColumn.pszText, "type") == 0)
- {
- 2 = iItem;
- }
- else if(stricmp(lvColumn.pszText, "date") == 0)
- {
- 3 = iItem;
- }
- else
- {
- ASSERT(FALSE);
- }
- }
- */
- }
- CQuickView* CFileView::GetQuickView(void)
- {
- CWnd *pParent = GetParent();
- while(NULL != pParent)
- {
- if(pParent->IsKindOf(RUNTIME_CLASS(CDirFrame)))
- return (CQuickView*)(((CDirFrame*)pParent)->m_wndSplitH.GetPane(1, 0));
-
- pParent = pParent->GetParent();
- }
- return NULL;
- }
- CDirView* CFileView::GetDirView(void)
- {
- CWnd *pParent = GetParent();
- while(NULL != pParent)
- {
- if(pParent->IsKindOf(RUNTIME_CLASS(CDirFrame)))
- return (CDirView*)(((CDirFrame*)pParent)->m_wndSplitH.GetPane(0, 0));
- pParent = pParent->GetParent();
- }
- return NULL;
- }
- void CFileView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- if (pNMListView->uChanged == LVIF_STATE)
- {
- CString strFileName;
-
- if(MakeFileNameFromListItem(strFileName))
- {
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = FindFirstFile((LPCTSTR)strFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(!(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- GetQuickView()->SetFileName(strFileName);
- }
- }
- FindClose(hFind);
- }
- }
-
- *pResult = 0;
- }
- BOOL CFileView::MakeFileNameFromListItem(CString &strFileName, int iItem)
- {
- CListCtrl &rList = GetListCtrl();
- if(-1 == iItem)
- {
- if(rList.GetSelectedCount() < 1)
- {
- return FALSE;
- }
- POSITION pos = rList.GetFirstSelectedItemPosition();
- iItem = rList.GetNextSelectedItem(pos);
- }
- ASSERT(iItem < rList.GetItemCount());
- LVCOLUMN lvColumn;
- int iName = 0;
- lvColumn.mask = LVCF_TEXT;
- lvColumn.cchTextMax = 5;
- char szLVC[5];
- lvColumn.pszText = szLVC;
- for(int k = 0; k < 4; k++)
- {
- if(!rList.GetColumn(k, &lvColumn))
- break;
- if(stricmp(lvColumn.pszText, "name") == 0)
- {
- iName = k;
- break;
- }
- }
- char szTemp[_MAX_PATH];
- rList.GetItemText(iItem, iName, szTemp, MAX_PATH);
- strFileName = g_strCurrentDir + szTemp;
- return TRUE;
- }
- void CFileView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
- {
- CString strFileName;
- if(MakeFileNameFromListItem(strFileName))
- {
- if(CGlobal::IsImgFile(strFileName))
- {
- ((CQuickImageApp*)AfxGetApp())->m_pImageTemplate->
- OpenDocumentFile(strFileName);
- }
- else
- {
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = FindFirstFile((LPCTSTR)strFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- GetDirView()->ExpendItem(strFileName + _T("\"));
- }
- }
- FindClose(hFind);
- }
- }
-
- *pResult = 0;
- }
- void CFileView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- if(pNMListView->iItem > -1)
- {
- CPoint point = pNMListView->ptAction;
- ClientToScreen(&point);
- point.Offset(5, 5);
-
- CMenu menu;
- VERIFY(menu.LoadMenu(CG_IDR_POPUP_FILE_VIEW));
-
- CMenu* pPopup = menu.GetSubMenu(0);
- ASSERT(pPopup != NULL);
- CWnd* pWndPopupOwner = this;
-
- while (pWndPopupOwner->GetStyle() & WS_CHILD)
- pWndPopupOwner = pWndPopupOwner->GetParent();
-
- pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
- pWndPopupOwner);
- }
-
- *pResult = 0;
- }
- void CFileView::OnFileRename()
- {
- CDlgRename dlg;
- if(dlg.DoModal() == IDOK)
- {
- CString strTemplate = dlg.m_strTemplate;
- int iStart = dlg.m_iStart;
- char *szFront = new char[strTemplate.GetLength() +1];
- if(NULL == szFront)
- {
- return;
- }
- CString strBack;
- strcpy(szFront, strTemplate);
- char *pDevide = strchr(szFront, '*');
- if(NULL == pDevide)
- {
- strBack = _T("");
- }
- else
- {
- *pDevide = ' ';
- pDevide = strrchr(strTemplate, '*');
- strBack = ++pDevide;
- }
- CString strNewFileName, strOldFileName;
- CListCtrl &rList = GetListCtrl();
- POSITION pos = rList.GetFirstSelectedItemPosition();
- int iItem;
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = NULL;
- char *pNewTitle = NULL;
- CDirView *pDirView = GetDirView();
- ASSERT(NULL != pDirView);
- while(pos)
- {
- iItem = rList.GetNextSelectedItem(pos);
- if(!MakeFileNameFromListItem(strOldFileName, iItem))
- {
- break;
- }
- strNewFileName.Format("%s%s%0d%s",
- g_strCurrentDir, szFront, iStart++, strBack);
- hFind = FindFirstFile((LPCTSTR)strOldFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- pNewTitle = strrchr(strNewFileName, '\');
- pDirView->SetItemText(strOldFileName, ++pNewTitle);
- }
- }
- FindClose(hFind);
- CFile::Rename(strOldFileName, strNewFileName);
- }
- delete szFront;
- ListFiles();
- }
- }
- void CFileView::OnUpdateFileRename(CCmdUI* pCmdUI)
- {
- /* CString strFileName;
- if(!MakeFileNameFromListSel(strFileName))
- {
- pCmdUI->Enable(FALSE);
- }
- else
- {
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = FindFirstFile((LPCTSTR)strFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- pCmdUI->Enable(FALSE);
- }
- }
- FindClose(hFind);
- pCmdUI->Enable(TRUE);
- }
- */ pCmdUI->Enable(GetListCtrl().GetSelectedCount() > 0);
- }
- void CFileView::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult)
- {
- LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
- // TODO: Add your control notification handler code here
- CString strNew, strOldFileName, strNewFileName;
- if(!MakeFileNameFromListItem(strOldFileName, pDispInfo->item.iItem))
- {
- return;
- }
- GetListCtrl().GetEditControl()->GetWindowText(strNew);
- strNewFileName.Format("%s%s", g_strCurrentDir, strNew);
-
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = FindFirstFile((LPCTSTR)strOldFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- char *pNewTitle = strrchr(strNewFileName, '\');
- GetDirView()->SetItemText(strOldFileName, ++pNewTitle);
- }
- }
- FindClose(hFind);
-
- CFile::Rename(strOldFileName, strNewFileName);
- GetListCtrl().SetItemText(pDispInfo->item.iItem, pDispInfo->item.iSubItem, strNew);
-
- *pResult = 0;
- }
- void CFileView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- if(nChar == 13)//VK_ENTER
- {
- CString strFileName;
- if(MakeFileNameFromListItem(strFileName))
- {
- if(CGlobal::IsImgFile(strFileName))
- {
- ((CQuickImageApp*)AfxGetApp())->m_pImageTemplate->
- OpenDocumentFile(strFileName);
- }
- else
- {
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = FindFirstFile((LPCTSTR)strFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- GetDirView()->ExpendItem(strFileName + _T("\"));
- }
- }
- FindClose(hFind);;
- }
- }
- }
- else if(nChar == 46)//Delete
- {
- CString strFileName;
- if(MakeFileNameFromListItem(strFileName))
- {
- WIN32_FIND_DATA stFindData;
- HANDLE hFind = FindFirstFile((LPCTSTR)strFileName, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- if(stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- {
- GetDirView()->DeleteItem(strFileName + _T("\"));
- }
- }
- DeleteFile(strFileName);
- FindClose(hFind);
- POSITION pos = GetListCtrl().GetFirstSelectedItemPosition();
- GetListCtrl().DeleteItem(GetListCtrl().GetNextSelectedItem(pos));
- }
- }
-
- CListView::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CFileView::OnDirButtons(UINT nID)
- {
- CListCtrl &rList = GetListCtrl();
- int iHot = rList.GetNextItem(-1, LVNI_SELECTED);
- switch(nID)
- {
- case ID_DIR_UP:
- GetDirView()->MoveToUpFolder();
- ListFiles();
- break;
- case ID_DIR_HOME:
- if(iHot != -1)
- {
- rList.SetItemState(iHot,
- ~LVIS_SELECTED & ~LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- }
- rList.SetItemState(0,
- LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- break;
- case ID_DIR_PREV:
- if(iHot != -1)
- {
- rList.SetItemState(iHot,
- ~LVIS_SELECTED & ~LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- iHot --;
- if(iHot == -1)
- {
- iHot = rList.GetItemCount() -1;
- }
- rList.SetItemState(iHot,
- LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- }
- else
- {
- rList.SetItemState(rList.GetItemCount() -1,
- LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- }
- break;
- case ID_DIR_NEXT:
- if(iHot != -1)
- {
- rList.SetItemState(iHot,
- ~LVIS_SELECTED & ~LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- iHot ++;
- if(iHot == rList.GetItemCount())
- {
- iHot = 0;
- }
- rList.SetItemState(iHot,
- LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- }
- else
- {
- rList.SetItemState(0,
- LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- }
- break;
- case ID_DIR_END:
- if(iHot != -1)
- {
- rList.SetItemState(iHot,
- ~LVIS_SELECTED & ~LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- }
- rList.SetItemState(rList.GetItemCount() -1,
- LVIS_SELECTED | LVIS_FOCUSED , LVIS_SELECTED | LVIS_FOCUSED);
- break;
- default:
- break;
- }
- }
- void CFileView::OnUpdateDirButtons(CCmdUI *pCmdUI)
- {
- /* switch(pCmdUI->m_nID)
- {
- case ID_DIR_UP:
- pCmdUI->Enable(TRUE);
- break;
- case ID_DIR_HOME:
- break;
- case ID_DIR_PREV:
- break;
- case ID_DIR_NEXT:
- break;
- case ID_DIR_END:
- break;
- default:
- break;
- }*/
- pCmdUI->Enable(TRUE);
- }
- int CALLBACK CFileView::SortFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
- {
- // lParamSort contains a pointer to the list view control.
- // The lParam of an item is just its index.
- CListCtrl* pListCtrl = (CListCtrl*) lParamSort;
- CString strItem1 = pListCtrl->GetItemText(lParam1, g_iSortColumn);
- CString strItem2 = pListCtrl->GetItemText(lParam2, g_iSortColumn);
-
- CString strFile1 = g_strCurrentDir + strItem1;
- CString strFile2 = g_strCurrentDir + strItem2;
- WIN32_FIND_DATA stFindData;
- BOOL bIsFolder1, bIsFolder2;
-
- HANDLE hFind = FindFirstFile((LPCTSTR)strFile1, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- bIsFolder1 = stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
- }
- hFind = FindFirstFile((LPCTSTR)strFile2, &stFindData);
- if (INVALID_HANDLE_VALUE != hFind)
- {
- bIsFolder2 = stFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
- }
- FindClose(hFind);
-
- if(bIsFolder1 && !bIsFolder2)
- return -1;
- if(!bIsFolder1 && bIsFolder2)
- return 1;
- return strcmp(strItem1, strItem2);
- }