Skip to content

Instantly share code, notes, and snippets.

@Appendme Appendme/FileSystem.cpp Secret
Last active May 2, 2019

Embed
What would you like to do?
HRESULT FileSystem::QueryInterface(const IID& riid, LPVOID* ppvObj)
{
if (!ppvObj) return E_POINTER;
if (riid == IID_IAIMPExtensionFileSystem)
{
*ppvObj = static_cast<IAIMPExtensionFileSystem*>(this);
AddRef();
return S_OK;
}
if (riid == IID_IAIMPFileSystemCommandCopyToClipboard)
{
*ppvObj = static_cast<IAIMPFileSystemCommandCopyToClipboard*>(this);
AddRef();
return S_OK;
}
if (riid == IID_IAIMPFileSystemCommandDelete)
{
*ppvObj = static_cast<IAIMPFileSystemCommandDelete*>(this);
AddRef();
return S_OK;
}
if (riid == IID_IAIMPFileSystemCommandDropSource)
{
*ppvObj = static_cast<IAIMPFileSystemCommandDropSource*>(this);
AddRef();
return S_OK;
}
if (riid == IID_IAIMPFileSystemCommandFileInfo)
{
*ppvObj = static_cast<IAIMPFileSystemCommandFileInfo*>(this);
AddRef();
return S_OK;
}
if (riid == IID_IAIMPFileSystemCommandOpenFileFolder)
{
*ppvObj = static_cast<IAIMPFileSystemCommandOpenFileFolder*>(this);
AddRef();
return S_OK;
}
if (riid == IID_IAIMPFileSystemCommandStreaming)
{
*ppvObj = static_cast<IAIMPFileSystemCommandStreaming*>(this);
AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
ULONG FileSystem::AddRef()
{
return Base::AddRef();
}
ULONG FileSystem::Release()
{
return Base::Release();
}
void FileSystem::BeginUpdate()
{
}
void FileSystem::EndUpdate()
{
}
HRESULT FileSystem::Reset()
{
return E_NOTIMPL;
}
HRESULT FileSystem::GetValueAsFloat(int propertyId, double* value)
{
return E_NOTIMPL;
}
HRESULT FileSystem::GetValueAsInt32(int propertyId, int* value)
{
if (propertyId == AIMP_FILESYSTEM_PROPID_READONLY)
{
*value = 0;
return S_OK;
}
return E_INVALIDARG;
}
HRESULT FileSystem::GetValueAsInt64(int propertyId, INT64* value)
{
return E_NOTIMPL;
}
HRESULT FileSystem::GetValueAsObject(
int propertyId, const IID& iid, void** value)
{
if (propertyId == AIMP_FILESYSTEM_PROPID_SCHEME)
{
return String(L"vkmusic")->QueryInterface(iid, value);
}
return E_INVALIDARG;
}
HRESULT FileSystem::SetValueAsFloat(int propertyId, const double value)
{
return E_NOTIMPL;
}
HRESULT FileSystem::SetValueAsInt32(int propertyId, int value)
{
return E_NOTIMPL;
}
HRESULT FileSystem::SetValueAsInt64(int propertyId, const INT64 value)
{
return E_NOTIMPL;
}
HRESULT FileSystem::SetValueAsObject(int propertyId, IUnknown* value)
{
return E_NOTIMPL;
}
HRESULT FileSystem::CanProcess(IAIMPString* fileName)
{
return E_NOTIMPL;
}
HRESULT FileSystem::Process(IAIMPString* fileName)
{
return E_NOTIMPL;
}
HRESULT FileSystem::CopyToClipboard(IAIMPObjectList* files)
{
return E_NOTIMPL;
}
HRESULT FileSystem::CreateStream(
IAIMPString* fileName, IAIMPStream** stream)
{
return E_NOTIMPL;
}
HRESULT FileSystem::GetFileAttrs(
IAIMPString* fileName, TAIMPFileAttributes* attrs)
{
return E_NOTIMPL;
}
HRESULT FileSystem::GetFileSize(IAIMPString* fileName, INT64* size)
{
return E_NOTIMPL;
}
HRESULT FileSystem::IsFileExists(IAIMPString* fileName)
{
return E_NOTIMPL;
}
HRESULT FileSystem::CreateStream(
IAIMPString* fileName,
const INT64 offset,
const INT64 size,
DWORD flags,
IAIMPStream** stream)
{
return E_NOTIMPL;
}
class FileSystem final
: public IUnknownII<IAIMPExtensionFileSystem>
, public IAIMPFileSystemCommandCopyToClipboard
, public IAIMPFileSystemCommandDelete
, public IAIMPFileSystemCommandDropSource
, public IAIMPFileSystemCommandFileInfo
, public IAIMPFileSystemCommandOpenFileFolder
, public IAIMPFileSystemCommandStreaming
{
public:
using Base = IUnknownII<IAIMPExtensionFileSystem>;
FileSystem() = default;
HRESULT WINAPI QueryInterface(
const IID& riid, LPVOID* ppvObj) override;
ULONG WINAPI AddRef() override;
ULONG WINAPI Release() override;
void WINAPI BeginUpdate() override;
void WINAPI EndUpdate() override;
HRESULT WINAPI Reset() override;
HRESULT WINAPI GetValueAsFloat(
int propertyId, double* value) override;
HRESULT WINAPI GetValueAsInt32(
int propertyId, int* value) override;
HRESULT WINAPI GetValueAsInt64(
int propertyId, INT64* value) override;
HRESULT WINAPI GetValueAsObject(
int propertyId, const IID& iid, void** value) override;
HRESULT WINAPI SetValueAsFloat(
int propertyId, const double value) override;
HRESULT WINAPI SetValueAsInt32(
int propertyId, int value) override;
HRESULT WINAPI SetValueAsInt64(
int propertyId, const INT64 value) override;
HRESULT WINAPI SetValueAsObject(
int propertyId, IUnknown* value) override;
HRESULT WINAPI CanProcess(
IAIMPString* fileName) override;
HRESULT WINAPI Process(
IAIMPString* fileName) override;
HRESULT WINAPI CopyToClipboard(
IAIMPObjectList* Files) override;
HRESULT WINAPI CreateStream(
IAIMPString* fileName, IAIMPStream** stream) override;
HRESULT WINAPI GetFileAttrs(
IAIMPString* fileName, TAIMPFileAttributes* attrs) override;
HRESULT WINAPI GetFileSize(
IAIMPString* fileName, INT64* size) override;
HRESULT WINAPI IsFileExists(
IAIMPString* fileName) override;
HRESULT WINAPI CreateStream(
IAIMPString* fileName,
const INT64 offset,
const INT64 size,
DWORD flags,
IAIMPStream** stream) override;
};
if (FAILED(core->RegisterExtension(
IID_IAIMPServiceFileSystems,
static_cast<FileSystem::Base*>(new FileSystem))))
return Fail();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.