Pass cache location
This commit is contained in:
@@ -35,7 +35,12 @@ private:
|
|||||||
static String _mountPoint;
|
static String _mountPoint;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool AddFileToCache(const String& siaPath, const String& cachePath)
|
inline static const String& GetCacheLocation()
|
||||||
|
{
|
||||||
|
return _cacheLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool AddFileToCache(const String& siaPath, const String& cacheLocation)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
std::wstring tempPath;
|
std::wstring tempPath;
|
||||||
@@ -148,7 +153,7 @@ private:
|
|||||||
{
|
{
|
||||||
String cacheFilePath;
|
String cacheFilePath;
|
||||||
cacheFilePath.resize(MAX_PATH + 1);
|
cacheFilePath.resize(MAX_PATH + 1);
|
||||||
PathCombine(&cacheFilePath[0], _cacheLocation.c_str(), siaPath.c_str());
|
PathCombine(&cacheFilePath[0], GetCacheLocation().c_str(), siaPath.c_str());
|
||||||
|
|
||||||
// If cache file already exists and is a directory, requested file operation isn't valid
|
// If cache file already exists and is a directory, requested file operation isn't valid
|
||||||
if (GetFileAttributes(cacheFilePath.c_str()) & FILE_ATTRIBUTE_DIRECTORY)
|
if (GetFileAttributes(cacheFilePath.c_str()) & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
@@ -418,10 +423,11 @@ public:
|
|||||||
_dokanOptions.Options |= DOKAN_OPTION_CURRENT_SESSION;
|
_dokanOptions.Options |= DOKAN_OPTION_CURRENT_SESSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mount(const wchar_t& driveLetter)
|
static void Mount(const wchar_t& driveLetter, const String& cacheLocation)
|
||||||
{
|
{
|
||||||
if (_siaApi && !_mountThread)
|
if (_siaApi && !_mountThread)
|
||||||
{
|
{
|
||||||
|
_cacheLocation = cacheLocation;
|
||||||
wchar_t tmp[] = { driveLetter, ':', '\\', 0 };
|
wchar_t tmp[] = { driveLetter, ':', '\\', 0 };
|
||||||
_mountPoint = tmp;
|
_mountPoint = tmp;
|
||||||
_mountThread.reset(new std::thread([&]()
|
_mountThread.reset(new std::thread([&]()
|
||||||
@@ -499,12 +505,13 @@ CSiaDokanDrive::~CSiaDokanDrive()
|
|||||||
void CSiaDokanDrive::Mount(const wchar_t& driveLetter, const String& cacheLocation, const std::uint64_t& maxCacheSizeBytes)
|
void CSiaDokanDrive::Mount(const wchar_t& driveLetter, const String& cacheLocation, const std::uint64_t& maxCacheSizeBytes)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||||
DokanImpl::Mount('s');
|
DokanImpl::Mount(driveLetter, cacheLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSiaDokanDrive::Unmount(const bool& clearCache)
|
void CSiaDokanDrive::Unmount(const bool& clearCache)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
std::lock_guard<std::mutex> l(DokanImpl::GetMutex());
|
||||||
|
DokanImpl::Unmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSiaDokanDrive::ClearCache()
|
void CSiaDokanDrive::ClearCache()
|
||||||
|
Reference in New Issue
Block a user