VfFsys.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:10k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // This is part of the WAR SOFTWARE SERIES initiated by Jarle Aase
- // Copyright 1996 by Jarle Aase. All rights reserved.
- // See the "War Software Series Licende Agreement" for details concerning
- // use and distribution.
- // ---
- // This source code, executables and programs containing source code or
- // binaries or proprietetary technology from the War Software Series are
- // NOT alloed used, viewed or tested by any governmental agencies in
- // any countries. This includes the government, departments, police,
- // military etc.
- // ---
- // This file is intended for use with Tab space = 2
- // Created and maintained in MSVC Developer Studio
- // ---
- // NAME : VfFsys.h
- // PURPOSE : Header file War Daemon Virtual File System
- // PROGRAM :
- // DATE : March 13 1997
- // AUTHOR : Jarle Aase
- // ---
- //
- // Exports are done in the .def file.
- // DLL_VFSYS_ exports are used by vfsys native plugins only
- //
- // REVISION HISTORY
- //
- #ifdef DLL_VFSYS_EXPORT
- #define DLL_VFSYS_ __declspec(dllexport)
- #else
- #define DLL_VFSYS_ __declspec(dllimport)
- #endif
- #define FSYS_DIR_MAX_UMASK 2
- #define DRIVER_NAME_LEN 32
- #define DRIVER_TABLE_SIZE 32
- #define PLUGIN_TABLE_SIZE 32
- #define DEFAULT_NEW_FILE_PERMS 0666
- #define DEFAULT_NEW_DIR_PERMS 0777
- struct FILE_SYSTEM
- {
- char DOSPath[MAX_PATH]; // Network or DOS path
- char Vpath[MAX_PATH]; // Virtual path to root node
- int DevIdx; // Index to device driver
- char LoginName[32];
- char LoginPwd[32];
- DWORD FlushDelay;
- BOOL DoCopy;
- SMEM RootNode; // Root directory node for the file system
- SMEM Next; // Single linked list
- };
- struct FILE_NODE
- {
- public:
- DWORD Perms; // Permissions
- USER User; // Owner
- USER Class; // Class
- SMEM MoreUsers; // USER[] List of more users with class permission
- FLEN Size;
- FILETIME CreationTime;
- FILETIME LastWriteDate;
- FILETIME lastDlTime;
- DWORD DlCount;
- unsigned f_OpenCnt : 16; // Number of open handles
- unsigned f_Deleted : 1; // Deleted
- unsigned f_DeleteFile : 1; // If deleted, also delete the physical file
- unsigned f_Locked : 1; // Exclusive lock
- unsigned f_UseCopy: 1; // Use the copy for normal file access
- unsigned f_UseHome: 1; // Use original for nornal file access
- unsigned f_CopyToHome : 1; // Uploaded file needs to be copyed to home
- unsigned f_PseudoName : 1; // The filename is not the physical DOS name
- unsigned f_IsVirtual: 1; // Virtual node
- unsigned f_IsRefreshed : 1; // Used to flag files that are found during rescan
- unsigned f_BufIsSMEM : 1; // Buf SMEM, must be freed at destruction
- unsigned f_LinkNotResolved : 1; // Link must be resolved
- // Linking
- SMEM Next;
- SMEM Prev;
- SMEM Father;
- LPCSTR Name; // File name as wee see it
- // If NULL, act as if the dir we link to was this
- LPCSTR Comment;
- LPCSTR RealName; // Real file name (for .lnk and other extensions)
- LPCSTR LinkTo; // This is a link to --> ..
- SMEM Buf; // Buffer for packed data
- };
- typedef struct FILE_NODE * LPFILE_NODE;
- typedef const LPFILE_NODE LPCFILE_NODE;
- struct DIR_NODE
- {
- FILE_NODE FileNode;
- enum // Umask
- {
- DEF_PERM_FILE,
- DEF_PERM_DIR,
- };
- DWORD m_DefaultPerms[FSYS_DIR_MAX_UMASK];
- SMEM m_FileSystem;
- CWarTimer Timer; // Timeout until rescan
- SMEM Son;
- DWORD SpecialNewFilePerm; // If set, use these permissions on new files
- unsigned f_Dirty : 1; // security information needs to be flushed
- unsigned f_DoScan: 1; // Full scanning is not performed
- char Buf[sizeof(int)];
- };
- class DLL_VFSYS_ CFileList : public CLinkedList
- {
- public:
- ~CFileList();
- void Add(FILE_NODE *pNode){AddFirst((LPVOID)pNode);}
- BOOL ListRaw(CString& cReturnBuf, DWORD Flags = 0);
- };
- class DLL_VFSYS_ CPseudoFileInfo
- {
- public:
- const FILE_NODE *pNode;
- CString m_Name;
- LPCSTR FileName() const
- {
- if (m_Name.IsEmpty())
- return pNode->Name;
- else
- return m_Name;
- }
- CString MakeFileNameASCII()
- {
- LPCSTR p = pNode->Name;
- m_Name.Empty();
- while(p)
- m_Name += *p++;
- return m_Name;
- }
- BOOL Hide(int State)
- {
- //ASSERT(FALSE);
- return FALSE;
- }
- FLEN GetFileLength() {return pNode->Size;}
- FLEN GetFileBlocks() {return GetFileLength() / (FLEN)512;}
- int GetInode() {return (int)pNode;};
- int GetLinks() {return 1;}
- const LPFILETIME GetModifyTime() const {return (const LPFILETIME)&pNode->LastWriteDate;}
- const LPFILETIME GetAccessTime() const {return (const LPFILETIME)&pNode->LastWriteDate;;}
- const LPFILETIME GetCreationTime() const {return (const LPFILETIME)&pNode->CreationTime;}
- const LPFILETIME GetLastModeTime() const {return (const LPFILETIME)&pNode->LastWriteDate;;}
- BOOL IsDirectory() {return (pNode->Perms & NODE_DIR);}
- BOOL IsLink() {return (pNode->Perms & NODE_LINK);}
- BOOL IsReadOnly() {return (pNode->Perms & NODE_READONLY);}
- int GetFileNameLen() {return strlen(FileName());}
- LPCSTR GetComment() {return pNode->Comment ? pNode->Comment : "";}
- DWORD GetDLC() {return pNode->DlCount;}
- LPCSTR GetUserName(CString& cBuf) const
- {
- if (!pNode->User || !CUsr::FindUser(pNode->User,cBuf))
- return "root";
- return (LPCSTR)cBuf;
- }
- LPCSTR GetGroupName(CString& cBuf) const
- {
- if (!pNode->Class || !CUsr::FindUser(pNode->Class,cBuf))
- return "root";
- return (LPCSTR)cBuf;
- return "root";
- }
- void operator =(struct FILE_NODE * pn)
- {
- m_Name.Empty();
- pNode = pn;
- //return *this;
- }
- operator DWORD () {return pNode->Perms;}
- operator LPCFILE_NODE() {return (LPCFILE_NODE)pNode;}
- };
- enum // shmem user pointers
- {
- USERPTR_ROOTNODE = 0, // VfSys master node
- USERPTR_DEVDRV, // Global device driver table
- USERPTR_FSYS, // File system list
- USERPTR_PLUGINS, // Plugins global table
- };
- // Shared memory list of device drivers
- // Each process must create a table of drivers
- // where the index of the drivers are the same
- // as the shared memory table.
- struct GLOBAL_FSYS_DRIVERS_HDR
- {
- char Name[DRIVER_TABLE_SIZE][DRIVER_NAME_LEN];
- };
- class CDeviceDriver : public CFileSystemTemplate
- {
- public:
- };
- struct LOCAL_FSYS_DRIVERS_HDR
- {
- CDeviceDriver *pDevDr;
- HINSTANCE hDll;
- };
- // Shared memory list of fsys plugins
- // Each process must create a table of plugins
- // where the index of the drivers are the same
- // as the shared memory table.
- // These plugins are written for VfSys
- struct VFSYS_PLUGIN_HDR
- {
- char Name[32]; // Dll name
- char Pattern[64];
- DWORD dwFlags;
- };
- struct GLOBAL_VFSYS_PLUGIN_HDR
- {
- struct VFSYS_PLUGIN_HDR Plugin[PLUGIN_TABLE_SIZE];
- };
- struct LOCAL_VFSYS_PLUGIN_HDR
- {
- HINSTANCE hDll;
- DWORD (*OnFoundFile)(
- SMEM smDir, // Parent directory
- CFileInfo& Info, // File info from device
- SMEM smNode, // Node, 0 if new file
- CString& RealName, //File system name
- CString& VisualName, // The name the user will see
- CString& LinkTo, // Link to
- LPCSTR FsysPath, // File system path to parent dir
- FILE_SYSTEM *pFsys, // Current file system
- CDeviceDriver *pDev // Current device
- );
- };
- class DLL_VFSYS_ CPathArray : public CStringArray
- {
- public:
- void ParsePathToArray(LPCSTR Path);
- };
- ///////////////////////////////////////////////////////////
- // Prototypes
- DLL_VFSYS_ BOOL OpenFsys(HWND *phWnd, LPCSTR IniFilePath);
- DLL_VFSYS_ BOOL CreateMasterFsys(LPCSTR IniFilePath);
- DLL_VFSYS_ BOOL MountFsys(LPCSTR Path, LPCSTR Vpath, LPCSTR Driver, LPCSTR User, LPCSTR Pwd, int Copy, int Timeout, LPCSTR IniFilePath, LPCSTR Tag);
- DLL_VFSYS_ BOOL SyncDeviceDrivers();
- DLL_VFSYS_ int MountDeviceDriver(LPCSTR Driver);
- DLL_VFSYS_ int FindDeviceDriver(LPCSTR Name);
- DLL_VFSYS_ BOOL CreateRootNode(SMEM smFsys);
- DLL_VFSYS_ BOOL CreateDirNode(SMEM& smDirNode, LPCSTR Name, LPCSTR RealName, LPCSTR LinkTo, SMEM *psmFather, LPCSTR Comment);
- DLL_VFSYS_ BOOL CreateFileNode(SMEM& smNode, LPCSTR Name, LPCSTR RealName, LPCSTR LinkTo, SMEM *psmFather, LPCSTR Comment);
- DLL_VFSYS_ void SyncPlugins();
- DLL_VFSYS_ void InitializeFileNode(
- FILE_NODE *pNode,
- LPSTR Buf,
- LPCSTR Name,
- LPCSTR RealName,
- LPCSTR LinkTo,
- LPCSTR Comment);
- DLL_VFSYS_ BOOL AllocDirNode(
- SMEM& smNode,
- LPCSTR Name,
- LPCSTR RealName,
- LPCSTR LinkTo,
- SMEM *psmFather,
- LPCSTR Comment);
- DLL_VFSYS_ BOOL AllocFileNode(
- SMEM& smNode,
- LPCSTR Name,
- LPCSTR RealName,
- LPCSTR LinkTo,
- SMEM *psmFather,
- LPCSTR Comment);
- DLL_VFSYS_ DWORD GetDataBufLen(
- LPCSTR Name,
- LPCSTR RealName,
- LPCSTR Comment,
- LPCSTR LinkTo);
- DLL_VFSYS_ BOOL ChangeNodeInformation(
- FILE_NODE *pNode,
- LPCSTR Name,
- LPCSTR RealName,
- LPCSTR LinkTo,
- LPCSTR Comment);
- DLL_VFSYS_ BOOL ScanPath(LPCSTR Path, BOOL FullScanToPath, BOOL Recursive, BOOL Force);
- DLL_VFSYS_ BOOL ScanDir(SMEM smDir, LPCSTR Pattern, BOOL Force);
- DLL_VFSYS_ void ScanDown(SMEM smDir, BOOL Force);
- DLL_VFSYS_ SMEM FindNode(SMEM& smDir, LPCSTR Name);
- DLL_VFSYS_ CString ResolveFsysPath(SMEM smNode, SMEM& smFsys);
- DLL_VFSYS_ CString ResolveVfSysPathFromDosPath(LPCSTR DOSPath);
- DLL_VFSYS_ void MarkAllNodesAsNotRefreshed(SMEM smNode, LPCSTR Pattern);
- DLL_VFSYS_ void LinkToFather(SMEM smNode, SMEM smFather);
- DLL_VFSYS_ void DeleteNode(SMEM smNode);
- DLL_VFSYS_ void DeleteTree(SMEM smDir);
- DLL_VFSYS_ BOOL FindNodeFromPath(SMEM &smDir, CPathArray& PathArray);
- DLL_VFSYS_ BOOL FindNodeFromPath(SMEM& smDir, LPCSTR Path);
- DLL_VFSYS_ void CopyFileNode(FILE_NODE *pDstNode, FILE_NODE *pSrcNode);
- DLL_VFSYS_ void CopyDirNode(DIR_NODE *pDstNode, DIR_NODE *pSrcNode);
- DLL_VFSYS_ void FreeFsysNode(SMEM& smNode, BOOL KillExtraToo = TRUE);
- DLL_VFSYS_ void UnlinkNode(SMEM smNode);
- DLL_VFSYS_ BOOL ScanForBusyFiles(SMEM smDir);
- #include "VirtualFileSystem.h"
- #ifndef EXT
- #define EXT extern
- #endif
- // Global variables
- DLL_VFSYS_ EXT CVirtualFileSystem *pVfSys;
- DLL_VFSYS_ EXT CSharedBlksMem *pSmem;
- DLL_VFSYS_ EXT CRWLock *pLock;
- DLL_VFSYS_ EXT LOCAL_FSYS_DRIVERS_HDR LocalDeviceDrivers[DRIVER_TABLE_SIZE];
- DLL_VFSYS_ EXT LOCAL_VFSYS_PLUGIN_HDR LocalPluginTable[PLUGIN_TABLE_SIZE];
- DLL_VFSYS_ EXT GLOBAL_VFSYS_PLUGIN_HDR *pGlobalPluginHdr;
- // Plugin return codes
- #define LINK_PRESENT_NOT_RESOLVED 0x00000001