25#define WIN32_NO_STATUS
38#define NO_SHLWAPI_STRFCNS
44#include "../btrfsioctl.h"
49#define NEW_SUBVOL_VERBA "newsubvol"
50#define NEW_SUBVOL_VERBW L"newsubvol"
51#define SNAPSHOT_VERBA "snapshot"
52#define SNAPSHOT_VERBW L"snapshot"
53#define REFLINK_VERBA "reflink"
54#define REFLINK_VERBW L"reflink"
55#define RECV_VERBA "recvsubvol"
56#define RECV_VERBW L"recvsubvol"
57#define SEND_VERBA "sendsubvol"
58#define SEND_VERBW L"sendsubvol"
75 }
else if (
riid == IID_IShellExtInit) {
91 FORMATETC
format = {
CF_HDROP,
nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
99 stgm.tymed = TYMED_HGLOBAL;
116 for (
i = 0;
i < num_files;
i++) {
236 if (num_files == 0) {
258 return !
wcscmp(volpath1, volpath2);
300 hr =
CoCreateInstance(CLSID_WICImagingFactory,
nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (
void **)&
factory);
346 if (
uFlags & CMF_DEFAULTONLY)
360 if (idCmdFirst + entries <= idCmdLast) {
373 mii.
wID = idCmdFirst + entries;
390 if (idCmdFirst + 1 <= idCmdLast) {
403 mii.
wID = idCmdFirst + 1;
429 if (
bs == string::npos)
443 if (
bs == string::npos) {
463 wstring subvolname, parpath, searchpath, temp1,
name, nameorig;
487 searchpath = parpath +
L"\\" +
name;
496 name = nameorig +
L" (" + to_wstring(
num) +
L")";
505 searchpath = parpath +
L"\\" +
name;
515 bcs->readonly =
false;
533 n = (
n +
a) & ~(
a - 1);
540 WCHAR*
name, volpath1[255], volpath2[255];
541 wstring dirw, newpath;
570 if (
wcscmp(volpath1, volpath2))
619 memcpy(bcs->
name, destname.c_str(), destname.length() *
sizeof(
WCHAR));
691 wstring namew =
name;
748 if (fff.cFileName[0] ==
'.' && (fff.cFileName[1] == 0 || (fff.cFileName[1] ==
'.' && fff.cFileName[2] == 0)))
753 fn2 += fff.cFileName;
782 FILE_STANDARD_INFO fsi;
783 FILE_END_OF_FILE_INFO feofi;
808 feofi.EndOfFile = fsi.EndOfFile;
819 while (
offset < alloc_size) {
829 ULONG streambufsize = 0;
833 streambufsize += 0x1000;
847 if (fsi->StreamNameLength > 0) {
848 wstring sn = wstring(fsi->StreamName, fsi->StreamNameLength /
sizeof(
WCHAR));
850 if (sn !=
L"::$DATA" && sn.length() > 6 && sn.substr(sn.length() - 6, 6) ==
L":$DATA") {
895 if (fsi->NextEntryOffset == 0)
929 while (xa2->valuelen > 0) {
943 FILE_DISPOSITION_INFO fdi;
945 fdi.DeleteFile =
true;
974 for (
i = 0;
i < num_files;
i++) {
998 for (
i = 0;
i < num_files;
i++) {
1002 t +=
L"\",SendSubvolGUI ";
1007 sei.
cbSize =
sizeof(sei);
1030 wstring
name, nameorig, searchpath;
1053 name = nameorig +
L" (" + to_wstring(
num) +
L")";
1095 t +=
L"\",RecvSubvolGUI ";
1100 sei.
cbSize =
sizeof(sei);
1139 for (
i = 0;
i < num_files;
i++) {
1204 }
else if (idCmd == 1) {
1261 }
else if (idCmd == 1) {
1288 }
else if (idCmd == 2) {
1320static void reflink_copy2(
const wstring& srcfn,
const wstring& destdir,
const wstring& destname) {
1322 FILE_BASIC_INFO fbi;
1352 memcpy(bcs->
name, destname.c_str(), destname.length() *
sizeof(
WCHAR));
1435 if (fff.cFileName[0] ==
'.' && (fff.cFileName[1] == 0 || (fff.cFileName[1] ==
'.' && fff.cFileName[2] == 0)))
1440 fn2 += fff.cFileName;
1474 FILE_STANDARD_INFO fsi;
1475 FILE_END_OF_FILE_INFO feofi;
1500 feofi.EndOfFile = fsi.EndOfFile;
1511 while (
offset < alloc_size) {
1521 ULONG streambufsize = 0;
1525 streambufsize += 0x1000;
1539 if (fsi->StreamNameLength > 0) {
1540 wstring sn = wstring(fsi->StreamName, fsi->StreamNameLength /
sizeof(
WCHAR));
1542 if (sn !=
L"::$DATA" && sn.length() > 6 && sn.substr(sn.length() - 6, 6) ==
L":$DATA") {
1587 if (fsi->NextEntryOffset == 0)
1621 while (xa2->valuelen > 0) {
1635 FILE_DISPOSITION_INFO fdi;
1637 fdi.DeleteFile =
true;
1651 if (
args.size() >= 2) {
1652 bool dest_is_dir =
false;
1653 wstring
dest =
args[
args.size() - 1], destdir, destname;
1667 if (destdir.substr(destdir.
length() - 1, 1) !=
L"\\")
1674 size_t found =
dest.rfind(
L"\\");
1676 if (found == wstring::npos) {
1680 destdir =
dest.substr(0, found);
1681 destname =
dest.substr(found + 1);
1688 for (
unsigned int i = 0;
i <
args.size() - 1;
i++) {
1695 size_t found =
path.rfind(
L"\\");
1697 if (found == wstring::npos)
1705 if (!
wcscmp(volpath1, volpath2)) {
1708 reflink_copy2(
path + ffd.cFileName, destdir, dest_is_dir ? ffd.cFileName : destname);
basic_streambuf< char, char_traits< char > > streambuf
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
int strcmp(const char *String1, const char *String2)
#define FSCTL_BTRFS_CREATE_SNAPSHOT
#define FSCTL_BTRFS_SET_INODE_INFO
#define FSCTL_BTRFS_SET_XATTR
#define FSCTL_BTRFS_GET_XATTRS
#define FSCTL_BTRFS_MKNOD
#define FSCTL_BTRFS_GET_INODE_INFO
#define FSCTL_BTRFS_CREATE_SUBVOL
#define FSCTL_BTRFS_GET_FILE_IDS
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
#define NT_SUCCESS(StatCode)
void error_message(HWND hwnd, const char *msg)
void wstring_sprintf(wstring &s, wstring fmt,...)
void command_line_to_args(LPWSTR cmdline, vector< wstring > &args)
#define IDS_CREATE_SNAPSHOT_HELP_TEXT
#define IDS_NEW_SUBVOL_FILENAME
#define IDS_SNAPSHOT_FILENAME
#define IDS_CREATE_SNAPSHOT
#define IDS_NEW_SUBVOL_HELP_TEXT
#define IDS_REFLINK_PASTE_HELP
#define IDS_RECV_SUBVOL_HELP
#define IDS_CANT_REFLINK_DIFFERENT_FS
#define IDS_SEND_SUBVOL_HELP
#define IDS_REFLINK_PASTE
#define ReadFile(a, b, c, d, e)
#define INVALID_HANDLE_VALUE
static const WCHAR *const ext[]
BOOL WINAPI CreateDirectoryExW(IN LPCWSTR lpTemplateDirectory, IN LPCWSTR lpNewDirectory, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
BOOL WINAPI SetFileTime(IN HANDLE hFile, CONST FILETIME *lpCreationTime OPTIONAL, CONST FILETIME *lpLastAccessTime OPTIONAL, CONST FILETIME *lpLastWriteTime OPTIONAL)
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
BOOL WINAPI GetVolumePathNameW(IN LPCWSTR lpszFileName, IN LPWSTR lpszVolumePathName, IN DWORD cchBufferLength)
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
UINT WINAPI DragQueryFileW(HDROP hDrop, UINT lFile, LPWSTR lpszwFile, UINT lLength)
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
LPWSTR WINAPI PathFindExtensionW(LPCWSTR lpszPath)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
#define MAKE_HRESULT(sev, fac, code)
@ FileEndOfFileInformation
@ FileDispositionInformation
#define FILE_OPEN_REPARSE_POINT
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLboolean GLboolean GLboolean b
GLenum GLuint GLenum GLsizei const GLchar * buf
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT GetData([in, unique] FORMATETC *pformatetcIn, [out] STGMEDIUM *pmedium)
static struct msdos_boot_sector bs
#define memcpy(s1, s2, n)
#define ERROR_ALREADY_EXISTS
#define FILE_FLAG_BACKUP_SEMANTICS
static PIO_STATUS_BLOCK iosb
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
static short search(int val, const short *table, int size)
unsigned __int3264 UINT_PTR
static int load_string(HINSTANCE hModule, UINT resId, LPWSTR pwszBuffer, INT cMaxChars)
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
#define FILE_SHARE_DELETE
#define FILE_ATTRIBUTE_DIRECTORY
#define FILE_ADD_SUBDIRECTORY
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
_Must_inspect_result_ _Out_ LPSIZE psize
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
#define FILE_ATTRIBUTE_SPARSE_FILE
#define FILE_ATTRIBUTE_REPARSE_POINT
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
#define BTRFS_INODE_COMPRESS
_Out_opt_ int _Out_opt_ int * cy
#define FSCTL_GET_REPARSE_POINT
#define FSCTL_SET_REPARSE_POINT
#define offsetof(TYPE, MEMBER)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
int const char int stream_size
#define SEE_MASK_NOCLOSEPROCESS
#define SUBVOL_ROOT_INODE
#define FileStandardInformation
#define FSCTL_SET_INTEGRITY_INFORMATION
#define FSCTL_GET_INTEGRITY_INFORMATION
#define FSCTL_DUPLICATE_EXTENTS_TO_FILE
#define BTRFS_TYPE_SOCKET
#define STATUS_BUFFER_OVERFLOW
#define BTRFS_TYPE_CHARDEV
#define BTRFS_TYPE_BLOCKDEV
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
LARGE_INTEGER SourceFileOffset
LARGE_INTEGER TargetFileOffset
BOOL compression_type_changed
BITMAPINFOHEADER bmiHeader
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
#define RtlZeroMemory(Destination, Length)
static GLenum _GLUfuncptr fn
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
DWORD WINAPI GetLastError(void)
#define ERROR_FILE_EXISTS
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI InsertMenuW(_In_ HMENU, _In_ UINT, _In_ UINT, _In_ UINT_PTR, _In_opt_ LPCWSTR)
#define IS_INTRESOURCE(i)
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
BOOL WINAPI CloseClipboard(void)
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
HANDLE WINAPI GetClipboardData(_In_ UINT)
HDC WINAPI GetDC(_In_opt_ HWND)
#define MAKEINTRESOURCEW(i)
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
BOOL WINAPI InsertMenuItemW(_In_ HMENU, _In_ UINT, _In_ BOOL, _In_ LPCMENUITEMINFOW)
struct tagMENUITEMINFOW MENUITEMINFOW