Fixed spelling
This commit is contained in:
113
SiaDrive.Dokan.Api/SiaDokanDrive.cpp
Normal file
113
SiaDrive.Dokan.Api/SiaDokanDrive.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "stdafx.h"
|
||||
#include "SiaDokanDrive.h"
|
||||
#include <dokan\dokan.h>
|
||||
|
||||
using namespace Sia::Api;
|
||||
using namespace Sia::Api::Dokan;
|
||||
|
||||
class DokanImpl
|
||||
{
|
||||
private:
|
||||
static std::mutex _dokanMutex;
|
||||
static CSiaApi* _siaApi;
|
||||
static DOKAN_OPERATIONS _dokanOps;
|
||||
|
||||
private:
|
||||
static NTSTATUS DOKAN_CALLBACK SiaDrive_ZwCreateFile(
|
||||
LPCWSTR FileName,
|
||||
PDOKAN_IO_SECURITY_CONTEXT SecurityContext,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
ULONG FileAttributes,
|
||||
ULONG ShareAccess,
|
||||
ULONG CreateDisposition,
|
||||
ULONG CreateOptions,
|
||||
PDOKAN_FILE_INFO DokanFileInfo)
|
||||
{
|
||||
}
|
||||
|
||||
static NTSTATUS DOKAN_CALLBACK SiaDrive_FindFiles(
|
||||
LPCWSTR FileName,
|
||||
PFillFindData FillFindData,
|
||||
PDOKAN_FILE_INFO DokanFileInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
static void Initialize(CSiaApi* siaApi)
|
||||
{
|
||||
_siaApi = siaApi;
|
||||
_dokanOps.Cleanup = nullptr;
|
||||
_dokanOps.CloseFile = nullptr;
|
||||
_dokanOps.DeleteDirectory = nullptr;
|
||||
_dokanOps.DeleteFileW = nullptr;
|
||||
_dokanOps.FindFiles = SiaDrive_FindFiles;
|
||||
_dokanOps.FindFilesWithPattern = nullptr;
|
||||
_dokanOps.FindStreams = nullptr;
|
||||
_dokanOps.FlushFileBuffers = nullptr;
|
||||
_dokanOps.GetDiskFreeSpaceW = nullptr;
|
||||
_dokanOps.GetFileInformation = nullptr;
|
||||
_dokanOps.GetFileSecurityW = nullptr;
|
||||
_dokanOps.GetVolumeInformationW = nullptr;
|
||||
_dokanOps.LockFile = nullptr;
|
||||
_dokanOps.Mounted = nullptr;
|
||||
_dokanOps.MoveFileW = nullptr;
|
||||
_dokanOps.ReadFile = nullptr;
|
||||
_dokanOps.SetAllocationSize = nullptr;
|
||||
_dokanOps.SetEndOfFile = nullptr;
|
||||
_dokanOps.SetFileAttributesW = nullptr;
|
||||
_dokanOps.SetFileSecurityW = nullptr;
|
||||
_dokanOps.SetFileTime = nullptr;
|
||||
_dokanOps.UnlockFile = nullptr;
|
||||
_dokanOps.Unmounted = nullptr;
|
||||
_dokanOps.WriteFile = nullptr;
|
||||
_dokanOps.ZwCreateFile = SiaDrive_ZwCreateFile;
|
||||
}
|
||||
|
||||
static void Shutdown()
|
||||
{
|
||||
_siaApi = nullptr;
|
||||
ZeroMemory(&_dokanOps, sizeof(_dokanOps));
|
||||
}
|
||||
|
||||
static std::mutex& GetMutex()
|
||||
{
|
||||
return _dokanMutex;
|
||||
}
|
||||
|
||||
static bool IsInitialized()
|
||||
{
|
||||
return _siaApi != nullptr;
|
||||
}
|
||||
};
|
||||
std::mutex DokanImpl::_dokanMutex;
|
||||
CSiaApi* DokanImpl::_siaApi = nullptr;
|
||||
DOKAN_OPERATIONS DokanImpl::_dokanOps = { 0 };
|
||||
|
||||
CSiaDokanDrive::CSiaDokanDrive(CSiaApi& siaApi) :
|
||||
_siaApi(siaApi)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
if (DokanImpl::IsInitialized())
|
||||
{
|
||||
throw SiaDokanDriveException("Sia drive has already been activated");
|
||||
}
|
||||
else
|
||||
{
|
||||
DokanImpl::Initialize(&_siaApi);
|
||||
}
|
||||
}
|
||||
|
||||
CSiaDokanDrive::~CSiaDokanDrive()
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
Unmount();
|
||||
DokanImpl::Shutdown();
|
||||
}
|
||||
|
||||
void CSiaDokanDrive::Mount(const wchar_t& driveLetter)
|
||||
{
|
||||
}
|
||||
|
||||
void CSiaDokanDrive::Unmount()
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user