⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 networkfilesystem.h

📁 c++系统开发实例精粹内附的80例源代码 环境:windows2000,c++6.0
💻 H
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
//       http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////

// NetworkFileSystem.h: interface for the CNetworkFileSystem class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_NETWORKFILESYSTEM_H__3FCE24A0_5D69_11D3_B8DC_00600838CD5F__INCLUDED_)
#define AFX_NETWORKFILESYSTEM_H__3FCE24A0_5D69_11D3_B8DC_00600838CD5F__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "FileSystem.h"
#include "TimeoutSocket.h"

#define PORT_OSCARNFS                    3782
#define PORT_OSCARSEARCH                 3785
#define PORT_OSCARSEARCHRESULT           3788
#define PORT_OSCARTRANSFER               3791
#define PORT_OSCARIM                     3794
#define SOCKET_TIMEOUT                   5000        // Five seconds
#define SOCKET_RETRY_LIMIT               5           // Iterations
#define OSCARNFS_BUFFERSIZE              512

#define OPMASK_OPERATION                 0x00ff
#define OPMASK_TYPE                      0xff00
#define OPTYPE_BOOL_0P                   0x0100
#define OPTYPE_BOOL_1P                   0x0200
#define OPTYPE_BOOL_2P                   0x0300
#define OPTYPE_STR_0P                    0x0400
#define OPTYPE_STR_1P                    0x0500
#define OPTYPE_UINT_1P                   0x0600
#define OPTYPE_SPECIAL                   0x0700
#define REQUEST_NEWID                    0x0001
#define SUGGEST_SETID                    0x0002
#define SUGGEST_RELEASEIDENTIFIER        0x0003
#define REQUEST_ISRECYCLEBIN             0x0004
#define REQUEST_GETRECYCLEDIRECTORY      0x0005
#define REQUEST_ISHIDDEN                 0x0006
#define REQUEST_ISDIRECTORY              0x0007
#define REQUEST_ISDOTS                   0x0008
#define REQUEST_FINDNEXTFILE             0x0009
#define REQUEST_FINDFILE                 0x000a
#define REQUEST_EXECUTEFILE              0x000b
#define REQUEST_GETFILEPATH              0x000c
#define REQUEST_GETDRIVETYPE             0x000d
#define SUGGEST_MOVEFILE                 0x000e
#define REQUEST_RESOLVELINK              0x000f
#define REQUEST_GETFILESTATUS            0x0010
#define REQUEST_FILLFILEINFO             0x0011
#define REQUEST_GETLOGICALDRIVESTRINGS   0x0012
#define REQUEST_TRANSFERFILECACHE        0x0013
#define REQUEST_MACHINEINFO              0x0014

typedef struct
{
	time_t m_ctime;
	time_t m_mtime;
	time_t m_atime;
	LONG m_size;
	BYTE m_attribute;
	char m_szFullName[MAX_PATH];
} FileStatusTransferStruct;

typedef struct
{
	TCHAR tczCompName[155];
	TCHAR tczUserName[155];
	TCHAR tczSharedDirs[155];
} CompInfoTransferStruct;

typedef struct
{
	BOOL bIsHidden;
	BOOL bIsDirectory;
	FileStatusTransferStruct FileStatus;
	BOOL bFileStatusResult;
	SHFILEINFO FileInfo_SmallIcon;
	SHFILEINFO FileInfo_LargeIcon;
	SHFILEINFO FileInfo_OpenIcon;
	BOOL bIsDots;
	BOOL bHasSubDir;
	BOOL bFileInfoResult[3];
	TCHAR czFullPath[MAX_PATH];
} FileCacheEntry;

class CNetworkFileSystem : public CFileSystem  
{
public:
	virtual BOOL CopyFile(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists);
	virtual BOOL CreateDirectory(LPCTSTR czName);
	virtual BOOL DeleteFile(LPCTSTR lpFileName);
	virtual BOOL GetCompInfo(CStringArray &csaInfo);
	virtual int GetFSType();
	virtual BOOL HasSubDirectory(LPCTSTR strPath);
	CNetworkFileSystem(LPCTSTR czIP);
	virtual ~CNetworkFileSystem();

	// Virtuals, overrides
	virtual LPCTSTR GetComputerName();
	BOOL IsRecycleBin(LPCTSTR cszDir);
	virtual LPCTSTR GetRecycleDirectory();
	virtual DWORD GetLogicalDriveStrings(DWORD nBufferLength, LPTSTR lpBuffer);
	virtual UINT GetDriveType(LPCTSTR lpRootPathName);
	virtual HRESULT ResolveLink(HWND hwnd, LPCSTR lpszLinkFile, LPSTR lpszPath);
	virtual HRESULT CreateLink(LPCSTR lpszPathObj, LPSTR lpszPathLink, LPSTR lpszDesc);
	virtual BOOL MoveFile( LPCTSTR pszOldName, LPCTSTR pszNewName );
	virtual BOOL IsHidden( );
	virtual BOOL IsDirectory( );
	virtual BOOL GetFileStatus( LPCTSTR pszFileName, CFileStatus &rStatus );
	virtual BOOL FillFileInfo(LPCTSTR pszPath, SHFILEINFO *fiInfo, UINT uFlags);
	virtual CString GetFilePath( );
	virtual BOOL IsDots( );
	virtual BOOL FindNextFile( );
	virtual BOOL FindFile(LPCTSTR pstrName = NULL, DWORD dwUnused = 0 );
	virtual bool ExecuteFile(HWND hWnd, LPCTSTR strName);

protected:
	UINT m_nServerVersion;
	UINT m_uLastFileInfo;
	SHFILEINFO m_shLastFileInfo;
	CString m_czLastFileInfo;
	BOOL m_bLastFileInfo;
	int m_nLastCacheHit;
	FileCacheEntry *FindCacheEntry(LPCTSTR strName);
	BOOL IsCacheValid();
	int m_nCacheIndex;
	FileCacheEntry *m_pFileCache;
	UINT m_nNumCacheEntries;
	void RefreshFileCache(LPCTSTR strFiles);
	BOOL BoolNetOp(UINT nOp, LPCTSTR cszStrA, LPCTSTR cszStrB);
	UINT UintNetOp(UINT nOp, LPCTSTR cszStr);
	BOOL StringNetOp_Special(UINT nOp, LPTSTR lpStr);
	CString StringNetOp(UINT nOp, LPCTSTR czStr);
	CString StringNetOp(UINT nOp);
	BOOL BoolNetOp(UINT nOp, LPCTSTR cszStr);
	BOOL BoolNetOp(UINT nOp);
	void CloseConnection(CTimeoutSocket *sock);
	BOOL IdentifyInstance(CTimeoutSocket *sock);
	CTimeoutSocket * OpenConnection(LPCTSTR czIP, UINT nPort = PORT_OSCARNFS);
	void AppendFeedback(LPCTSTR czStatus);
	void AcquireNewInstance(UINT nVer, UINT &nServerVer);
	CString m_czRemoteIP;
	int m_nInstanceID;
	int m_nNumFiles;
};

#endif // !defined(AFX_NETWORKFILESYSTEM_H__3FCE24A0_5D69_11D3_B8DC_00600838CD5F__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -