|
|
@ -2,6 +2,7 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using Ionic.Zip;
|
|
|
|
using Ionic.Zip;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
|
|
|
@ -9,6 +10,13 @@ namespace NzbDrone.Core.Providers.Core
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class DiskProvider
|
|
|
|
public class DiskProvider
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
|
|
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
|
|
|
static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
|
|
|
|
|
|
|
|
out ulong lpFreeBytesAvailable,
|
|
|
|
|
|
|
|
out ulong lpTotalNumberOfBytes,
|
|
|
|
|
|
|
|
out ulong lpTotalNumberOfFreeBytes);
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
|
|
public virtual bool FolderExists(string path)
|
|
|
|
public virtual bool FolderExists(string path)
|
|
|
@ -96,5 +104,19 @@ namespace NzbDrone.Core.Providers.Core
|
|
|
|
fs.SetAccessRuleProtection(false, false);
|
|
|
|
fs.SetAccessRuleProtection(false, false);
|
|
|
|
File.SetAccessControl(filename, fs);
|
|
|
|
File.SetAccessControl(filename, fs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual ulong FreeDiskSpace(DirectoryInfo directoryInfo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ulong freeBytesAvailable;
|
|
|
|
|
|
|
|
ulong totalNumberOfBytes;
|
|
|
|
|
|
|
|
ulong totalNumberOfFreeBytes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool success = GetDiskFreeSpaceEx(directoryInfo.FullName, out freeBytesAvailable, out totalNumberOfBytes,
|
|
|
|
|
|
|
|
out totalNumberOfFreeBytes);
|
|
|
|
|
|
|
|
if (!success)
|
|
|
|
|
|
|
|
throw new System.ComponentModel.Win32Exception();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return freeBytesAvailable;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|