VirtualFileSystem.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:7k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // VirtualFileSystem.h : header file
- //
- #include "unix.h"
- /////////////////////////////////////////////////////////////////////////////
- // CVirtualFileSystem window
- // Each therad has it's own private window. At this time the window
- // is executed by the callers therad (to relax task switching).
- // However, this might change. The caller must not relay on the
- // fact that the window is ran by it's own thread.
- class DLL_VFSYS_ CVirtualFileSystem : public CWnd
- {
- // Construction
- public:
- CVirtualFileSystem();
- static SMEM m_MasterVfSys; // Master file system
- static CLinkedList m_FreeThreads;
- static CLinkedList m_BusyThreads;
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CVirtualFileSystem)
- //}}AFX_VIRTUAL
- // Implementation
- public:
- virtual ~CVirtualFileSystem();
- static CWinThread *GetThread(CWinThread *pTherad, HWND hWnd);
- LONG ProcessRequest(int Type, WPARAM wParam, LPARAM lParam);
- static void Shutdown();
- afx_msg LONG mhCallback( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhCreateFile( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhCreate( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhChdir( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhChmod( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhPreperePath( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhList( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhCloseFile( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhWlist( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhFsysstat( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhCreateDir( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhDeleteDir( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhDeleteFile( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhDeleteGeneric( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhLinkFile( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhMoveFile( WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhQuit(WPARAM wParam, LPARAM lParam);
- afx_msg LONG mhStat(WPARAM wParam, LPARAM lParam);
- // Generated message map functions
- protected:
- //{{AFX_MSG(CVirtualFileSystem)
- // NOTE - the ClassWizard will add and remove member functions here.
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- class DLL_VFSYS_ CFsysThread
- {
- public:
- CFsysThread();
- ~CFsysThread();
- static UINT EntryPoint(LPVOID pParam);
- UINT Process();
- DIR_NODE *GetRootNode();
- void LogMsg(int flag, LPCSTR Format, ...);
- BOOL ParseRootpath(LPCSTR RootPath, CString& Name, CString& LinkPath);
- BOOL ScanPath(LPCSTR Path, BOOL FullScanToPath, BOOL Recursive, BOOL Force, BOOL DoLock = TRUE);
- BOOL ParsePath(CString& Path);
- BOOL CheckPermissions(LPCSTR Path, DWORD ReqType, DWORD Perm, SMEM *psmNode);
- BOOL UserHasPermission(DWORD Perms, DWORD PermWanted);
- BOOL UserHasPermission(DIR_NODE *pDir, DWORD Perm);
- SMEM FindNode(SMEM& smDir, LPCSTR Name);
- BOOL BldFileInfoList(CFileList& FileList, LPCSTR Path, BOOL ListDir);
- int AddFileInfoListPath(CFileList& FileList, LPCSTR Path, LPCSTR Pattern);
- int AddFileInfoListPath(CFileList& FileList, SMEM smDir, LPCSTR Pattern);
- BOOL ChDir(LPCSTR Path);
- void Flush(SMEM smDir);
- // User functions
- BOOL DoCreateUser(LPCSTR RootPaths);
- BOOL DoCreateFile(LPCSTR Path);
- BOOL DoChDirUser(LPCSTR Path);
- BOOL DoPrepereUserCmdLine(LPCSTR CmdLine);
- BOOL DoList(LPCSTR ArgumentsUnparsed);
- BOOL DoWlist(LPCSTR ArgumentsUnparsed);
- void DoCloseFile(SMEM smNode);
- BOOL DoChmod(CCmdArgs& Args);
- BOOL DoFsysStat();
- BOOL DoCreateDirectory(LPCSTR Path);
- BOOL DoDeleteGeneric(LPCSTR Path, DWORD Flags);
- BOOL DoCreateLink(LPCSTR From, LPCSTR To);
- BOOL DoMoveFile(LPCSTR From, LPCSTR To);
- BOOL DoStat(LPCSTR Path);
- // Data members
- CCriticalSection m_Lock;
- int m_SeqNo;
- HWND m_CallbackWin;
- static int m_NumThreadsStarted;
- CUserFsys *m_pFsys;
- enum // Delete flags
- {
- DELE_FILE = 0x00000001,
- DELE_DIR = 0x00000002
- };
- };
- class DLL_VFSYS_ CChmod : public CUnix
- {
- protected:
- int m_Owner;
- int m_Group;
- LPCSTR m_Comment;
- int m_DefDirPerms;
- int m_DefFilePerms;
- int m_SpecialNewFilePerm;
- BOOL m_SetMode;
- CFsysThread *m_pFsysThread;
- CStringList m_VisitedDirs;
- LPVOID set;
- long val;
- int oct, omode;
- int Hflag, Lflag, Pflag, Rflag, ch, fflag, hflag, rval;
- char *ep, *mode;
- public:
- CChmod(CFsysThread *pFsysThread);
- ~CChmod();
- protected:
- virtual int main(int argc, char **argv);
- int Process(int argc, char **argv, int Level, CFileList& MasterFileList);
- int _Process(int argc, char **argv, int Level, CFileList& MasterFileList);
- int usage();
- BOOL ChmodFileList(CFileList& FileList, LPCSTR Path);
- int __chmod(FILE_NODE *pNode, int SetMode, int SetOwner,
- int SetClass, LPCSTR SetComment, int DefDirMode,
- int DefFileMode, int SpecialNewFilePerm);
- };
- class DLL_VFSYS_ CVfSysLs : public CUnix
- {
- public:
- long blocksize; /* block size units */
- int termwidth; /* default terminal width */
- /* flags */
- int f_accesstime; /* use time of last access */
- int f_column; /* columnated format */
- int f_flags; /* show flags associated with a file */
- int f_inode; /* print inode */
- int f_kblocks; /* print size in kilobytes */
- int f_listdir; /* list actual directory, not contents */
- int f_listdot; /* list files beginning with . */
- int f_hidethisandprevdotdir;
- int f_longform; /* long listing format */
- int f_newline; /* if precede with newline */
- int f_nonprint; /* show unprintables as ? */
- int f_nosort; /* don't sort output */
- int f_recursive; /* ls subdirectories also */
- int f_reversesort; /* reverse whatever sort is used */
- int f_sectime; /* print the real time for all files */
- int f_singlecol; /* use single column output */
- int f_size; /* list size in short listing */
- int f_statustime; /* use time of last mode change */
- int f_dirname; /* if precede with directory name */
- int f_timesort; /* sort by time vice name */
- int f_type; /* add type character for non-regular files */
- int f_followLinks; // Follown any symbolic links (FTS_COMFOLLOW)
- int f_printdlc;
- int f_comment;
- int output;
- int (*sortfcn)(const CLinkedListItem **a, const CLinkedListItem **b);
- FLEN btotal;
- int entries;
- int maxlen;
- FLEN maxsize;
- int s_block, s_group, s_inode, s_nlink, s_size, s_user;
- BOOL m_Virgin;
- CFsysThread *m_pFsysThread;
- FILE_NODE **array;
- int lastentries;
- CStringList m_VisitedDirs;
- public:
- CVfSysLs();
- ~CVfSysLs();
- virtual int main(int argc, char **argv);
- int ListDir(int argc, char **argv);
- int _ListDir(int argc, char **argv);
- BOOL PrintFileList(CFileList& FileList, LPCSTR Path);
- void printscol(CFileList& FileList, LPCSTR Path);
- int printaname(CPseudoFileInfo& Info, LPCSTR Path);
- int printtype(CPseudoFileInfo& Info);
- void printlong(CFileList& FileList, LPCSTR Path);
- void printtime(LPFILETIME ftime);
- void printcol(CFileList& FileList, LPCSTR Path);
- int printcomment(CPseudoFileInfo& Info);
- static int namecmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int revnamecmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int modcmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int revmodcmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int acccmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int revacccmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int statcmp(const CLinkedListItem **a, const CLinkedListItem **b);
- static int revstatcmp(const CLinkedListItem **a, const CLinkedListItem **b);
- void usage();
- };