CarotDav_decompile/Rei.Fs/IO/Win32Native.cs

183 lines
6.9 KiB
C#
Raw Normal View History

// 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;
}
}
}