ftp 服务器源码

源代码在线查看: prop.cpp

软件大小: 30 K
上传用户: cando99
关键词: ftp 服务器 源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				// Prop.cpp : implementation file
				//
				
				#include "stdafx.h"
				#include "FtpBrowse.h"
				#include "Prop.h"
				
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				
				/////////////////////////////////////////////////////////////////////////////
				// CProp property page
				
				IMPLEMENT_DYNCREATE(CProp, CPropertyPage)
				
				CProp::CProp() : CPropertyPage(CProp::IDD)
				{
					m_psp.dwFlags &= ~PSP_HASHELP; 
				
					HIMAGELIST  hSystemLargeImageList;//, hSystemLargeImageList; 
					SHFILEINFO    ssfi; 
				
				   //get a handle to the system small icon list 
					hSystemLargeImageList = 
					 (HIMAGELIST)SHGetFileInfo( 
					(LPCTSTR)_T("C:\\"), 
					0, 
					 &ssfi, 
					 sizeof(SHFILEINFO), 
					 SHGFI_SYSICONINDEX | SHGFI_LARGEICON); 
					//attach it to the small image list 
					//--DON'T FORGET TO PUT m_smallImageList.Detach();  in your destructor 
					m_largeImageList.Attach(hSystemLargeImageList); 
				
				
					//{{AFX_DATA_INIT(CProp)
					m_name = _T("");
					m_server = _T("");
					m_size = _T("");
					m_loc = _T("");
					m_hid = FALSE;
					m_created = _T("");
					m_access = _T("");
					m_ar = FALSE;
					m_comp = FALSE;
					m_sys = FALSE;
					m_ro = FALSE;
					m_modified = _T("");
					//}}AFX_DATA_INIT
				}
				
				CProp::~CProp()
				{
				}
				
				void CProp::DoDataExchange(CDataExchange* pDX)
				{
					CPropertyPage::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(CProp)
					DDX_Control(pDX, IDC_PROP_ICON, m_icon);
					DDX_Text(pDX, IDC_PROP_NAME, m_name);
					DDX_Text(pDX, IDC_PROP_SERVER, m_server);
					DDX_Text(pDX, IDC_PROP_SIZE, m_size);
					DDX_Text(pDX, IDC_PROP_LOC, m_loc);
					DDX_Check(pDX, IDC_PROP_HD, m_hid);
					DDX_Text(pDX, IDC_PROP_CREATED, m_created);
					DDX_Text(pDX, IDC_PROP_ACCESSED, m_access);
					DDX_Check(pDX, IDC_PROP_AR, m_ar);
					DDX_Check(pDX, IDC_PROP_CM, m_comp);
					DDX_Check(pDX, IDC_PROP_SY, m_sys);
					DDX_Check(pDX, IDC_PROP_RO, m_ro);
					DDX_Text(pDX, IDC_PROP_MODIFIED, m_modified);
					//}}AFX_DATA_MAP
				}
				
				
				BEGIN_MESSAGE_MAP(CProp, CPropertyPage)
					//{{AFX_MSG_MAP(CProp)
					//}}AFX_MSG_MAP
				END_MESSAGE_MAP()
				
				/////////////////////////////////////////////////////////////////////////////
				// CProp message handlers
				
				BOOL CProp::OnInitDialog() 
				{
					CPropertyPage::OnInitDialog();
				//set bitmap
					char windir[MAX_PATH];
					GetWindowsDirectory(windir,MAX_PATH);
				
					if(!m_file.dir)
						m_icon.SetIcon(m_largeImageList.ExtractIcon(GetIconIndex("*.txt")));
					else
						m_icon.SetIcon(m_largeImageList.ExtractIcon(GetIconIndex(windir)));
					
					char tmp[256];
					m_name = m_file.FileTitle;
					m_loc = m_file.Root;
					m_server = m_file.Server;
					if(m_file.size==-1) 
						m_size = "?";
					else
					{
						sprintf(tmp,"%d",m_file.size);
						m_size = tmp;
					}
					m_created = FormatString(m_file.created);
					m_access = FormatString(m_file.accessed);
					m_modified = FormatString(m_file.modfied);
					m_ro= m_file.ReadOnly;
					m_sys = m_file.System;
					m_comp = m_file.Compressed;
					m_ar = m_file.Archive;
					m_hid=m_file.Hidden;
					UpdateData(FALSE);
						
					return TRUE;  // return TRUE unless you set the focus to a control
					              // EXCEPTION: OCX Property Pages should return FALSE
				}
				
				int CProp::GetIconIndex(CString file)
				{
				    SHFILEINFO    sfi;
				        SHGetFileInfo(
				           (LPCTSTR)file, 
				           0,
				           &sfi, 
				           sizeof(SHFILEINFO), 
				           SHGFI_SYSICONINDEX | SHGFI_LARGEICON );
				
				        return sfi.iIcon;
				
				}
				
				CString CProp::FormatString(CTime time)
				{
				CString stime;
					switch( time.GetDayOfWeek())
					{
					case 0:
						stime = "Sunday, ";
						break;
					case 1:
						stime = "Monday, ";
						break;
					case 2:
						stime = "Tuesday, ";
						break;
					case 3:
						stime = "Wednesday, ";
						break;
					case 4:
						stime = "Thursday, ";
						break;
					case 5:
						stime = "Friday, ";
						break;
					case 6:
						stime = "Saturday ";
						break;
					}
					char tmp[256];
					switch(time.GetMonth())
					{
					case 1:
						stime += "January ";
						sprintf(tmp,"%d",time.GetDay());
						stime+= tmp;
						break;
					case 2:
						stime += "Feburary ";
						sprintf(tmp,"%d",time.GetDay());
						break;
					case 3:
						stime += "March ";
						sprintf(tmp,"%d",time.GetDay()); 
						break;
					case 4:
						stime += "April ";
						sprintf(tmp,"%d",time.GetDay()); 
						break;
					case 5:
						stime += "May ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 6:
						stime += "June ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 7:
						stime = "July ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 8:
						stime += "August ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 9:
						stime += "September ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 10:
						stime += "October ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 11:
						stime += "November ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					case 12:
						stime += "December ";
						sprintf(tmp,"%d",time.GetDay()); 
						stime +=tmp;
						break;
					}
					sprintf(tmp,"%d",time.GetYear());
					stime += ",  ";
					stime+=tmp;
					stime += " ";
					//time
					if(time.GetHour()>12)
					{
						sprintf(tmp,"%d",time.GetHour()-12);
						stime+= tmp;
						stime += ":";
						sprintf(tmp,"%d",time.GetMinute());
						stime+= tmp;
						stime += ":";
						sprintf(tmp,"%d",time.GetSecond());
						stime+= tmp;
						
						stime+= "  PM";
					}
					else
					{
						sprintf(tmp,"%d",time.GetHour());
						stime+= tmp;
						stime += ":";
						sprintf(tmp,"%d",time.GetMinute());
						stime+= tmp;
						stime += ":";
						sprintf(tmp,"%d",time.GetSecond());
						stime+= tmp;
						
						stime+= "  AM";
					}
					return stime;
				}
							

相关资源