Clone
ixen <ixen@copyhandler.com>
committed
on 13 Oct 10
Refactoring: got rid of the CClipboardArray and CClipboardEntry in favor of TBasePathDataContainer and TBasePathData objects which are linke… Show more
Refactoring: got rid of the CClipboardArray and CClipboardEntry in favor of TBasePathDataContainer and TBasePathData objects which are linked to input paths only by index (instead of being itself a copy of the input path with some additions).

Show less

LoggerImprovements + 5 more
src/ch/Device IO.h (+2 -3)
3 3 *   ixen@copyhandler.com                                                  *
4 4 *                                                                         *
5 5 *   This program is free software; you can redistribute it and/or modify  *
6 6 *   it under the terms of the GNU Library General Public License          *
7 7 *   (version 2) as published by the Free Software Foundation;             *
8 8 *                                                                         *
9 9 *   This program is distributed in the hope that it will be useful,       *
10 10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11 11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12 12 *   GNU General Public License for more details.                          *
13 13 *                                                                         *
14 14 *   You should have received a copy of the GNU Library General Public     *
15 15 *   License along with this program; if not, write to the                 *
16 16 *   Free Software Foundation, Inc.,                                       *
17 17 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18 18 ***************************************************************************/
19 19 #ifndef __DEVICEIO_H__
20 20 #define __DEVICEIO_H__
21 21
22 22 // only NT
23   bool GetSignature(LPCTSTR lpszDrive, LPTSTR lpszBuffer, int iSize)
  23 static bool GetSignature(LPCTSTR lpszDrive, LPTSTR lpszBuffer, int iSize)
24 24 {
25 25         std::auto_ptr<TCHAR> szMapping(new TCHAR[1024]);
26 26         std::auto_ptr<TCHAR> szQuery(new TCHAR[16384]);
27 27         std::auto_ptr<TCHAR> szSymbolic(new TCHAR[1024]);
28 28
29 29         // read mappings
30 30         if (QueryDosDevice(lpszDrive, szMapping.get(), 1024) == 0)
31 31                 return false;
32 32
33 33         // search for all, to find out in which string is the signature
34 34         DWORD dwCount, dwCount2;
35 35         if ((dwCount=QueryDosDevice(NULL, szQuery.get(), 16384)) == 0)
36 36         {
37 37                 TRACE("Encountered error #%lu @QueryDosDevice\n", GetLastError());
38 38                 return false;
39 39         }
40 40
41 41         DWORD dwOffset = 0, dwOffset2 = 0;
42 42         TCHAR* pszSignature = NULL;
43 43         TCHAR* pszOffset = NULL;
 
71 71                         {
72 72                                 // compare szSymbolic+dwOffset2 with szMapping
73 73                                 if (_tcscmp(szMapping.get(), szSymbolic.get() + dwOffset2) == 0)
74 74                                 {
75 75                                         // found Signature & Offset - copy
76 76                                         int iCnt=reinterpret_cast<int>(pszOffset)-reinterpret_cast<int>(pszSignature)+1;
77 77                                         _tcsncpy(lpszBuffer, pszSignature, (iCnt > iSize) ? iSize : iCnt);
78 78                                         return true;
79 79                                 }
80 80
81 81                                 dwOffset2 += boost::numeric_cast<DWORD>(_tcslen(szSymbolic.get()) + 1);
82 82                         }
83 83                 }
84 84
85 85                 dwOffset += boost::numeric_cast<DWORD>(_tcslen(szQuery.get() + dwOffset) + 1);
86 86         }
87 87
88 88         return false;
89 89 }
90 90
91   // at 9x function checks int13h devices and at NT within symbolic links
92   bool IsSamePhysicalDisk(int iDrvNum1, int iDrvNum2)
  91 static bool IsSamePhysicalDisk(int iDrvNum1, int iDrvNum2)
93 92 {
94 93         OSVERSIONINFO osvi;
95 94         osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
96 95
97 96         GetVersionEx(&osvi);
98 97         if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
99 98         {
100 99                 TCHAR drv1[3], drv2[3];
101 100                 
102 101                 drv1[0]=static_cast<TCHAR>(iDrvNum1+_T('A'));
103 102                 drv1[1]=_T(':');
104 103                 drv1[2]=_T('\0');
105 104                 drv2[0]=static_cast<TCHAR>(iDrvNum2+_T('A'));
106 105                 drv2[1]=_T(':');
107 106                 drv2[2]=_T('\0');
108 107                 
109 108                 TCHAR szSign1[512], szSign2[512];
110 109                 return (GetSignature(drv1, szSign1, 512) && GetSignature(drv2, szSign2, 512) && _tcscmp(szSign1, szSign2) == 0);
111 110         }
112 111