Win95Links.cpp
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:4k
源码类别:
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 : Win95Links.cpp
- // PURPOSE : War Daemon Virtual File System special plugin
- // PROGRAM :
- // DATE : April 8 1997
- // AUTHOR : Jarle Aase
- // ---
- //
- // Exports are done in the .def file.
- //
- // REVISION HISTORY
- //
- #include "stdafx.h"
- #include <afxdllx.h>
- #include "WarDaemon.h"
- #include "WarFsys.h"
- #include "VfFSys.h"
- #include "UnixFsysTypes.h"
- #include "FsysSecurity.h"
- BOOL AFXAPI AfxResolveShortcut(CWnd* pWnd, LPCTSTR pszShortcutFile,
- LPTSTR pszPath, int cchPath);
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- static AFX_EXTENSION_MODULE Win95LinksDLL = { NULL, NULL };
- extern "C" int APIENTRY
- DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
- {
- // Remove this if you use lpReserved
- UNREFERENCED_PARAMETER(lpReserved);
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- TRACE0("WIN95LINKS.DLL Initializing!n");
- // Extension DLL one-time initialization
- if (!AfxInitExtensionModule(Win95LinksDLL, hInstance))
- return 0;
- // Insert this DLL into the resource chain
- // NOTE: If this Extension DLL is being implicitly linked to by
- // an MFC Regular DLL (such as an ActiveX Control)
- // instead of an MFC application, then you will want to
- // remove this line from DllMain and put it in a separate
- // function exported from this Extension DLL. The Regular DLL
- // that uses this Extension DLL should then explicitly call that
- // function to initialize this Extension DLL. Otherwise,
- // the CDynLinkLibrary object will not be attached to the
- // Regular DLL's resource chain, and serious problems will
- // result.
- new CDynLinkLibrary(Win95LinksDLL);
- }
- else if (dwReason == DLL_PROCESS_DETACH)
- {
- TRACE0("WIN95LINKS.DLL Terminating!n");
- // Terminate the library before destructors are called
- AfxTermExtensionModule(Win95LinksDLL);
- }
- return 1; // ok
- }
- // Called from ScanDir() each time a file that math the plugin's 'pattern'
- // is detected.
- // This function is required and must be exported in the .def file
- 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 currently being scanned
- FILE_SYSTEM *pFsys, // Current file system
- CDeviceDriver *pDev // Current device
- )
- {
- CString cBuf = RealName;
- LPSTR p = cBuf.GetBuffer(1);
- // Check if this is a .lnk file
- if (p = strrchr(p,'.'))
- {
- if (!stricmp(p,".lnk"))
- {
- *p = 0;
- cBuf.ReleaseBuffer();
- VisualName = cBuf;
- SMEM smFsys;
- CString FsysPath = ResolveFsysPath(smDir, smFsys);
- FsysPath += '/';
- FsysPath += RealName;
- // Convert FsysPath to a DOS path
- p = FsysPath.GetBuffer(1);
- while(*p)
- {
- if (*p == '/')
- *p = '\';
- ++p;
- }
- FsysPath.ReleaseBuffer();
- // Get the Win95 shortcut
- if (AfxResolveShortcut(NULL, FsysPath, cBuf.GetBuffer(MAX_PATH), MAX_PATH))
- {
- // At this time we don't know if the file system containing the shortcut
- // actually exist. We therefore need to store it with it's original name
- // and leave to VfSys to resolve it on demand.
- cBuf.ReleaseBuffer();
- LinkTo = cBuf;
- // Check if the destination is a directory
- // Use native IO calls, we don't know what driver to use...
- DWORD Flags = GetFileAttributes(LinkTo);
- if ((Flags != 0xFFFFFFFF) && (Flags & FILE_ATTRIBUTE_DIRECTORY))
- Info.m_Flags |= NODE_DIR;
- Info.m_Flags |= NODE_LINK;
- return LINK_PRESENT_NOT_RESOLVED;
- }
- }
- }
- return 0; // Neutral
- }