-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRustigateDemoExt.cs
47 lines (39 loc) · 1.29 KB
/
RustigateDemoExt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.IO;
namespace Oxide.Ext.Rustigate
{
public class RustigateDemoExt
{
//instead of getting the size of the folder each time a demo is added or deleted
//we just incrementally subtract or add based on DeleteDemoFromDisk and NotifyNewDemoCreated calls
public long DemoFolderSize;
public RustigateDemoExt()
{
}
public void NotifyNewDemoCreated(string DemofileLocation)
{
long DemoSize = GetDemoSize(DemofileLocation);
DemoFolderSize += DemoSize;
}
public bool IsDemoOnDisk(string DemofileLocation)
{
return File.Exists(DemofileLocation);
}
//returns the amount of bytes deleted
public long DeleteDemoFromDisk(string DemofileLocation)
{
if (IsDemoOnDisk(DemofileLocation))
{
long DemoSize = GetDemoSize(DemofileLocation);
DemoFolderSize -= DemoSize;
File.Delete(DemofileLocation);
return DemoSize;
}
return 0;
}
public long GetDemoSize(string DemofileLocation)
{
FileInfo DemoFileInfo = new FileInfo(DemofileLocation);
return DemoFileInfo.Length;
}
}
}