-
Notifications
You must be signed in to change notification settings - Fork 9
/
DokanFileInfo.cs
105 lines (85 loc) · 2.53 KB
/
DokanFileInfo.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Runtime.InteropServices;
using System.Security.Principal;
using DokanNet.Native;
#pragma warning disable 649,169
namespace DokanNet
{
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public sealed class DokanFileInfo
{
private ulong _context;
private readonly ulong _dokanContext;
private readonly IntPtr _dokanOptions;
private readonly uint _processId;
[MarshalAs(UnmanagedType.U1)] private bool _isDirectory;
[MarshalAs(UnmanagedType.U1)] private bool _deleteOnClose;
[MarshalAs(UnmanagedType.U1)] private bool _pagingIo;
[MarshalAs(UnmanagedType.U1)] private bool _synchronousIo;
[MarshalAs(UnmanagedType.U1)] private bool _nocache;
[MarshalAs(UnmanagedType.U1)] private bool _writeToEndOfFile;
public object Context
{
get { return _context != 0 ? ((GCHandle) ((IntPtr) _context)).Target : null; }
set
{
if (_context != 0)
{
((GCHandle) ((IntPtr) _context)).Free();
_context = 0;
}
if (value != null)
{
_context = (ulong) (IntPtr) GCHandle.Alloc(value);
}
}
}
public int ProcessId
{
get { return (int) _processId; }
}
public bool IsDirectory
{
get { return _isDirectory; }
set { _isDirectory = value; }
}
public bool DeleteOnClose
{
get { return _deleteOnClose; }
set { _deleteOnClose = value; }
}
public bool PagingIo
{
get { return _pagingIo; }
}
public bool SynchronousIo
{
get { return _synchronousIo; }
}
public bool NoCache
{
get { return _nocache; }
}
public bool WriteToEndOfFile
{
get { return _writeToEndOfFile; }
}
public WindowsIdentity GetRequestor()
{
try
{
return new WindowsIdentity(NativeMethods.DokanOpenRequestorToken(this));
}
catch
{
return null;
}
}
public bool TryResetTimeout(int milliseconds)
{
return NativeMethods.DokanResetTimeout((uint) milliseconds, this);
}
private DokanFileInfo(){}
}
}
#pragma warning restore 649,169