Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek shellext: perform file I/O using CAtlFile, part 1

Changeset ef6ea1af6f56

Parent 7654159f827b

by David Golub

Changes to 2 files · Browse files at ef6ea1af6f56 Showing diff from parent 7654159f827b Diff from another changeset...

 
106
107
108
109
110
111
112
 
 
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 
 
127
128
129
130
131
132
 
 
133
134
135
 
136
137
138
 
106
107
108
 
 
 
 
109
110
111
112
113
114
115
116
 
117
118
119
120
121
 
 
122
123
124
125
126
127
 
 
128
129
130
131
 
132
133
134
135
@@ -106,33 +106,30 @@
  }     ATLTRACE("RunDialog: temp file = %s\n", (LPCTSTR)strTempFile); - HANDLE hTempFile = ::CreateFile(strTempFile, GENERIC_WRITE, FILE_SHARE_READ, 0, - CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - - if (hTempFile == INVALID_HANDLE_VALUE) + CAtlFile file; + if (FAILED(file.Create(strTempFile, GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS)))   {   ATLTRACE("***** RunDialog: error: failed to create file '%s'\n",   (LPCTSTR)strTempFile);   return;   }   - DWORD dwWritten;   POSITION position = listFiles.GetHeadPosition();   while (position != NULL)   {   CString strFile = listFiles.GetNext(position);   ATLTRACE("RunDialog: temp file adding '%s'\n", (LPCTSTR)strFile); - ::WriteFile(hTempFile, (LPCTSTR)strFile, strFile.GetLength(), &dwWritten, 0); - ::WriteFile(hTempFile, "\n", 1, &dwWritten, 0); + file.Write((LPCTSTR)strFile, strFile.GetLength()); + file.Write("\n", 1);   }   if (strCmd == "drag_move" || strCmd == "drag_copy")   {   // Append the current directory as the dest. - ::WriteFile(hTempFile, (LPCTSTR)strCwd, strCwd.GetLength(), &dwWritten, 0); - ::WriteFile(hTempFile, "\n", 1, &dwWritten, 0); + file.Write((LPCTSTR)strCwd, strCwd.GetLength()); + file.Write("\n", 1);   }   - ::CloseHandle(hTempFile); + file.Close();   strHgCmd += " --listfile " + Quote(strTempFile);   }  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 // Copyright (C) 2011 Fog Creek Software  //  // 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, see <http://www.gnu.org/licenses/>.    #pragma once    // WINVER must be defined as at least 0x0500 in order to have access to the hbmpItem  // member in MENUITEMINFO.  #define WINVER 0x0500    #include "resource.h"    #include <atlbase.h>  extern CComModule _Module;  #include <atlcom.h>  #include <atlwin.h>  #include <atlstr.h>  #include <atlcoll.h> +#include <atlfile.h>  #include <shlobj.h>