Disassembled CarotDav v1.14.7 with dotPeek 2017.2

This commit is contained in:
2017-10-06 17:20:58 +02:00
commit 2002a53fb5
191 changed files with 69359 additions and 0 deletions

111
Rei.Fs/IO/FileInfo.cs Normal file
View File

@@ -0,0 +1,111 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Fs.IO.FileInfo
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
using System;
using System.IO;
namespace Rei.Fs.IO
{
public class FileInfo
{
private FileAttributes pFileAttributes;
private DateTime pCreationTime;
private DateTime pLastAccessTime;
private DateTime pLastWriteTime;
private ulong pFileSize;
private string pFileName;
private string pFullPath;
private string pAltFileName;
internal FileInfo(string path, Win32Native.WIN32_FIND_DATA d)
{
this.pFileAttributes = d.dwFileAttributes;
this.pCreationTime = DateTime.FromFileTime((long) d.ftCreationTime.dwHighDateTime << 32 | (long) d.ftCreationTime.dwLowDateTime & (long) uint.MaxValue);
this.pLastAccessTime = DateTime.FromFileTime((long) d.ftLastAccessTime.dwHighDateTime << 32 | (long) d.ftLastAccessTime.dwLowDateTime & (long) uint.MaxValue);
this.pLastWriteTime = DateTime.FromFileTime((long) d.ftLastWriteTime.dwHighDateTime << 32 | (long) d.ftLastWriteTime.dwLowDateTime & (long) uint.MaxValue);
this.pFileSize = checked ((ulong) d.nFileSizeHigh << 32 + (ulong) d.nFileSizeLow);
this.pFileName = d.cFileName;
this.pAltFileName = d.cAlternateFileName;
this.pFullPath = path;
}
internal FileInfo(string path, Win32Native.WIN32_FILE_ATTRIBUTE_DATA d)
{
this.pFileAttributes = d.dwFileAttributes;
this.pCreationTime = DateTime.FromFileTime((long) d.ftCreationTime.dwHighDateTime << 32 | (long) d.ftCreationTime.dwLowDateTime & (long) uint.MaxValue);
this.pLastAccessTime = DateTime.FromFileTime((long) d.ftLastAccessTime.dwHighDateTime << 32 | (long) d.ftLastAccessTime.dwLowDateTime & (long) uint.MaxValue);
this.pLastWriteTime = DateTime.FromFileTime((long) d.ftLastWriteTime.dwHighDateTime << 32 | (long) d.ftLastWriteTime.dwLowDateTime & (long) uint.MaxValue);
this.pFileSize = checked ((ulong) d.nFileSizeHigh << 32 + (ulong) d.nFileSizeLow);
this.pFileName = FileSystem.GetFilename(path);
this.pAltFileName = (string) null;
this.pFullPath = path;
}
public bool IsDirectory
{
get
{
return (this.FileAttributes & FileAttributes.Directory) != (FileAttributes) 0;
}
}
public FileAttributes FileAttributes
{
get
{
return this.pFileAttributes;
}
}
public DateTime CreationTime
{
get
{
return this.pCreationTime;
}
}
public DateTime LastAccessTime
{
get
{
return this.pLastAccessTime;
}
}
public DateTime LastWriteTime
{
get
{
return this.pLastWriteTime;
}
}
public ulong FileSize
{
get
{
return this.pFileSize;
}
}
public string FileName
{
get
{
return this.pFileName;
}
}
public string FullPath
{
get
{
return this.pFullPath;
}
}
}
}

482
Rei.Fs/IO/FileSystem.cs Normal file
View File

@@ -0,0 +1,482 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Fs.IO.FileSystem
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace Rei.Fs.IO
{
[StandardModule]
public sealed class FileSystem
{
private static DateTime win32timeorigin = new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static string CombinePath(string path1, string path2)
{
if (path1.EndsWith("\\"))
{
if (path2.StartsWith("\\"))
return path1 + path2.Substring(1);
return path1 + path2;
}
if (path2.StartsWith("\\"))
return path1 + path2;
return path1 + "\\" + path2;
}
public static string GetFilename(string path)
{
while (path.EndsWith("\\"))
path = path.Substring(0, checked (path.Length - 1));
int num = path.LastIndexOf("\\");
if (num < 0)
return path;
return path.Substring(checked (num + 1));
}
public static string GetDirectoryName(string path)
{
while (path.EndsWith("\\"))
path = path.Substring(0, checked (path.Length - 1));
int length = path.LastIndexOf("\\");
if (length < 0)
return path;
return path.Substring(0, length);
}
public static string NormalizePath(string path)
{
if (path.StartsWith("\\\\?\\"))
return path;
string str1 = path;
if (str1.Length >= 248)
;
string str2 = str1.Replace("/", "\\");
if (str2.StartsWith("\\\\"))
path = "\\\\?\\UNC\\" + str2.Substring(1);
else if (path.Length > 3 && Operators.CompareString(Conversions.ToString(path[1]), ":", false) == 0 && Operators.CompareString(Conversions.ToString(path[2]), "\\", false) == 0)
path = "\\\\?\\" + str2.Replace("/", "\\");
else if (Operators.CompareString(Conversions.ToString(path[0]), "\\", false) == 0)
path = "\\\\?\\" + str2.Replace("/", "\\");
return path;
}
public static System.Runtime.InteropServices.ComTypes.FILETIME ToFileTime(DateTime time)
{
byte[] bytes = BitConverter.GetBytes(DateTime.Compare(time, FileSystem.win32timeorigin) >= 0 ? time.ToFileTime() : 0L);
System.Runtime.InteropServices.ComTypes.FILETIME filetime;
filetime.dwHighDateTime = BitConverter.ToInt32(bytes, 4);
filetime.dwLowDateTime = BitConverter.ToInt32(bytes, 0);
return filetime;
}
private static void RaiseError(string path)
{
FileSystem.RaiseError(path, Marshal.GetLastWin32Error());
}
private static void RaiseError(string path, int code)
{
switch (code)
{
case 2:
throw new FileNotFoundException();
case 3:
throw new DirectoryNotFoundException();
case 5:
throw new UnauthorizedAccessException();
case 15:
throw new DriveNotFoundException();
default:
throw new IOException(new Win32Exception(code).Message);
}
}
public static FileInfo GetFileInfo(string path)
{
FileInfo info = (FileInfo) null;
if (!FileSystem.TryGetFileInfo(path, ref info))
FileSystem.RaiseError(path);
return info;
}
public static bool TryGetFileInfo(string path, ref FileInfo info)
{
string path1 = FileSystem.NormalizePath(path);
Win32Native.WIN32_FILE_ATTRIBUTE_DATA fileData;
if (!Win32Native.GetFileAttributesEx(FileSystem.NormalizePath(path), Win32Native.GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, ref fileData))
{
switch (Marshal.GetLastWin32Error())
{
case 2:
case 3:
case 50:
case 67:
return false;
default:
throw new ArgumentOutOfRangeException("TryGetFileInfo error path:" + path + " error:" + Conversions.ToString(Marshal.GetLastWin32Error()));
}
}
else
{
info = new FileInfo(path1, fileData);
return true;
}
}
public static bool FileOrDirectoryExists(string path, ref bool isdirectory)
{
Win32Native.ErrorModeType uMode = Win32Native.SetErrorMode(Win32Native.ErrorModeType.SEM_FAILCRITICALERRORS);
Win32Native.WIN32_FILE_ATTRIBUTE_DATA fileData;
bool fileAttributesEx;
try
{
fileAttributesEx = Win32Native.GetFileAttributesEx(FileSystem.NormalizePath(path), Win32Native.GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, ref fileData);
}
finally
{
int num = (int) Win32Native.SetErrorMode(uMode);
}
if (!fileAttributesEx)
{
int lastWin32Error = Marshal.GetLastWin32Error();
switch (lastWin32Error)
{
case 2:
case 3:
break;
default:
throw new ArgumentOutOfRangeException(path + " " + lastWin32Error.ToString());
}
}
else
isdirectory = (fileData.dwFileAttributes & FileAttributes.Directory) != (FileAttributes) 0;
return fileAttributesEx;
}
public static bool FileExists(string path)
{
Win32Native.ErrorModeType uMode = Win32Native.SetErrorMode(Win32Native.ErrorModeType.SEM_FAILCRITICALERRORS);
Win32Native.WIN32_FILE_ATTRIBUTE_DATA fileData;
bool fileAttributesEx;
try
{
fileAttributesEx = Win32Native.GetFileAttributesEx(FileSystem.NormalizePath(path), Win32Native.GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, ref fileData);
}
finally
{
int num = (int) Win32Native.SetErrorMode(uMode);
}
if (!fileAttributesEx)
{
switch (Marshal.GetLastWin32Error())
{
case 2:
case 3:
break;
default:
throw new ArgumentOutOfRangeException(path);
}
}
return fileAttributesEx && (fileData.dwFileAttributes & FileAttributes.Directory) == (FileAttributes) 0;
}
public static bool DirectoryExists(string path)
{
Win32Native.ErrorModeType uMode = Win32Native.SetErrorMode(Win32Native.ErrorModeType.SEM_FAILCRITICALERRORS);
Win32Native.WIN32_FILE_ATTRIBUTE_DATA fileData;
bool fileAttributesEx;
try
{
fileAttributesEx = Win32Native.GetFileAttributesEx(FileSystem.NormalizePath(path), Win32Native.GET_FILEEX_INFO_LEVELS.GetFileExInfoStandard, ref fileData);
}
finally
{
int num = (int) Win32Native.SetErrorMode(uMode);
}
if (!fileAttributesEx)
{
switch (Marshal.GetLastWin32Error())
{
case 2:
case 3:
break;
default:
throw new ArgumentOutOfRangeException(path);
}
}
return fileAttributesEx && (fileData.dwFileAttributes & FileAttributes.Directory) != (FileAttributes) 0;
}
public static string[] GetNetworkShare(string host)
{
List<string> stringList = new List<string>();
int entriesread = 0;
int totalentries = 0;
int resume_handle = 0;
int num1 = Marshal.SizeOf(typeof (Win32Native.SHARE_INFO_0));
IntPtr zero = IntPtr.Zero;
int hresult = Win32Native.NetShareEnum(new StringBuilder(host), 0, ref zero, uint.MaxValue, ref entriesread, ref totalentries, ref resume_handle);
if (hresult != 0)
throw new IOException("unknown error", hresult);
try
{
IntPtr ptr = zero;
int num2 = 0;
int num3 = checked (entriesread - 1);
int num4 = num2;
while (num4 <= num3)
{
object structure = Marshal.PtrToStructure(ptr, typeof (Win32Native.SHARE_INFO_0));
Win32Native.SHARE_INFO_0 shareInfo0_1;
Win32Native.SHARE_INFO_0 shareInfo0_2 = structure != null ? (Win32Native.SHARE_INFO_0) structure : shareInfo0_1;
stringList.Add(shareInfo0_2.shi0_netname);
ptr = new IntPtr(checked (ptr.ToInt32() + num1));
checked { ++num4; }
}
}
finally
{
Win32Native.NetApiBufferFree(zero);
}
return stringList.ToArray();
}
public static SafeFileHandle CreateFile(string path, FileAccess access, FileShare share, FileMode mode)
{
return FileSystem.CreateFile(path, access, share, mode, 128U);
}
public static SafeFileHandle CreateFile(string path, FileAccess access, FileShare share, FileMode mode, uint dwFlagsAndAttributes)
{
SafeFileHandle file;
if (mode == FileMode.Append)
{
file = Win32Native.CreateFile(FileSystem.NormalizePath(path), checked ((uint) access), checked ((uint) share), IntPtr.Zero, 4U, dwFlagsAndAttributes | 268435456U, IntPtr.Zero);
if (!file.IsInvalid)
{
int num = (int) Win32Native.SetFilePointer(file, 0, IntPtr.Zero, Win32Native.MoveMethodType.FILE_END);
}
}
else
{
uint dwDesiredAccess;
if (access == FileAccess.Read)
dwDesiredAccess = 2147483648U;
else if (access == FileAccess.Write)
dwDesiredAccess = 1073741824U;
else if (access == FileAccess.ReadWrite)
dwDesiredAccess = 268435456U;
file = Win32Native.CreateFile(FileSystem.NormalizePath(path), dwDesiredAccess, checked ((uint) share), IntPtr.Zero, checked ((uint) mode), dwFlagsAndAttributes, IntPtr.Zero);
}
if (file.IsInvalid)
FileSystem.RaiseError(path);
return file;
}
public static Stream OpenRead(string path)
{
return (Stream) new FileStream(FileSystem.CreateFile(path, FileAccess.Read, FileShare.Read, FileMode.Open), FileAccess.Read);
}
public static void SetFileTime(string path, DateTime creationtime, DateTime accesstime, DateTime writetime)
{
if (DateTime.Compare(creationtime, DateTime.MinValue) == 0 && DateTime.Compare(accesstime, DateTime.MinValue) == 0 && DateTime.Compare(writetime, DateTime.MinValue) == 0)
return;
while (path.EndsWith("\\"))
path = path.Substring(0, checked (path.Length - 1));
using (SafeFileHandle file = Win32Native.CreateFile(FileSystem.NormalizePath(path), 256U, 0U, IntPtr.Zero, 3U, 33554432U, IntPtr.Zero))
{
if (file.IsInvalid)
FileSystem.RaiseError(path);
System.Runtime.InteropServices.ComTypes.FILETIME lpCreationTime = new System.Runtime.InteropServices.ComTypes.FILETIME();
System.Runtime.InteropServices.ComTypes.FILETIME lpLastAccessTime = new System.Runtime.InteropServices.ComTypes.FILETIME();
System.Runtime.InteropServices.ComTypes.FILETIME lpLastWriteTime = new System.Runtime.InteropServices.ComTypes.FILETIME();
if (DateTime.Compare(creationtime, DateTime.MinValue) > 0)
lpCreationTime = FileSystem.ToFileTime(creationtime);
if (DateTime.Compare(accesstime, DateTime.MinValue) > 0)
lpLastAccessTime = FileSystem.ToFileTime(accesstime);
if (DateTime.Compare(writetime, DateTime.MinValue) > 0)
lpLastWriteTime = FileSystem.ToFileTime(writetime);
if (Win32Native.SetFileTime(file, ref lpCreationTime, ref lpLastAccessTime, ref lpLastWriteTime))
return;
FileSystem.RaiseError(path);
}
}
public static FileInfo[] ListDirectoryEntries(string directorypath)
{
if (string.IsNullOrEmpty(directorypath))
throw new ArgumentNullException();
directorypath = directorypath.EndsWith("\\") || directorypath.EndsWith("/") ? FileSystem.CombinePath(directorypath, "*") : FileSystem.CombinePath(directorypath, "\\*");
return FileSystem.FindFiles(directorypath);
}
public static FileInfo[] FindFiles(string path)
{
List<FileInfo> fileInfoList = new List<FileInfo>();
Win32Native.WIN32_FIND_DATA lpFindFileData = new Win32Native.WIN32_FIND_DATA();
int length = path.LastIndexOf("\\");
int num = path.LastIndexOf("/");
if (num > length)
length = num;
string path1 = length >= 0 ? path.Substring(0, length) : Environment.CurrentDirectory;
using (SafeFindHandle firstFile = Win32Native.FindFirstFile(FileSystem.NormalizePath(path), out lpFindFileData))
{
if (firstFile.IsInvalid)
FileSystem.RaiseError(path);
do
{
if (Operators.CompareString(lpFindFileData.cFileName, ".", false) != 0 && Operators.CompareString(lpFindFileData.cFileName, "..", false) != 0)
fileInfoList.Add(new FileInfo(FileSystem.CombinePath(path1, lpFindFileData.cFileName), lpFindFileData));
}
while (Win32Native.FindNextFile(firstFile, out lpFindFileData));
int lastWin32Error = Marshal.GetLastWin32Error();
if (lastWin32Error != 18)
FileSystem.RaiseError(path, lastWin32Error);
}
return fileInfoList.ToArray();
}
public static void CreateDirectory(string path)
{
if (Win32Native.CreateDirectory(FileSystem.NormalizePath(path), IntPtr.Zero))
return;
FileSystem.RaiseError(path);
}
public static void DeleteFile(string path, bool recursive)
{
string str1 = FileSystem.NormalizePath(path);
bool isdirectory;
if (!FileSystem.FileOrDirectoryExists(str1, ref isdirectory))
throw new FileNotFoundException();
if (!isdirectory)
{
if (Win32Native.DeleteFile(str1))
return;
FileSystem.RaiseError(str1);
}
else if (!recursive)
{
if (Win32Native.RemoveDirectory(str1))
return;
FileSystem.RaiseError(str1);
}
else
{
List<string> stringList = new List<string>();
stringList.Add(str1);
while (stringList.Count > 0)
{
string str2 = stringList[checked (stringList.Count - 1)];
FileInfo[] fileInfoArray = FileSystem.ListDirectoryEntries(str2);
if (fileInfoArray.Length == 0)
{
if (!Win32Native.RemoveDirectory(str2))
FileSystem.RaiseError(str2);
stringList.RemoveAt(checked (stringList.Count - 1));
}
else
{
int num1 = 0;
int num2 = checked (fileInfoArray.Length - 1);
int index = num1;
while (index <= num2)
{
if (fileInfoArray[index].IsDirectory)
stringList.Add(FileSystem.NormalizePath(FileSystem.CombinePath(str2, fileInfoArray[index].FileName)));
else if (!Win32Native.DeleteFile(FileSystem.NormalizePath(FileSystem.CombinePath(str2, fileInfoArray[index].FileName))))
FileSystem.RaiseError(str2);
checked { ++index; }
}
}
}
}
}
public static void MoveFile(string path1, string path2, bool overwrite)
{
if (!overwrite ? Win32Native.MoveFileEx(FileSystem.NormalizePath(path1), FileSystem.NormalizePath(path2), Win32Native.MoveFileFlagType.MOVEFILE_COPY_ALLOWED) : Win32Native.MoveFileEx(FileSystem.NormalizePath(path1), FileSystem.NormalizePath(path2), Win32Native.MoveFileFlagType.MOVEFILE_REPLACE_EXISTING | Win32Native.MoveFileFlagType.MOVEFILE_COPY_ALLOWED))
return;
int lastWin32Error = Marshal.GetLastWin32Error();
FileSystem.RaiseError(path1, lastWin32Error);
}
public static void CopyFile(string path1, string path2, bool overwrite)
{
string str1 = FileSystem.NormalizePath(path1);
string str2 = FileSystem.NormalizePath(path2);
bool isdirectory1;
if (!FileSystem.FileOrDirectoryExists(str1, ref isdirectory1))
throw new FileNotFoundException();
bool isdirectory2;
if (!overwrite && FileSystem.FileOrDirectoryExists(str2, ref isdirectory2))
FileSystem.RaiseError(str2, 183);
if (!isdirectory1)
{
if (Win32Native.CopyFile(str1, str2, !overwrite))
return;
FileSystem.RaiseError(str1);
}
else
{
List<string[]> strArrayList = new List<string[]>();
strArrayList.Add(new string[3]{ str1, str2, "d" });
int index1 = 0;
while (index1 < strArrayList.Count)
{
string[] strArray = strArrayList[index1];
if (Operators.CompareString(strArray[2], "d", false) == 0)
{
FileInfo[] fileInfoArray = FileSystem.ListDirectoryEntries(strArray[0]);
int num1 = 0;
int num2 = checked (fileInfoArray.Length - 1);
int index2 = num1;
while (index2 <= num2)
{
if (fileInfoArray[index2].IsDirectory)
strArrayList.Add(new string[3]
{
FileSystem.NormalizePath(FileSystem.CombinePath(strArray[0], fileInfoArray[index2].FileName)),
FileSystem.NormalizePath(FileSystem.CombinePath(strArray[1], fileInfoArray[index2].FileName)),
"d"
});
else
strArrayList.Add(new string[3]
{
FileSystem.NormalizePath(FileSystem.CombinePath(strArray[0], fileInfoArray[index2].FileName)),
FileSystem.NormalizePath(FileSystem.CombinePath(strArray[1], fileInfoArray[index2].FileName)),
"f"
});
checked { ++index2; }
}
}
checked { ++index1; }
}
int index3 = 0;
while (index3 < strArrayList.Count)
{
string[] strArray = strArrayList[index3];
if (Operators.CompareString(strArray[2], "d", false) == 0)
{
if (!Win32Native.CreateDirectory(strArray[1], IntPtr.Zero))
FileSystem.RaiseError(strArray[1]);
}
else if (!Win32Native.CopyFile(strArray[0], strArray[1], !overwrite))
FileSystem.RaiseError(strArray[0]);
checked { ++index3; }
}
}
}
}
}

View File

@@ -0,0 +1,23 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Fs.IO.SafeFindHandle
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
using Microsoft.Win32.SafeHandles;
namespace Rei.Fs.IO
{
public class SafeFindHandle : SafeHandleMinusOneIsInvalid
{
private SafeFindHandle()
: base(true)
{
}
protected override bool ReleaseHandle()
{
return Win32Native.FindClose(this.handle);
}
}
}

182
Rei.Fs/IO/Win32Native.cs Normal file
View File

@@ -0,0 +1,182 @@
// Decompiled with JetBrains decompiler
// Type: Rei.Fs.IO.Win32Native
// Assembly: Rei.Fs, Version=1.13.2.8796, Culture=neutral, PublicKeyToken=null
// MVID: D8B08A8B-697C-4439-9CFF-1BE4EE46F7B0
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\Rei.Fs.dll
using Microsoft.VisualBasic.CompilerServices;
using Microsoft.Win32.SafeHandles;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace Rei.Fs.IO
{
[StandardModule]
public sealed class Win32Native
{
public const int MAX_PATH = 260;
public const string LongFilePrefix = "\\\\?\\";
public const string LongFileUncPrefix = "\\\\?\\UNC\\";
public const uint MAX_PREFERRED_LENGTH = 4294967295;
[DllImport("kernel32.dll")]
public static extern Win32Native.ErrorModeType SetErrorMode(Win32Native.ErrorModeType uMode);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool GetFileAttributesEx(string lpFileName, Win32Native.GET_FILEEX_INFO_LEVELS fInfoLevelId, ref Win32Native.WIN32_FILE_ATTRIBUTE_DATA fileData);
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int NetShareEnum(StringBuilder ServerName, int level, ref IntPtr bufPtr, uint prefmaxlen, ref int entriesread, ref int totalentries, ref int resume_handle);
[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int NetApiBufferFree(IntPtr buf);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern uint SetFilePointer(SafeFileHandle hFile, int lDistanceToMove, IntPtr lpDistanceToMoveHigh, Win32Native.MoveMethodType dwMoveMethod);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetFileTime(SafeFileHandle hFile, [In] ref System.Runtime.InteropServices.ComTypes.FILETIME lpCreationTime, [In] ref System.Runtime.InteropServices.ComTypes.FILETIME lpLastAccessTime, [In] ref System.Runtime.InteropServices.ComTypes.FILETIME lpLastWriteTime);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeFindHandle FindFirstFile(string lpFileName, out Win32Native.WIN32_FIND_DATA lpFindFileData);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool FindNextFile(SafeFindHandle hFindFile, out Win32Native.WIN32_FIND_DATA lpFindFileData);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool FindClose(IntPtr hFindFile);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CreateDirectory(string lpPathName, IntPtr lpSecurityAttributes);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool DeleteFile(string lpFileName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool RemoveDirectory(string lpPathName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, Win32Native.MoveFileFlagType dwFlags);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CopyFile(string lpExistingFileName, string lpNewFileName, bool bFailIfExists);
public struct WIN32_FILE_ATTRIBUTE_DATA
{
public FileAttributes dwFileAttributes;
public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime;
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime;
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime;
public uint nFileSizeHigh;
public uint nFileSizeLow;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WIN32_FIND_DATA
{
public FileAttributes dwFileAttributes;
public System.Runtime.InteropServices.ComTypes.FILETIME ftCreationTime;
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastAccessTime;
public System.Runtime.InteropServices.ComTypes.FILETIME ftLastWriteTime;
public uint nFileSizeHigh;
public uint nFileSizeLow;
public uint dwReserved0;
public uint dwReserved1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string cFileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string cAlternateFileName;
}
public enum GET_FILEEX_INFO_LEVELS
{
GetFileExInfoStandard,
GetFileExMaxInfoLevel,
}
[Flags]
public enum ErrorModeType : uint
{
System_DefalutDEFAULT = 0,
SEM_FAILCRITICALERRORS = 1,
SEM_NOALIGNMENTFAULTEXCEPT = 4,
SEM_NOGPFAULTERRORBOX = 2,
SEM_NOOPENFILEERRORBOX = 32768,
}
public enum CreateDispositionType : uint
{
CREATE_NEW = 1,
CREATE_ALWAYS = 2,
OPEN_EXISTING = 3,
OPEN_ALWAYS = 4,
TRUNCATE_EXISTING = 5,
}
[Flags]
public enum FileAttributeType : uint
{
FILE_ATTRIBUTE_READONLY = 1,
FILE_ATTRIBUTE_HIDDEN = 2,
FILE_ATTRIBUTE_SYSTEM = 4,
FILE_ATTRIBUTE_DIRECTORY = 16,
FILE_ATTRIBUTE_ARCHIVE = 32,
FILE_ATTRIBUTE_DEVICE = 64,
FILE_ATTRIBUTE_NORMAL = 128,
FILE_ATTRIBUTE_TEMPORARY = 256,
FILE_ATTRIBUTE_SPARSE_FILE = 512,
FILE_ATTRIBUTE_REPARSE_POINT = 1024,
FILE_ATTRIBUTE_COMPRESSED = 2048,
FILE_ATTRIBUTE_OFFLINE = 4096,
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192,
FILE_ATTRIBUTE_ENCRYPTED = 16384,
FILE_ATTRIBUTE_VIRTUAL = 65536,
}
public enum MoveMethodType : uint
{
FILE_BEGIN,
FILE_CURRENT,
FILE_END,
}
[Flags]
public enum GenericAccessType : uint
{
GENERIC_READ = 2147483648,
GENERIC_WRITE = 1073741824,
GENERIC_EXECUTE = 536870912,
GENERIC_ALL = 268435456,
}
[Flags]
public enum FileShareType : uint
{
FILE_SHARE_READ = 1,
FILE_SHARE_WRITE = 2,
FILE_SHARE_DELETE = 4,
}
[Flags]
public enum MoveFileFlagType : uint
{
MOVEFILE_REPLACE_EXISTING = 1,
MOVEFILE_COPY_ALLOWED = 2,
MOVEFILE_DELAY_UNTIL_REBOOT = 4,
MOVEFILE_WRITE_THROUGH = 8,
MOVEFILE_CREATE_HARDLINK = 16,
MOVEFILE_FAIL_IF_NOT_TRACKABLE = 32,
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHARE_INFO_0
{
public string shi0_netname;
}
}
}