Index: src/common/FileSupport.cpp =================================================================== diff -u -N --- src/common/FileSupport.cpp (revision 0) +++ src/common/FileSupport.cpp (revision ce5a87f4daca41daeb018a27e9ecdd353fb80c1e) @@ -0,0 +1,143 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "wtypes.h" +#include "FileSupport.h" +//#include "tchar.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#pragma warning (disable: 4711) + +__int64 SetFilePointer64(HANDLE hFile, __int64 llDistance, DWORD dwMoveMethod) +{ + LARGE_INTEGER li; + + li.QuadPart = llDistance; + + li.LowPart = SetFilePointer(hFile, li.LowPart, &li.HighPart, dwMoveMethod); + + if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) + li.QuadPart = -1; + + return li.QuadPart; +} + +__int64 GetFilePointer64(HANDLE hFile) +{ + return SetFilePointer64(hFile, 0, FILE_CURRENT); +} + +__int64 GetFileSize64(HANDLE hFile) +{ + ULARGE_INTEGER li; + + li.LowPart = GetFileSize(hFile, &li.HighPart); + + // If we failed ... + if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) + li.QuadPart=static_cast(-1); + + return li.QuadPart; +} + +bool SetFileSize64(LPCTSTR lpszFilename, __int64 llSize) +{ + HANDLE hFile=CreateFile(lpszFilename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) + return false; + + if (SetFilePointer64(hFile, llSize, FILE_BEGIN) == -1) + { + CloseHandle(hFile); + return false; + } + + if (!SetEndOfFile(hFile)) + { + CloseHandle(hFile); + return false; + } + + if (!CloseHandle(hFile)) + return false; + + return true; +} + +// disk support routines + +bool GetDynamicFreeSpace(LPCTSTR lpszPath, __int64* pFree, __int64* pTotal) +{ + typedef BOOL(__stdcall *PGETDISKFREESPACEEX)(LPCTSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes); + + ULARGE_INTEGER ui64Available, ui64Total; + PGETDISKFREESPACEEX pGetDiskFreeSpaceEx; + pGetDiskFreeSpaceEx = (PGETDISKFREESPACEEX)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), _T("GetDiskFreeSpaceExA")); + if (pGetDiskFreeSpaceEx) + { + if (!pGetDiskFreeSpaceEx(lpszPath, &ui64Available, &ui64Total, NULL)) + { + if (pFree) + *pFree=-1; + if (pTotal) + *pTotal=-1; + return false; + } + else + { + if (pFree) + *pFree=ui64Available.QuadPart; + if (pTotal) + *pTotal=ui64Total.QuadPart; + return true; + } + } + else + { + // support for win95 (not osr2) + // set the root for path and correct '\\' at the end + TCHAR szDisk[_MAX_DRIVE]; + _tsplitpath(lpszPath, szDisk, NULL, NULL, NULL); + if (_tcslen(szDisk) != 0 && szDisk[_tcslen(szDisk)-1] != _T('\\')) + _tcscat(szDisk, _T("\\")); + + // std func + DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters; + if (!GetDiskFreeSpace(szDisk, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters)) + { + if (pFree) + *pFree=-1; + if (pTotal) + *pTotal=-1; + return false; + } + else + { + if (pFree) + *pFree=((__int64)dwFreeClusters*(__int64)dwSectPerClust)*(__int64)dwBytesPerSect; + if (pTotal) + *pTotal=((__int64)dwTotalClusters*(__int64)dwSectPerClust)*(__int64)dwBytesPerSect; + return true; + } + } +} Index: common/FileSupport.cpp =================================================================== diff -u -N --- common/FileSupport.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ common/FileSupport.cpp (revision 0) @@ -1,143 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "wtypes.h" -#include "FileSupport.h" -//#include "tchar.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#pragma warning (disable: 4711) - -__int64 SetFilePointer64(HANDLE hFile, __int64 llDistance, DWORD dwMoveMethod) -{ - LARGE_INTEGER li; - - li.QuadPart = llDistance; - - li.LowPart = SetFilePointer(hFile, li.LowPart, &li.HighPart, dwMoveMethod); - - if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) - li.QuadPart = -1; - - return li.QuadPart; -} - -__int64 GetFilePointer64(HANDLE hFile) -{ - return SetFilePointer64(hFile, 0, FILE_CURRENT); -} - -__int64 GetFileSize64(HANDLE hFile) -{ - ULARGE_INTEGER li; - - li.LowPart = GetFileSize(hFile, &li.HighPart); - - // If we failed ... - if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) - li.QuadPart=static_cast(-1); - - return li.QuadPart; -} - -bool SetFileSize64(LPCTSTR lpszFilename, __int64 llSize) -{ - HANDLE hFile=CreateFile(lpszFilename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) - return false; - - if (SetFilePointer64(hFile, llSize, FILE_BEGIN) == -1) - { - CloseHandle(hFile); - return false; - } - - if (!SetEndOfFile(hFile)) - { - CloseHandle(hFile); - return false; - } - - if (!CloseHandle(hFile)) - return false; - - return true; -} - -// disk support routines - -bool GetDynamicFreeSpace(LPCTSTR lpszPath, __int64* pFree, __int64* pTotal) -{ - typedef BOOL(__stdcall *PGETDISKFREESPACEEX)(LPCTSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes); - - ULARGE_INTEGER ui64Available, ui64Total; - PGETDISKFREESPACEEX pGetDiskFreeSpaceEx; - pGetDiskFreeSpaceEx = (PGETDISKFREESPACEEX)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), _T("GetDiskFreeSpaceExA")); - if (pGetDiskFreeSpaceEx) - { - if (!pGetDiskFreeSpaceEx(lpszPath, &ui64Available, &ui64Total, NULL)) - { - if (pFree) - *pFree=-1; - if (pTotal) - *pTotal=-1; - return false; - } - else - { - if (pFree) - *pFree=ui64Available.QuadPart; - if (pTotal) - *pTotal=ui64Total.QuadPart; - return true; - } - } - else - { - // support for win95 (not osr2) - // set the root for path and correct '\\' at the end - TCHAR szDisk[_MAX_DRIVE]; - _tsplitpath(lpszPath, szDisk, NULL, NULL, NULL); - if (_tcslen(szDisk) != 0 && szDisk[_tcslen(szDisk)-1] != _T('\\')) - _tcscat(szDisk, _T("\\")); - - // std func - DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters; - if (!GetDiskFreeSpace(szDisk, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters)) - { - if (pFree) - *pFree=-1; - if (pTotal) - *pTotal=-1; - return false; - } - else - { - if (pFree) - *pFree=((__int64)dwFreeClusters*(__int64)dwSectPerClust)*(__int64)dwBytesPerSect; - if (pTotal) - *pTotal=((__int64)dwTotalClusters*(__int64)dwSectPerClust)*(__int64)dwBytesPerSect; - return true; - } - } -} Index: src/common/FileSupport.h =================================================================== diff -u -N --- src/common/FileSupport.h (revision 0) +++ src/common/FileSupport.h (revision ce5a87f4daca41daeb018a27e9ecdd353fb80c1e) @@ -0,0 +1,32 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __FILESUPPORT_ROUTINES_H__ +#define __FILESUPPORT_ROUTINES_H__ + +// file support routines +__int64 SetFilePointer64(HANDLE hFile, __int64 llDistance, DWORD dwMoveMethod); +__int64 GetFilePointer64(HANDLE hFile); +__int64 GetFileSize64(HANDLE hFile); +bool SetFileSize64(LPCTSTR lpszFilename, __int64 llSize); + +// disk support routines +bool GetDynamicFreeSpace(LPCTSTR lpszPath, __int64* pFree, __int64* pTotal); + +#endif \ No newline at end of file Index: common/FileSupport.h =================================================================== diff -u -N --- common/FileSupport.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ common/FileSupport.h (revision 0) @@ -1,32 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __FILESUPPORT_ROUTINES_H__ -#define __FILESUPPORT_ROUTINES_H__ - -// file support routines -__int64 SetFilePointer64(HANDLE hFile, __int64 llDistance, DWORD dwMoveMethod); -__int64 GetFilePointer64(HANDLE hFile); -__int64 GetFileSize64(HANDLE hFile); -bool SetFileSize64(LPCTSTR lpszFilename, __int64 llSize); - -// disk support routines -bool GetDynamicFreeSpace(LPCTSTR lpszPath, __int64* pFree, __int64* pTotal); - -#endif \ No newline at end of file Index: src/common/ipcstructs.h =================================================================== diff -u -N --- src/common/ipcstructs.h (revision 0) +++ src/common/ipcstructs.h (revision ce5a87f4daca41daeb018a27e9ecdd353fb80c1e) @@ -0,0 +1,81 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __SHAREDDATA_H__ +#define __SHAREDDATA_H__ + +// drag&drop flags +#define OPERATION_MASK 0x00ffffff +#define DD_COPY_FLAG 0x00000001 +#define DD_MOVE_FLAG 0x00000002 +#define DD_COPYMOVESPECIAL_FLAG 0x00000004 + +#define EC_PASTE_FLAG 0x00000010 +#define EC_PASTESPECIAL_FLAG 0x00000020 +#define EC_COPYTO_FLAG 0x00000040 +#define EC_MOVETO_FLAG 0x00000080 +#define EC_COPYMOVETOSPECIAL_FLAG 0x00000100 + +// messages used +#define WM_GETCONFIG WM_USER+20 + +// config type to get from program +#define GC_DRAGDROP 0x00 +#define GC_EXPLORER 0x01 + +// command properties (used in menu displaying) +#pragma pack(push, 1) +struct _COMMAND +{ + UINT uiCommandID; // command ID - would be send be + TCHAR szCommand[128]; // command name + TCHAR szDesc[128]; // and it's description +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct _SHORTCUT +{ + TCHAR szName[128]; + TCHAR szPath[_MAX_PATH]; +}; +#pragma pack(pop) + +// shared memory size in bytes +#define SHARED_BUFFERSIZE 65536 + +// structure used for passing data from program to DLL +// the rest is a dynamic texts +class CSharedConfigStruct +{ +public: + UINT uiFlags; // what items and how to display in drag&drop ctx menu & explorer.ctx.menu + + bool bShowFreeSpace; // showthe free space by the shortcuts ? + TCHAR szSizes[6][64]; // names of the kB, GB, ... + bool bShowShortcutIcons; // show shell icons with shortcuts ? + bool bOverrideDefault; // only for d&d - want to change menu default item to the one from ch ? + UINT uiDefaultAction; // default action for drag&drop when using above option + int iCommandCount; // count of commands stored at the beginning of a buffer + int iShortcutsCount; // count of shortcuts to display in submenus + + TCHAR szData[SHARED_BUFFERSIZE]; // buffer for texts and other stuff +}; + +#endif Index: common/ipcstructs.h =================================================================== diff -u -N --- common/ipcstructs.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ common/ipcstructs.h (revision 0) @@ -1,81 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __SHAREDDATA_H__ -#define __SHAREDDATA_H__ - -// drag&drop flags -#define OPERATION_MASK 0x00ffffff -#define DD_COPY_FLAG 0x00000001 -#define DD_MOVE_FLAG 0x00000002 -#define DD_COPYMOVESPECIAL_FLAG 0x00000004 - -#define EC_PASTE_FLAG 0x00000010 -#define EC_PASTESPECIAL_FLAG 0x00000020 -#define EC_COPYTO_FLAG 0x00000040 -#define EC_MOVETO_FLAG 0x00000080 -#define EC_COPYMOVETOSPECIAL_FLAG 0x00000100 - -// messages used -#define WM_GETCONFIG WM_USER+20 - -// config type to get from program -#define GC_DRAGDROP 0x00 -#define GC_EXPLORER 0x01 - -// command properties (used in menu displaying) -#pragma pack(push, 1) -struct _COMMAND -{ - UINT uiCommandID; // command ID - would be send be - TCHAR szCommand[128]; // command name - TCHAR szDesc[128]; // and it's description -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct _SHORTCUT -{ - TCHAR szName[128]; - TCHAR szPath[_MAX_PATH]; -}; -#pragma pack(pop) - -// shared memory size in bytes -#define SHARED_BUFFERSIZE 65536 - -// structure used for passing data from program to DLL -// the rest is a dynamic texts -class CSharedConfigStruct -{ -public: - UINT uiFlags; // what items and how to display in drag&drop ctx menu & explorer.ctx.menu - - bool bShowFreeSpace; // showthe free space by the shortcuts ? - TCHAR szSizes[6][64]; // names of the kB, GB, ... - bool bShowShortcutIcons; // show shell icons with shortcuts ? - bool bOverrideDefault; // only for d&d - want to change menu default item to the one from ch ? - UINT uiDefaultAction; // default action for drag&drop when using above option - int iCommandCount; // count of commands stored at the beginning of a buffer - int iShortcutsCount; // count of shortcuts to display in submenus - - TCHAR szData[SHARED_BUFFERSIZE]; // buffer for texts and other stuff -}; - -#endif