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);   }  
 
27
28
29
 
30
 
27
28
29
30
31
@@ -27,4 +27,5 @@
 #include <atlwin.h>  #include <atlstr.h>  #include <atlcoll.h> +#include <atlfile.h>  #include <shlobj.h>