88{
101
102
110
115 DWORD dwMoveFlags = 0;
116 DWORD dwMoveStatusFlags = 0;
117
119 {
120#if 0
121 ConOutPuts (
_T(
"Moves files and renames files and directories.\n\n"
122 "To move one or more files:\n"
123 "MOVE [/N][/Y|/-Y][drive:][path]filename1[,...] destination\n"
124 "\n"
125 "To rename a directory:\n"
126 "MOVE [/N][/Y|/-Y][drive:][path]dirname1 dirname2\n"
127 "\n"
128 " [drive:][path]filename1 Specifies the location and name of the file\n"
129 " or files you want to move.\n"
130 " /N Nothing. Don everthing but move files or directories.\n"
131 " /Y\n"
132 " /-Y\n"
133 "..."));
134#else
136#endif
137 return 0;
138 }
139
142
143
145 {
152 else
153 break;
154 }
156
157 if (nFiles < 1)
158 {
159
162 goto Quit;
163 }
164
165 if (nFiles > 2)
166 {
167
170 goto Quit;
171 }
172
173
174 pszDest = (nFiles == 1) ?
_T(
".") :
arg[
i + 1];
175
176
178 {
179
182 goto Quit;
183 }
185 {
187 }
188
189
192
193
198
201 {
204 goto Quit;
205 }
206
207
209 while(FoundFile &&
210 (
_tcscmp(findBuffer.cFileName,
_T(
".")) == 0 ||
211 _tcscmp(findBuffer.cFileName,
_T(
"..")) == 0))
213
214 if (!FoundFile)
215 {
216
220 goto Quit;
221 }
222
224
227 else
230 {
232 {
235 else
236 {
238 dwMoveStatusFlags &= ~MOVE_SOURCE_IS_DIR;
239 }
240 }
241 }
243
244 TRACE (
"Do we have only one file: %s\n", OnlyOneFile ?
"TRUE" :
"FALSE");
245
246
249 {
252 goto Quit;
253 }
254
255
257 while(FoundFile &&
258 (
_tcscmp(findBuffer.cFileName,
_T(
".")) == 0 ||
259 _tcscmp(findBuffer.cFileName,
_T(
"..")) == 0))
261
262 if (!FoundFile)
263 {
264
268 goto Quit;
269 }
270
271
272 if (szSrcDirPath[0] != szDestPath[0])
274
275
276 do
277 {
279 nOverwrite = 1;
280 dwMoveFlags = 0;
281 dwMoveStatusFlags &= ~MOVE_DEST_IS_FILE &
282 ~MOVE_DEST_IS_DIR &
283 ~MOVE_SRC_CURRENT_IS_DIR &
284 ~MOVE_DEST_EXISTS;
285 _tcscpy(szFullSrcPath,szSrcDirPath);
286 if (szFullSrcPath[
_tcslen(szFullSrcPath) - 1] !=
_T(
'\\'))
288 _tcscat(szFullSrcPath,findBuffer.cFileName);
289 _tcscpy(szSrcPath, szFullSrcPath);
290
292 {
293
295 {
297 continue;
298 }
301 }
302
303
305 {
306
308
310
311
312 _tcscpy (szFullDestPath, szDestPath);
313
314 if (szFullDestPath[
_tcslen(szFullDestPath) - 1] !=
_T(
'\\'))
316 _tcscat (szFullDestPath, findBuffer.cFileName);
317
320
322 }
324 {
325
327
329 _tcscpy (szFullDestPath, szDestPath);
330
332 }
333
334 TRACE (
"Move Status Flags: 0x%X\n",dwMoveStatusFlags);
335
339 {
340
344 goto Quit;
345 }
347 {
348
349 _tcscpy (szFullDestPath, szDestPath);
352
354 }
355
358 !OnlyOneFile)
359 {
360
364 goto Quit;
365 }
366
367
370 continue;
375 continue;
378
380
381
383 continue;
384
385
388
389 MoveStatus =
MoveFileEx (szSrcPath, szFullDestPath, dwMoveFlags);
390 else
391 {
392 _tcscpy(szMoveDest, szFullDestPath);
396 if (MoveStatus)
397 {
400 nDirLevel = 0;
401 pszDestDirPointer = szMoveDest +
_tcslen(szMoveDest);
402 pszSrcDirPointer = szMoveSrc +
_tcslen(szMoveSrc);
407 else
408 {
412 while(FoundFile)
413 {
414 if (FirstTime)
416 else
418
419 if (!FoundFile)
420 {
421
423 (pszSrcDirPointer)--;
424 (pszDestDirPointer)--;
427 if (nDirLevel > 0)
428 {
431
433 nDirLevel--;
437 pszSrcDirPointer = pszSrcDirPointer - nDiff;
441 pszDestDirPointer = pszDestDirPointer - nDiff;
443 if (szMoveSrc[
_tcslen(szMoveSrc) - 1] !=
_T(
'\\'))
445 if (szMoveDest[
_tcslen(szMoveDest) - 1] !=
_T(
'\\'))
447 pszDestDirPointer = szMoveDest +
_tcslen(szMoveDest);
448 pszSrcDirPointer = szMoveSrc +
_tcslen(szMoveSrc);
452 continue;
454 }
455 else
456 {
459 }
460 continue;
461 }
462
463
464 if (
_tcscmp(findDestBuffer.cFileName,
_T(
".")) == 0 ||
465 _tcscmp(findDestBuffer.cFileName,
_T(
"..")) == 0)
466 continue;
467
468 _tcscpy(pszSrcDirPointer, findDestBuffer.cFileName);
469 _tcscpy(pszDestDirPointer, findDestBuffer.cFileName);
471 {
473 if (!FoundFile) continue;
475 }
476 else
477 {
482 nDirLevel++;
483 pszDestDirPointer = szMoveDest +
_tcslen(szMoveDest);
484 pszSrcDirPointer = szMoveSrc +
_tcslen(szMoveSrc);
488 {
490 continue;
491 }
493 }
494 }
495 }
496 }
497 }
498
499 if (MoveStatus)
500 {
502 }
503 else
504 {
507 }
508 }
513
516
517Quit:
520}
static VOID ErrorMessage(_In_ DWORD dwErrorCode, _In_opt_ PCWSTR pszMsg,...)
VOID error_too_many_parameters(PCTSTR s)
VOID error_file_not_found(VOID)
VOID error_req_param_missing(VOID)
LPTSTR * splitspace(LPTSTR, LPINT)
VOID error_syntax(PCTSTR s)
VOID error_invalid_parameter_format(PCTSTR s)
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
#define ConOutPrintf(szStr,...)
#define ConOutPuts(szStr)
void GetDirectory(LPTSTR wholepath, LPTSTR directory, BOOL CheckExisting)
static INT MoveOverwrite(LPTSTR fn)
#define STRING_MOVE_HELP2
#define STRING_MOVE_ERROR2
#define STRING_MOVE_ERROR1
static VOID freep(LPSTR *p)
#define INVALID_HANDLE_VALUE
BOOL WINAPI FindClose(HANDLE hFindFile)
#define MOVEFILE_WRITE_THROUGH
#define MOVEFILE_REPLACE_EXISTING
#define MOVEFILE_COPY_ALLOWED
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
static char szTempPath[MAX_PATH]
#define FILE_ATTRIBUTE_DIRECTORY
BOOL IsExistingDirectory(IN LPCTSTR pszPath)
BOOL IsExistingFile(IN LPCTSTR pszPath)
#define ConOutResPrintf(uID,...)
DWORD WINAPI GetLastError(void)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags