Mounting changes
This commit is contained in:
@@ -317,7 +317,25 @@ private:
|
||||
}
|
||||
else // Folder Operation (cache operation only)
|
||||
{
|
||||
ret = STATUS_NOT_IMPLEMENTED;
|
||||
String cacheFilePath;
|
||||
cacheFilePath.resize(MAX_PATH + 1);
|
||||
if (String(L"\\") == FileName)
|
||||
{
|
||||
cacheFilePath = GetCacheLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
PathCombine(&cacheFilePath[0], GetCacheLocation().c_str(), FileName);
|
||||
}
|
||||
HANDLE handle = ::CreateFile(cacheFilePath.c_str(), genericDesiredAccess, ShareAccess, &securityAttrib, creationDisposition, fileAttributesAndFlags | FILE_FLAG_BACKUP_SEMANTICS, nullptr);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ret = DokanNtStatusFromWin32(GetLastError());
|
||||
}
|
||||
else
|
||||
{
|
||||
DokanFileInfo->Context = reinterpret_cast<ULONG64>(handle); // save the file handle in Context
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,6 +410,28 @@ private:
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS DOKAN_CALLBACK Sia_GetVolumeInformation(
|
||||
LPWSTR VolumeNameBuffer, DWORD VolumeNameSize, LPDWORD VolumeSerialNumber,
|
||||
LPDWORD MaximumComponentLength, LPDWORD FileSystemFlags,
|
||||
LPWSTR FileSystemNameBuffer, DWORD FileSystemNameSize,
|
||||
PDOKAN_FILE_INFO DokanFileInfo) {
|
||||
UNREFERENCED_PARAMETER(DokanFileInfo);
|
||||
|
||||
wcscpy_s(VolumeNameBuffer, VolumeNameSize, L"SIA");
|
||||
*VolumeSerialNumber = 0x19831116;
|
||||
*MaximumComponentLength = 256;
|
||||
*FileSystemFlags = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES |
|
||||
FILE_SUPPORTS_REMOTE_STORAGE | FILE_UNICODE_ON_DISK |
|
||||
FILE_PERSISTENT_ACLS;
|
||||
|
||||
// File system name could be anything up to 10 characters.
|
||||
// But Windows check few feature availability based on file system name.
|
||||
// For this, it is recommended to set NTFS or FAT here.
|
||||
wcscpy_s(FileSystemNameBuffer, FileSystemNameSize, L"FAT");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
public:
|
||||
static void Initialize(CSiaApi* siaApi, CSiaDriveConfig* siaDriveConfig)
|
||||
{
|
||||
@@ -410,7 +450,7 @@ public:
|
||||
_dokanOps.GetDiskFreeSpaceW = nullptr;
|
||||
_dokanOps.GetFileInformation = nullptr;
|
||||
_dokanOps.GetFileSecurityW = nullptr;
|
||||
_dokanOps.GetVolumeInformationW = nullptr;
|
||||
_dokanOps.GetVolumeInformationW = Sia_GetVolumeInformation;
|
||||
_dokanOps.LockFile = nullptr;
|
||||
_dokanOps.Mounted = Sia_Mounted;
|
||||
_dokanOps.MoveFileW = nullptr;
|
||||
@@ -428,7 +468,7 @@ public:
|
||||
ZeroMemory(&_dokanOptions, sizeof(DOKAN_OPTIONS));
|
||||
_dokanOptions.Version = DOKAN_VERSION;
|
||||
_dokanOptions.ThreadCount = 0; // use default
|
||||
_dokanOptions.Options |= DOKAN_OPTION_CURRENT_SESSION;
|
||||
_dokanOptions.Options = DOKAN_OPTION_DEBUG;
|
||||
}
|
||||
|
||||
static void Mount(const wchar_t& driveLetter, const String& cacheLocation)
|
||||
@@ -436,7 +476,7 @@ public:
|
||||
if (_siaApi && !_mountThread)
|
||||
{
|
||||
_cacheLocation = cacheLocation;
|
||||
wchar_t tmp[] = { driveLetter, ':', 0 };
|
||||
wchar_t tmp[] = { driveLetter, ':', '\\', 0 };
|
||||
_mountPoint = tmp;
|
||||
_mountThread.reset(new std::thread([&]()
|
||||
{
|
||||
@@ -452,6 +492,7 @@ public:
|
||||
if (_mountThread)
|
||||
{
|
||||
DokanRemoveMountPoint(_mountPoint.c_str());
|
||||
|
||||
_mountThread->join();
|
||||
_mountThread.reset(nullptr);
|
||||
_mountPoint.clear();
|
||||
@@ -460,6 +501,7 @@ public:
|
||||
|
||||
static void Shutdown()
|
||||
{
|
||||
StopFileListThread();
|
||||
Unmount();
|
||||
_uploadManager.reset(nullptr);
|
||||
_siaApi = nullptr;
|
||||
@@ -511,7 +553,6 @@ CSiaDokanDrive::CSiaDokanDrive(CSiaApi& siaApi, CSiaDriveConfig* siaDriveConfig)
|
||||
CSiaDokanDrive::~CSiaDokanDrive()
|
||||
{
|
||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||
Unmount();
|
||||
DokanImpl::Shutdown();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user