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

📄 smplfsys.cpp

📁 著名的 helix realplayer 基于手机 symbian 系统的 播放器全套源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ***** BEGIN LICENSE BLOCK *****
 * Version: RCSL 1.0/RPSL 1.0
 *
 * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
 *
 * The contents of this file, and the files included with this file, are
 * subject to the current version of the RealNetworks Public Source License
 * Version 1.0 (the "RPSL") available at
 * http://www.helixcommunity.org/content/rpsl unless you have licensed
 * the file under the RealNetworks Community Source License Version 1.0
 * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
 * in which case the RCSL will apply. You may also obtain the license terms
 * directly from RealNetworks.  You may not use this file except in
 * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
 * applicable to this file, the RCSL.  Please see the applicable RPSL or
 * RCSL for the rights, obligations and limitations governing use of the
 * contents of the file.
 *
 * This file is part of the Helix DNA Technology. RealNetworks is the
 * developer of the Original Code and owns the copyrights in the portions
 * it created.
 *
 * This file, and the files included with this file, is distributed and made
 * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 *
 * Technology Compatibility Kit Test Suite(s) Location:
 *    http://www.helixcommunity.org/content/tck
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** */

/////////////////////////////////////////////////////////////////////////////
//
//  Simple File System for simple synchronous local files
//
//  This is a very simple file system, it just calls basic standard lib
//  calls for open, seek, read, etc...
//

#define INITGUID    1

#include "hxcom.h"
#include "hxtypes.h"
#include "../smplfsys.ver"

#include "hxcomm.h"
#include "ihxpckts.h"
#include "hxfiles.h"
#include "hxplugn.h"
#include "hxengin.h"
#include "hxcore.h"
#include "hxprefs.h"
#include "hxrendr.h"
#include "hxmon.h"
#include "hxauth.h"
#include "hxauthn.h"
#include "hxplgns.h"
#include "hxdataf.h"
#include "hxtick.h"

#include "debug.h"

#undef INITGUID

#include "hxathsp.h"
#include "hxcorsp.h"
#include "hxpktsp.h"
#include "hxcomsp.h"
#include "hxplnsp.h"
#include "hxspriv.h"
#include "hlxosstr.h"

#include "timeval.h"
#include "tparse.h"
#include "dbcs.h"	// for HXCompareStrings
#include "hxstring.h"	// for CHXString
#include "hxxfile.h"	// for HXXFile::GetReasonableLocalFileName()
#include "hxstrutl.h"
#include "hxver.h"
#include "chxpckts.h"
#include "hxurl.h"
#include "hxperf.h"
#include "hxcbobj.h"

#include "hxdir.h"

#include <stdio.h>
#include <string.h>

#ifdef _MACINTOSH
#include <fcntl.h>
#include "chxdataf.h"	// Macintosh file i/o
#include "macasyncfile.h"  // Macintosh interrupt file i/o
#ifdef _MAC_MACHO
#include <sys/stat.h>
#include "hlxclib/fcntl.h"
#include <unistd.h> // for unlink
#else
#include <unix.h> // for unlink
#endif
#ifdef _UNIX /* including unix.h defines _UNIX */
#undef _UNIX
#endif
#elif (defined (_WINDOWS ) || defined (_WIN32)) && !defined(WIN32_PLATFORM_PSPC)
#include <direct.h>
#include "datffact.h"
#else
#include "hlxclib/sys/types.h"
#include "hlxclib/sys/stat.h"
#include "hlxclib/fcntl.h"
#include "datffact.h"
#endif
#include "findfile.h"
#include "smplmlog.h"
#include "baseobj.h"
#if defined(HELIX_FEATURE_PROGDOWN)
#include "progdown.h"
#include "microsleep.h"
#endif
#include "smplfsys.h"
#include "hxperf.h"

#ifdef _AIX
#include "hxtbuf.h"
#include "dllpath.h"
ENABLE_MULTILOAD_DLLACCESS_PATHS(Smplfsys);
#endif

// same for all the platforms...may need to tweak it, if necessary
#define MAX_ITERATION_COUNT    200

#include "hxheap.h"
#ifdef _DEBUG
#undef HX_THIS_FILE
static const char HX_THIS_FILE[] = __FILE__;
#endif

#ifndef HELIX_CONFIG_NOSTATICS
INT32 smpl_nRefCount = 0;
#endif	// HELIX_CONFIG_NOSTATICS

HX_ENABLE_CHECKPOINTS_FOR_MODULE( "SmplFsys", "SmplFsysPerf.log" )

const char* const CSimpleFileSystem::zm_pDescription	= "RealNetworks Local File System";
const char* const CSimpleFileSystem::zm_pCopyright	= HXVER_COPYRIGHT;
const char* const CSimpleFileSystem::zm_pMoreInfoURL	= HXVER_MOREINFO;
const char* const CSimpleFileSystem::zm_pShortName	= "pn-local";
const char* const CSimpleFileSystem::zm_pProtocol	= "file";

/****************************************************************************
 *
 *  Function:
 *
 *	HXCreateInstance()
 *
 *  Purpose:
 *
 *	Function implemented by all plugin DLL's to create an instance of
 *	any of the objects supported by the DLL. This method is similar to
 *	Window's CoCreateInstance() in its purpose, except that it only
 *	creates objects from this plugin DLL.
 *
 *	NOTE: Aggregation is never used. Therefore and outer unknown is
 *	not passed to this function, and you do not need to code for this
 *	situation.
 *
 */
STDAPI ENTRYPOINT(HXCREATEINSTANCE)
(
    IUnknown**  /*OUT*/	ppIUnknown
)
{
    // Do NOT check for expiration.  Needed for Auto Upgrade.

    *ppIUnknown = (IUnknown*)(IHXPlugin*)new CSimpleFileSystem();
    if (*ppIUnknown)
    {
	(*ppIUnknown)->AddRef();
	return HXR_OK;
    }
    return HXR_OUTOFMEMORY;
}

/****************************************************************************
 *
 *  Function:
 *
 *	CanUnload()
 *
 *  Purpose:
 *
 *	Function implemented by all plugin DLL's if it returns HXR_OK
 *	then the pluginhandler can unload the DLL
 *
 */
STDAPI ENTRYPOINT(CanUnload)(void)
{
#ifdef HELIX_CONFIG_NOSTATICS
    return HXR_FAIL;
#else	// HELIX_CONFIG_NOSTATICS
    return (smpl_nRefCount ? HXR_FAIL : HXR_OK);
#endif	// HELIX_CONFIG_NOSTATICS
}


/****************************************************************************
 *
 *  Function:
 *
 *	HXShutdown()
 *
 *  Purpose:
 *
 *	Function implemented by all plugin DLL's to free any *global*
 *	resources. This method is called just before the DLL is unloaded.
 *
 */
STDAPI ENTRYPOINT(HXSHUTDOWN)(void)
{
    return HXR_OK;
}

CSimpleFileSystem::CSimpleFileSystem()
    : m_lRefCount(0)
    , m_pContext(0)
    , m_options(NULL)
    , m_ulMaxIterationLevel(MAX_ITERATION_COUNT)
    , m_pCommonObj(NULL)
    , m_bDisableMemoryMappedIO(FALSE)
    , m_bEnableFileLocking(FALSE)
    , m_ulChunkSize(0)
{
#ifndef HELIX_CONFIG_NOSTATICS
    smpl_nRefCount++;
#endif	// HELIX_CONFIG_NOSTATICS
}

CSimpleFileSystem::~CSimpleFileSystem()
{
#ifndef HELIX_CONFIG_NOSTATICS
    smpl_nRefCount--;
#endif	// HELIX_CONFIG_NOSTATICS

    if (m_pContext)
    {
	m_pContext->Release();
	m_pContext = 0;
    }

    if(m_options)
    {
	m_options->Release();
	m_options = 0;
    }

    HX_RELEASE(m_pCommonObj);
}

/************************************************************************
 *  Method:
 *    IHXPlugin::InitPlugin
 *  Purpose:
 *    Initializes the plugin for use. This interface must always be
 *    called before any other method is called. This is primarily needed
 *    so that the plugin can have access to the context for creation of
 *    IHXBuffers and IMalloc.
 */
STDMETHODIMP CSimpleFileSystem::InitPlugin(IUnknown* /*IN*/ pContext)
{
    HX_LOG_BLOCK( "CSimpleFileSystem::InitPlugin" );

    HX_RESULT		lResult;
    IHXPreferences*	prefs = 0;
    IHXBuffer*		base_path_buf = 0;

    if (pContext && !m_pContext)
    {
        m_pContext = pContext;
	m_pContext->AddRef();

	IHXRegistry* pReg = NULL;
	if (m_pContext->QueryInterface(IID_IHXRegistry, (void**)&pReg) == HXR_OK)
	{
	    INT32 lCS = 0;
	    if (HXR_OK == pReg->GetIntByName("config.MMapChunkSize", lCS) && lCS)
	    {
		m_ulChunkSize = lCS;
	    }
	    pReg->Release();
	}

	if(!m_options ||
	   (HXR_OK != m_options->GetPropertyBuffer("BasePath", base_path_buf)))
	{
	    lResult = pContext->QueryInterface(IID_IHXPreferences,
					       (void**) &prefs);
	    if (lResult == HXR_OK)
	    {
		lResult = prefs->ReadPref("BasePath", base_path_buf);
		if (lResult == HXR_OK)
		{
		    m_base_path = CHXString((char*)base_path_buf->GetBuffer());
		}
	    }
	}
	else
	{
	    m_base_path = CHXString((char*)base_path_buf->GetBuffer());
	}
    }

    if (prefs)
    {
	prefs->Release();
	prefs = 0;
    }

    if (base_path_buf)
    {
	base_path_buf->Release();
	base_path_buf = 0;
    }

    IHXGetRecursionLevel* pGet;
    lResult = pContext->QueryInterface(IID_IHXGetRecursionLevel,
				       (void**) &pGet);
    if (lResult == HXR_OK)
    {
	m_ulMaxIterationLevel = pGet->GetRecursionLevel();
	pGet->Release();
    }

    return HXR_OK;
}

/************************************************************************
 *  Method:
 *    IHXPlugin::GetPluginInfo
 *  Purpose:
 *    Returns the basic information about this plugin. Including:
 *
 *    unInterfaceCount	the number of standard RMA interfaces
 *			supported by this plugin DLL.
 *    pIIDList		array of IID's for standard RMA interfaces
 *			supported by this plugin DLL.
 *    bLoadMultiple	whether or not this plugin DLL can be loaded
 *			multiple times. All File Formats must set
 *			this value to TRUE.
 *    pDescription	which is used in about UIs (can be NULL)
 *    pCopyright	which is used in about UIs (can be NULL)
 *    pMoreInfoURL	which is used in about UIs (can be NULL)
 */
STDMETHODIMP CSimpleFileSystem::GetPluginInfo
(
    REF(BOOL)        /*OUT*/ bLoadMultiple,
    REF(const char*) /*OUT*/ pDescription,
    REF(const char*) /*OUT*/ pCopyright,
    REF(const char*) /*OUT*/ pMoreInfoURL,
    REF(ULONG32)     /*OUT*/ ulVersionNumber
)
{
    bLoadMultiple = TRUE;

    pDescription    = zm_pDescription;
    pCopyright	    = zm_pCopyright;
    pMoreInfoURL    = zm_pMoreInfoURL;
    ulVersionNumber = TARVER_ULONG32_VERSION;

    return HXR_OK;
}


// *** IUnknown methods ***

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::QueryInterface
//  Purpose:
//	Implement this to export the interfaces supported by your
//	object.
//
STDMETHODIMP CSimpleFileSystem::QueryInterface(REFIID riid, void** ppvObj)
{
    QInterfaceList qiList[] =
    {
	{ GET_IIDHANDLE(IID_IUnknown), this },
	{ GET_IIDHANDLE(IID_IHXPlugin), (IHXPlugin*) this },
	{ GET_IIDHANDLE(IID_IHXFileSystemObject), (IHXFileSystemObject*) this },
    };
    return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
}

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::AddRef
//  Purpose:
//	Everyone usually implements this the same... feel free to use
//	this implementation.
//
STDMETHODIMP_(ULONG32) CSimpleFileSystem::AddRef()
{
    return InterlockedIncrement(&m_lRefCount);
}

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::Release
//  Purpose:
//	Everyone usually implements this the same... feel free to use
//	this implementation.
//
STDMETHODIMP_(ULONG32) CSimpleFileSystem::Release()
{
    if (InterlockedDecrement(&m_lRefCount) > 0)
    {
        return m_lRefCount;
    }

    delete this;
    return 0;
}

STDMETHODIMP CSimpleFileSystem::GetFileSystemInfo
(
    REF(const char*) /*OUT*/ pShortName,
    REF(const char*) /*OUT*/ pProtocol
)
{
    pShortName	= zm_pShortName;
    pProtocol	= zm_pProtocol;

    return HXR_OK;
}

STDMETHODIMP
CSimpleFileSystem::InitFileSystem(IHXValues* options)
{
    HX_LOG_BLOCK( "CSimpleFileSystem::InitFileSystem" );

    IHXBuffer*		base_path_buf = 0;

    m_options = options;

    if (m_options)
    {
	m_options->AddRef();

	if (HXR_OK == m_options->GetPropertyBuffer("BasePath", base_path_buf))
	{
	    m_base_path = CHXString((char*)base_path_buf->GetBuffer());
	}

	ULONG32 ulTemp = 0;

⌨️ 快捷键说明

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