Fix whitespace (part 4/x) (convert tabs into 4-space indent).

svn path=/trunk/; revision=59383
This commit is contained in:
Hermès Bélusca-Maïto 2013-06-30 12:27:18 +00:00
parent 16ca7b2a1d
commit 3f69dc1614
10 changed files with 3077 additions and 3168 deletions

View file

@ -189,25 +189,21 @@ typedef struct _DirSwitchesFlags
} stTimeField; /* The time field to display or use for sorting */ } stTimeField; /* The time field to display or use for sorting */
} DIRSWITCHFLAGS, *LPDIRSWITCHFLAGS; } DIRSWITCHFLAGS, *LPDIRSWITCHFLAGS;
typedef struct _DIRFINDLISTNODE typedef struct _DIRFINDLISTNODE
{ {
WIN32_FIND_DATA stFindInfo; WIN32_FIND_DATA stFindInfo;
struct _DIRFINDLISTNODE *ptrNext; struct _DIRFINDLISTNODE *ptrNext;
} DIRFINDLISTNODE, *PDIRFINDLISTNODE; } DIRFINDLISTNODE, *PDIRFINDLISTNODE;
typedef BOOL typedef BOOL
(WINAPI *PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); (WINAPI *PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
/* Globally save the # of dirs, files and bytes, /* Globally save the # of dirs, files and bytes,
* probabaly later pass them to functions. Rob Lake */ * probabaly later pass them to functions. Rob Lake */
static ULONG recurse_dir_cnt; static ULONG recurse_dir_cnt;
static ULONG recurse_file_cnt; static ULONG recurse_file_cnt;
static ULONGLONG recurse_bytes; static ULONGLONG recurse_bytes;
/* /*
* help * help
* *
@ -220,8 +216,6 @@ DirHelp(VOID)
ConOutResPaging(TRUE, STRING_DIR_HELP1); ConOutResPaging(TRUE, STRING_DIR_HELP1);
} }
/* /*
* DirReadParameters * DirReadParameters
* *
@ -585,7 +579,7 @@ PrintDirectoryHeader(LPTSTR szPath, LPDIRSWITCHFLAGS lpFlags)
!GetVolumeInformation(szRootName, szVolName, 80, &dwSerialNr, !GetVolumeInformation(szRootName, szVolName, 80, &dwSerialNr,
NULL, NULL, NULL, 0)) NULL, NULL, NULL, 0))
{ {
return(TRUE); return TRUE;
} }
/* print drive info */ /* print drive info */
@ -738,7 +732,6 @@ GetUserDiskFreeSpace(LPCTSTR lpRoot,
* print_summary: prints dir summary * print_summary: prints dir summary
* Added by Rob Lake 06/17/98 to compact code * Added by Rob Lake 06/17/98 to compact code
* Just copied Tim's Code and patched it a bit * Just copied Tim's Code and patched it a bit
*
*/ */
static INT static INT
PrintSummary(LPTSTR szPath, PrintSummary(LPTSTR szPath,
@ -752,7 +745,6 @@ PrintSummary(LPTSTR szPath,
TCHAR szBuffer[64]; TCHAR szBuffer[64];
ULARGE_INTEGER uliFree; ULARGE_INTEGER uliFree;
/* Here we check if we didn't find anything */ /* Here we check if we didn't find anything */
if (!(ulFiles + ulDirs)) if (!(ulFiles + ulDirs))
{ {
@ -761,7 +753,6 @@ PrintSummary(LPTSTR szPath,
return 1; return 1;
} }
/* In bare format we don't print results */ /* In bare format we don't print results */
if (lpFlags->bBareFormat) if (lpFlags->bBareFormat)
return 0; return 0;
@ -834,7 +825,6 @@ getName(const TCHAR* file, TCHAR * dest)
else else
iLen = (end - file); iLen = (end - file);
_tcsncpy(dest, file, iLen); _tcsncpy(dest, file, iLen);
*(dest + iLen) = _T('\0'); *(dest + iLen) = _T('\0');
@ -951,8 +941,7 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
iColumns --; iColumns --;
/* A last check at iColumns to avoid division by zero */ /* A last check at iColumns to avoid division by zero */
if (!(iColumns)) if (!iColumns) iColumns = 1;
iColumns = 1;
/* Calculate the lines that will be printed */ /* Calculate the lines that will be printed */
iLines = (USHORT)((dwCount + iColumns - 1) / iColumns); iLines = (USHORT)((dwCount + iColumns - 1) / iColumns);
@ -972,8 +961,7 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
temp = (i * iColumns) + j; temp = (i * iColumns) + j;
} }
if (temp >= dwCount) if (temp >= dwCount) break;
break;
if (ptrFiles[temp]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (ptrFiles[temp]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
_stprintf(szTempFname, _T("[%s]"), ptrFiles[temp]->cFileName); _stprintf(szTempFname, _T("[%s]"), ptrFiles[temp]->cFileName);

View file

@ -197,7 +197,6 @@ VOID CompleteFilename (LPTSTR str, UINT charcount)
/* /*
* returns 1 if at least one match, else returns 0 * returns 1 if at least one match, else returns 0
*/ */
BOOL ShowCompletionMatches (LPTSTR str, INT charcount) BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
{ {
WIN32_FIND_DATA file; WIN32_FIND_DATA file;
@ -381,8 +380,10 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
/* Count number of " */ /* Count number of " */
for(i = 0; i < _tcslen(str); i++) for(i = 0; i < _tcslen(str); i++)
{
if(str[i] == _T('\"')) if(str[i] == _T('\"'))
nQuotes++; nQuotes++;
}
/* Find the prefix and suffix */ /* Find the prefix and suffix */
if(nQuotes % 2 && nQuotes >= 1) if(nQuotes % 2 && nQuotes >= 1)
@ -465,7 +466,6 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
SBreak = i; SBreak = i;
if((str[i] == _T(' ') || str[i] == _T('\\')) && !bInside) if((str[i] == _T(' ') || str[i] == _T('\\')) && !bInside)
PBreak = i; PBreak = i;
} }
SBreak++; SBreak++;
PBreak++; PBreak++;
@ -479,9 +479,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
allow the next stuff to stay inside one set of quotes allow the next stuff to stay inside one set of quotes
otherwise you would have multiple sets of quotes*/ otherwise you would have multiple sets of quotes*/
_tcscpy(&szPrefix[_tcslen(szPrefix) - 2],_T("\\")); _tcscpy(&szPrefix[_tcslen(szPrefix) - 2],_T("\\"));
} }
} }
int __cdecl compare(const void *arg1,const void *arg2) int __cdecl compare(const void *arg1,const void *arg2)
@ -756,8 +754,8 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
bInside = !bInside; bInside = !bInside;
if(szPrefix[i] == _T(' ') && !bInside) if(szPrefix[i] == _T(' ') && !bInside)
LastSpace = i; LastSpace = i;
} }
/* insert the quotation and move things around */ /* insert the quotation and move things around */
if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1) if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
{ {
@ -788,9 +786,11 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
if(!NeededQuote) if(!NeededQuote)
{ {
for(i = 0; i < _tcslen(strOut); i++) for(i = 0; i < _tcslen(strOut); i++)
{
if(strOut[i] == _T('\"')) if(strOut[i] == _T('\"'))
NeededQuote = !NeededQuote; NeededQuote = !NeededQuote;
} }
}
if(szPrefix[_tcslen(szPrefix) - 1] == _T('\"') || NeededQuote) if(szPrefix[_tcslen(szPrefix) - 1] == _T('\"') || NeededQuote)
_tcscat(strOut,_T("\"")); _tcscat(strOut,_T("\""));
@ -800,6 +800,5 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
//DiffLength = EndLength - StartLength; //DiffLength = EndLength - StartLength;
if(FileList != NULL) if(FileList != NULL)
cmd_free(FileList); cmd_free(FileList);
} }
#endif #endif

View file

@ -48,18 +48,13 @@ typedef struct tagHISTORY
LPTSTR string; LPTSTR string;
} HIST_ENTRY, * LPHIST_ENTRY; } HIST_ENTRY, * LPHIST_ENTRY;
static INT size, static INT size, max_size=100;
max_size=100;
static LPHIST_ENTRY Top; static LPHIST_ENTRY Top;
static LPHIST_ENTRY Bottom; static LPHIST_ENTRY Bottom;
static LPHIST_ENTRY curr_ptr=0; static LPHIST_ENTRY curr_ptr=0;
VOID InitHistory(VOID); VOID InitHistory(VOID);
VOID History_move_to_bottom(VOID); VOID History_move_to_bottom(VOID);
VOID History (INT dir, LPTSTR commandline); VOID History (INT dir, LPTSTR commandline);
@ -73,7 +68,6 @@ static VOID add_at_bottom(LPTSTR string);
VOID set_size(INT new_size); VOID set_size(INT new_size);
INT CommandHistory (LPTSTR param) INT CommandHistory (LPTSTR param)
{ {
LPTSTR tmp; LPTSTR tmp;
@ -154,8 +148,6 @@ VOID InitHistory(VOID)
} }
VOID CleanHistory(VOID) VOID CleanHistory(VOID)
{ {
while (Bottom->next!=Top) while (Bottom->next!=Top)
@ -198,8 +190,6 @@ VOID del(LPHIST_ENTRY item)
return; return;
} }
/*free string's mem*/ /*free string's mem*/
if (item->string) if (item->string)
cmd_free(item->string); cmd_free(item->string);
@ -216,11 +206,8 @@ VOID del(LPHIST_ENTRY item)
static static
VOID add_at_bottom(LPTSTR string) VOID add_at_bottom(LPTSTR string)
{ {
LPHIST_ENTRY tmp; LPHIST_ENTRY tmp;
/*delete first entry if maximum number of entries is reached*/ /*delete first entry if maximum number of entries is reached*/
while(size>=max_size) while(size>=max_size)
del(Top->prev); del(Top->prev);
@ -231,13 +218,11 @@ VOID add_at_bottom(LPTSTR string)
if (*string==_T('\0')) if (*string==_T('\0'))
return; return;
/*if new entry is the same than the last do not add it*/ /*if new entry is the same than the last do not add it*/
if(size) if(size)
if(_tcscmp(string,Bottom->next->string)==0) if(_tcscmp(string,Bottom->next->string)==0)
return; return;
/*fill bottom with string, it will become Bottom->next*/ /*fill bottom with string, it will become Bottom->next*/
Bottom->string=cmd_alloc((_tcslen(string)+1)*sizeof(TCHAR)); Bottom->string=cmd_alloc((_tcslen(string)+1)*sizeof(TCHAR));
_tcscpy(Bottom->string,string); _tcscpy(Bottom->string,string);
@ -245,7 +230,6 @@ VOID add_at_bottom(LPTSTR string)
/*save Bottom value*/ /*save Bottom value*/
tmp=Bottom; tmp=Bottom;
/*create new void Bottom*/ /*create new void Bottom*/
Bottom=cmd_alloc(sizeof(HIST_ENTRY)); Bottom=cmd_alloc(sizeof(HIST_ENTRY));
Bottom->next=tmp; Bottom->next=tmp;
@ -256,15 +240,12 @@ VOID add_at_bottom(LPTSTR string)
/*set new size*/ /*set new size*/
size++; size++;
} }
VOID History_move_to_bottom(VOID) VOID History_move_to_bottom(VOID)
{ {
curr_ptr=Bottom; curr_ptr=Bottom;
} }
LPCTSTR PeekHistory(INT dir) LPCTSTR PeekHistory(INT dir)
@ -306,7 +287,6 @@ LPCTSTR PeekHistory(INT dir)
VOID History (INT dir, LPTSTR commandline) VOID History (INT dir, LPTSTR commandline)
{ {
if(dir==0) if(dir==0)
{ {
add_at_bottom(commandline); add_at_bottom(commandline);
@ -320,7 +300,6 @@ VOID History (INT dir, LPTSTR commandline)
return; return;
} }
if(dir<0)/*key up*/ if(dir<0)/*key up*/
{ {
if (curr_ptr->next==Top || curr_ptr==Top) if (curr_ptr->next==Top || curr_ptr==Top)
@ -334,20 +313,13 @@ VOID History (INT dir, LPTSTR commandline)
#endif #endif
} }
curr_ptr = curr_ptr->next; curr_ptr = curr_ptr->next;
if(curr_ptr->string) if(curr_ptr->string)
_tcscpy(commandline,curr_ptr->string); _tcscpy(commandline,curr_ptr->string);
} }
if(dir>0) if(dir>0)
{ {
if (curr_ptr->prev==Bottom || curr_ptr==Bottom) if (curr_ptr->prev==Bottom || curr_ptr==Bottom)
{ {
#ifdef WRAP_HISTORY #ifdef WRAP_HISTORY
@ -362,7 +334,6 @@ VOID History (INT dir, LPTSTR commandline)
curr_ptr=curr_ptr->prev; curr_ptr=curr_ptr->prev;
if(curr_ptr->string) if(curr_ptr->string)
_tcscpy(commandline,curr_ptr->string); _tcscpy(commandline,curr_ptr->string);
} }
} }

View file

@ -270,8 +270,6 @@ INT cmd_chdir (LPTSTR param)
#endif #endif
#ifdef INCLUDE_CMD_MKDIR #ifdef INCLUDE_CMD_MKDIR
/* Helper funtion for mkdir to make directories in a path. /* Helper funtion for mkdir to make directories in a path.
@ -301,7 +299,9 @@ MakeFullPath(TCHAR * DirPath)
path[n] = _T('\0'); path[n] = _T('\0');
if( !CreateDirectory(path, NULL) && if( !CreateDirectory(path, NULL) &&
(GetLastError() != ERROR_ALREADY_EXISTS)) (GetLastError() != ERROR_ALREADY_EXISTS))
{
return FALSE; return FALSE;
}
} while (p != NULL); } while (p != NULL);
return TRUE; return TRUE;
@ -309,7 +309,6 @@ MakeFullPath(TCHAR * DirPath)
/* /*
* MD / MKDIR * MD / MKDIR
*
*/ */
INT cmd_mkdir (LPTSTR param) INT cmd_mkdir (LPTSTR param)
{ {
@ -356,7 +355,6 @@ INT cmd_mkdir (LPTSTR param)
#ifdef INCLUDE_CMD_RMDIR #ifdef INCLUDE_CMD_RMDIR
/* /*
* RD / RMDIR * RD / RMDIR
*
*/ */
BOOL DeleteFolder(LPTSTR FileName) BOOL DeleteFolder(LPTSTR FileName)
{ {
@ -392,6 +390,7 @@ BOOL DeleteFolder(LPTSTR FileName)
} }
return RemoveDirectory(FileName); return RemoveDirectory(FileName);
} }
INT cmd_rmdir (LPTSTR param) INT cmd_rmdir (LPTSTR param)
{ {
TCHAR ch; TCHAR ch;
@ -497,7 +496,6 @@ INT cmd_rmdir (LPTSTR param)
/* /*
* set the exitflag to true * set the exitflag to true
*
*/ */
INT CommandExit (LPTSTR param) INT CommandExit (LPTSTR param)
{ {
@ -519,19 +517,17 @@ INT CommandExit (LPTSTR param)
nErrorLevel = _ttoi(param); nErrorLevel = _ttoi(param);
ExitBatch(); ExitBatch();
} }
else else
{
bExit = TRUE; bExit = TRUE;
}
return 0; return 0;
} }
#ifdef INCLUDE_CMD_REM #ifdef INCLUDE_CMD_REM
/* /*
* does nothing * does nothing
*
*/ */
INT CommandRem (LPTSTR param) INT CommandRem (LPTSTR param)
{ {

View file

@ -28,8 +28,8 @@
* 06-Nov-1999 (Eric Kohl) * 06-Nov-1999 (Eric Kohl)
* Added PagePrompt() and FilePrompt(). * Added PagePrompt() and FilePrompt().
* *
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>) * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
* Remove all hardcode string to En.rc * Remove all hardcoded strings in En.rc
*/ */
#include "precomp.h" #include "precomp.h"
@ -63,9 +63,8 @@ cgetchar (VOID)
(irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_MENU) || (irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
(irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL)) (irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL))
{ {
; // Nothing to do
} }
else else
{ {
break; break;
@ -93,7 +92,6 @@ VOID GetPathCase( TCHAR * Path, TCHAR * OutPath)
_tcscpy(TempPath, _T("")); _tcscpy(TempPath, _T(""));
_tcscpy(OutPath, _T("")); _tcscpy(OutPath, _T(""));
for(i = 0; i < _tcslen(Path); i++) for(i = 0; i < _tcslen(Path); i++)
{ {
if(Path[i] != _T('\\')) if(Path[i] != _T('\\'))
@ -273,7 +271,6 @@ static BOOL expand (LPINT ac, LPTSTR **arg, LPCTSTR pattern)
* split - splits a line up into separate arguments, deliminators * split - splits a line up into separate arguments, deliminators
* are spaces and slashes ('/'). * are spaces and slashes ('/').
*/ */
LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards, BOOL handle_plus) LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards, BOOL handle_plus)
{ {
LPTSTR *arg; LPTSTR *arg;
@ -364,7 +361,8 @@ LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards, BOOL handle_plus)
return arg; return arg;
} }
/* splitspace() is a function which uses JUST spaces as delimeters. split() uses "/" AND spaces. /*
* splitspace() is a function which uses JUST spaces as delimeters. split() uses "/" AND spaces.
* The way it works is real similar to split(), search the difference ;) * The way it works is real similar to split(), search the difference ;)
* splitspace is needed for commands such as "move" where paths as C:\this/is\allowed/ are allowed * splitspace is needed for commands such as "move" where paths as C:\this/is\allowed/ are allowed
*/ */
@ -428,7 +426,6 @@ LPTSTR *splitspace (LPTSTR s, LPINT args)
/* /*
* freep -- frees memory used for a call to split * freep -- frees memory used for a call to split
*
*/ */
VOID freep (LPTSTR *p) VOID freep (LPTSTR *p)
{ {
@ -444,7 +441,6 @@ VOID freep (LPTSTR *p)
cmd_free(p); cmd_free(p);
} }
LPTSTR _stpcpy (LPTSTR dest, LPCTSTR src) LPTSTR _stpcpy (LPTSTR dest, LPCTSTR src)
{ {
_tcscpy (dest, src); _tcscpy (dest, src);
@ -464,11 +460,9 @@ StripQuotes(TCHAR *in)
} }
/* /*
* Checks if a path is valid (accessible) * Checks if a path is valid (accessible)
*/ */
BOOL IsValidPathName (LPCTSTR pszPath) BOOL IsValidPathName (LPCTSTR pszPath)
{ {
TCHAR szOldPath[MAX_PATH]; TCHAR szOldPath[MAX_PATH];
@ -486,7 +480,6 @@ BOOL IsValidPathName (LPCTSTR pszPath)
/* /*
* Checks if a file exists (accessible) * Checks if a file exists (accessible)
*/ */
BOOL IsExistingFile (LPCTSTR pszPath) BOOL IsExistingFile (LPCTSTR pszPath)
{ {
DWORD attr = GetFileAttributes (pszPath); DWORD attr = GetFileAttributes (pszPath);
@ -605,8 +598,7 @@ INT FilePromptYN (UINT resID)
return PROMPT_NO; return PROMPT_NO;
/* unfinished solution */
/* unfinished sollution */
#if 0 #if 0
RemoveBreakHandler (); RemoveBreakHandler ();
ConInDisable (); ConInDisable ();
@ -665,7 +657,6 @@ INT FilePromptYNA (UINT resID)
return PROMPT_NO; return PROMPT_NO;
else if (_tcsncmp(p, &szMsg[2], 1) == 0) else if (_tcsncmp(p, &szMsg[2], 1) == 0)
return PROMPT_ALL; return PROMPT_ALL;
#if 0 #if 0
else if (*p == _T('\03')) else if (*p == _T('\03'))
return PROMPT_BREAK; return PROMPT_BREAK;
@ -673,8 +664,7 @@ INT FilePromptYNA (UINT resID)
return PROMPT_NO; return PROMPT_NO;
/* unfinished solution */
/* unfinished sollution */
#if 0 #if 0
RemoveBreakHandler (); RemoveBreakHandler ();
ConInDisable (); ConInDisable ();

View file

@ -11,12 +11,15 @@ static BOOL CreateJunction(LPCTSTR LinkName, LPCTSTR TargetName)
{ {
/* Structure for reparse point daya when ReparseTag is one of /* Structure for reparse point daya when ReparseTag is one of
* the tags defined by Microsoft. Copied from MinGW winnt.h */ * the tags defined by Microsoft. Copied from MinGW winnt.h */
typedef struct _REPARSE_DATA_BUFFER { typedef struct _REPARSE_DATA_BUFFER
{
DWORD ReparseTag; DWORD ReparseTag;
WORD ReparseDataLength; WORD ReparseDataLength;
WORD Reserved; WORD Reserved;
_ANONYMOUS_UNION union { _ANONYMOUS_UNION union
struct { {
struct
{
WORD SubstituteNameOffset; WORD SubstituteNameOffset;
WORD SubstituteNameLength; WORD SubstituteNameLength;
WORD PrintNameOffset; WORD PrintNameOffset;
@ -24,14 +27,16 @@ static BOOL CreateJunction(LPCTSTR LinkName, LPCTSTR TargetName)
ULONG Flags; ULONG Flags;
WCHAR PathBuffer[1]; WCHAR PathBuffer[1];
} SymbolicLinkReparseBuffer; } SymbolicLinkReparseBuffer;
struct { struct
{
WORD SubstituteNameOffset; WORD SubstituteNameOffset;
WORD SubstituteNameLength; WORD SubstituteNameLength;
WORD PrintNameOffset; WORD PrintNameOffset;
WORD PrintNameLength; WORD PrintNameLength;
WCHAR PathBuffer[1]; WCHAR PathBuffer[1];
} MountPointReparseBuffer; } MountPointReparseBuffer;
struct { struct
{
BYTE DataBuffer[1]; BYTE DataBuffer[1];
} GenericReparseBuffer; } GenericReparseBuffer;
} DUMMYUNIONNAME; } DUMMYUNIONNAME;

View file

@ -41,7 +41,8 @@ enum
}; };
enum enum
{ /* Move status flags */ {
/* Move status flags */
MOVE_SOURCE_IS_DIR = 0x001, MOVE_SOURCE_IS_DIR = 0x001,
MOVE_SOURCE_IS_FILE = 0x002, MOVE_SOURCE_IS_FILE = 0x002,
MOVE_DEST_IS_DIR = 0x004, MOVE_DEST_IS_DIR = 0x004,
@ -114,7 +115,6 @@ INT cmd_move (LPTSTR param)
DWORD dwMoveFlags = 0; DWORD dwMoveFlags = 0;
DWORD dwMoveStatusFlags = 0; DWORD dwMoveStatusFlags = 0;
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
#if 0 #if 0
@ -186,7 +186,6 @@ INT cmd_move (LPTSTR param)
dwMoveStatusFlags |= MOVE_SOURCE_HAS_WILD; dwMoveStatusFlags |= MOVE_SOURCE_HAS_WILD;
} }
/* get destination */ /* get destination */
GetFullPathName (pszDest, MAX_PATH, szDestPath, NULL); GetFullPathName (pszDest, MAX_PATH, szDestPath, NULL);
TRACE ("Destination: %s\n", debugstr_aw(szDestPath)); TRACE ("Destination: %s\n", debugstr_aw(szDestPath));
@ -203,7 +202,6 @@ INT cmd_move (LPTSTR param)
ErrorMessage (GetLastError (), arg[i]); ErrorMessage (GetLastError (), arg[i]);
freep (arg); freep (arg);
return 1; return 1;
} }
/* check for special cases "." and ".." and if found skip them */ /* check for special cases "." and ".." and if found skip them */
@ -252,7 +250,6 @@ INT cmd_move (LPTSTR param)
ErrorMessage (GetLastError (), arg[i]); ErrorMessage (GetLastError (), arg[i]);
freep (arg); freep (arg);
return 1; return 1;
} }
/* check for special cases "." and ".." and if found skip them */ /* check for special cases "." and ".." and if found skip them */
@ -294,7 +291,6 @@ INT cmd_move (LPTSTR param)
if (IsExistingDirectory(szSrcPath)) if (IsExistingDirectory(szSrcPath))
{ {
/* source is directory */ /* source is directory */
if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE) if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE)
{ {
dwMoveStatusFlags |= MOVE_SRC_CURRENT_IS_DIR; /* source is file but at the current round we found a directory */ dwMoveStatusFlags |= MOVE_SRC_CURRENT_IS_DIR; /* source is file but at the current round we found a directory */
@ -305,7 +301,6 @@ INT cmd_move (LPTSTR param)
} }
/* if source is file we don't need to do anything special */ /* if source is file we don't need to do anything special */
if (IsExistingDirectory(szDestPath)) if (IsExistingDirectory(szDestPath))
{ {
/* destination is existing directory */ /* destination is existing directory */
@ -324,7 +319,6 @@ INT cmd_move (LPTSTR param)
dwMoveStatusFlags |= MOVE_DEST_EXISTS; dwMoveStatusFlags |= MOVE_DEST_EXISTS;
dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED; dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED;
} }
if (IsExistingFile(szDestPath)) if (IsExistingFile(szDestPath))
{ {
@ -335,7 +329,6 @@ INT cmd_move (LPTSTR param)
_tcscpy (szFullDestPath, szDestPath); _tcscpy (szFullDestPath, szDestPath);
dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED; dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED;
} }
TRACE ("Move Status Flags: 0x%X\n",dwMoveStatusFlags); TRACE ("Move Status Flags: 0x%X\n",dwMoveStatusFlags);
@ -350,7 +343,6 @@ INT cmd_move (LPTSTR param)
freep(arg); freep(arg);
return 1; return 1;
} }
if (!(dwMoveStatusFlags & (MOVE_DEST_IS_FILE | MOVE_DEST_IS_DIR))) if (!(dwMoveStatusFlags & (MOVE_DEST_IS_FILE | MOVE_DEST_IS_DIR)))
{ {
/* destination doesn't exist */ /* destination doesn't exist */
@ -384,7 +376,6 @@ INT cmd_move (LPTSTR param)
if (nOverwrite == PROMPT_ALL) if (nOverwrite == PROMPT_ALL)
dwFlags |= MOVE_OVER_YES; dwFlags |= MOVE_OVER_YES;
ConOutPrintf (_T("%s => %s "), szSrcPath, szFullDestPath); ConOutPrintf (_T("%s => %s "), szSrcPath, szFullDestPath);
/* are we really supposed to do something */ /* are we really supposed to do something */
@ -426,7 +417,8 @@ INT cmd_move (LPTSTR param)
FoundFile = FindNextFile (hDestFile, &findDestBuffer); FoundFile = FindNextFile (hDestFile, &findDestBuffer);
if (!FoundFile) if (!FoundFile)
{ /* Nothing to do in this folder so we stop working on it */ {
/* Nothing to do in this folder so we stop working on it */
FindClose(hDestFile); FindClose(hDestFile);
(pszSrcDirPointer)--; (pszSrcDirPointer)--;
(pszDestDirPointer)--; (pszDestDirPointer)--;

View file

@ -1,6 +1,5 @@
/* /*
* PARSER.C - command parsing. * PARSER.C - command parsing.
*
*/ */
#include "precomp.h" #include "precomp.h"

View file

@ -150,7 +150,6 @@ INT cmd_rename (LPTSTR param)
return 1; return 1;
} }
/* Get destination pattern and source pattern*/ /* Get destination pattern and source pattern*/
for (i = 0; i < args; i++) for (i = 0; i < args; i++)
{ {
@ -158,16 +157,10 @@ INT cmd_rename (LPTSTR param)
continue; continue;
dstPattern = arg[i]; //we save the Last argument as dstPattern dstPattern = arg[i]; //we save the Last argument as dstPattern
srcPattern = arg[i-1]; srcPattern = arg[i-1];
} }
if (_tcschr(srcPattern, _T('\\'))) //Checking if the Source (srcPattern) is a Path to the file if (_tcschr(srcPattern, _T('\\'))) //Checking if the Source (srcPattern) is a Path to the file
{ {
bPath= TRUE; bPath= TRUE;
//Splitting srcPath and srcFile. //Splitting srcPath and srcFile.
@ -182,8 +175,6 @@ INT cmd_rename (LPTSTR param)
} }
_tcsncpy(srcPath,srcPattern,_tcslen(srcPattern)-_tcslen(srcFILE)); _tcsncpy(srcPath,srcPattern,_tcslen(srcPattern)-_tcslen(srcFILE));
if(_tcschr(dstPattern, _T('\\'))) //Checking if the Destiny (dstPattern)is also a Path.And splitting dstPattern in dstPath and srcPath. if(_tcschr(dstPattern, _T('\\'))) //Checking if the Destiny (dstPattern)is also a Path.And splitting dstPattern in dstPath and srcPath.
{ {
dstFILE = _tcschr(dstPattern, _T('\\')); dstFILE = _tcschr(dstPattern, _T('\\'));
@ -202,16 +193,12 @@ INT cmd_rename (LPTSTR param)
freep(arg); freep(arg);
return 1; return 1;
} }
}else { //If Destiny hasnt a Path,then (MSDN says) srcPath is its Path.
_tcscpy(dstPath,srcPath);
dstFILE=dstPattern;
} }
else
{ //If Destiny hasnt a Path,then (MSDN says) srcPath is its Path.
_tcscpy(dstPath,srcPath);
dstFILE=dstPattern;
}
} }
if (!_tcschr(srcPattern, _T('\\'))) //If srcPattern isn't a Path but a name: if (!_tcschr(srcPattern, _T('\\'))) //If srcPattern isn't a Path but a name:
@ -220,18 +207,19 @@ INT cmd_rename (LPTSTR param)
if(_tcschr(dstPattern, _T('\\'))) if(_tcschr(dstPattern, _T('\\')))
{ {
error_syntax(dstPattern); error_syntax(dstPattern);
freep(arg); freep(arg);
return 1; return 1;
}else dstFILE=dstPattern; }
else
{
dstFILE=dstPattern;
}
} }
//Checking Wildcards. //Checking Wildcards.
if (_tcschr(dstFILE, _T('*')) || _tcschr(dstFILE, _T('?'))) if (_tcschr(dstFILE, _T('*')) || _tcschr(dstFILE, _T('?')))
bDstWildcard = TRUE; bDstWildcard = TRUE;
TRACE("\n\nSourcePattern: %s SourcePath: %s SourceFile: %s", debugstr_aw(srcPattern),debugstr_aw(srcPath),debugstr_aw(srcFILE)); TRACE("\n\nSourcePattern: %s SourcePath: %s SourceFile: %s", debugstr_aw(srcPattern),debugstr_aw(srcPath),debugstr_aw(srcFILE));
TRACE("\n\nDestinationPattern: %s Destination Path:%s Destination File: %s\n", debugstr_aw(dstPattern),debugstr_aw(dstPath),debugstr_aw(dstFILE)); TRACE("\n\nDestinationPattern: %s Destination Path:%s Destination File: %s\n", debugstr_aw(dstPattern),debugstr_aw(dstPath),debugstr_aw(dstFILE));
@ -239,15 +227,12 @@ INT cmd_rename (LPTSTR param)
if (hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
{ {
if (!(dwFlags & REN_ERROR)) if (!(dwFlags & REN_ERROR)) error_file_not_found();
error_file_not_found();
} }
do do
{ {
/* ignore "." and ".." */ /* ignore "." and ".." */
if (!_tcscmp (f.cFileName, _T(".")) || if (!_tcscmp (f.cFileName, _T(".")) || !_tcscmp (f.cFileName, _T("..")))
!_tcscmp (f.cFileName, _T("..")))
continue; continue;
/* do not rename hidden or system files */ /* do not rename hidden or system files */
@ -256,10 +241,11 @@ INT cmd_rename (LPTSTR param)
/* do not rename directories when the destination pattern contains /* do not rename directories when the destination pattern contains
* wildcards, unless option /S is used */ * wildcards, unless option /S is used */
if ((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if ((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
&& bDstWildcard bDstWildcard && !(dwFlags & REN_SUBDIR))
&& !(dwFlags & REN_SUBDIR)) {
continue; continue;
}
TRACE("Found source name: %s\n", debugstr_aw(f.cFileName)); TRACE("Found source name: %s\n", debugstr_aw(f.cFileName));
/* So here we have splitted the dstFILE and we have find a f.cFileName(thanks to srcPattern) /* So here we have splitted the dstFILE and we have find a f.cFileName(thanks to srcPattern)
@ -292,8 +278,7 @@ INT cmd_rename (LPTSTR param)
else else
{ {
*r = *q; *r = *q;
if (*p != 0) if (*p != 0) p++;
p++;
q++; q++;
r++; r++;
} }
@ -302,36 +287,25 @@ INT cmd_rename (LPTSTR param)
//Well we have splitted the Paths,so now we have to paste them again(if needed),thanks bPath. //Well we have splitted the Paths,so now we have to paste them again(if needed),thanks bPath.
if(bPath == TRUE) if(bPath == TRUE)
{ {
_tcscpy(srcFinal,srcPath); _tcscpy(srcFinal,srcPath);
_tcscat(srcFinal,f.cFileName); _tcscat(srcFinal,f.cFileName);
_tcscpy(dstFinal,dstPath); _tcscpy(dstFinal,dstPath);
_tcscat(dstFinal,dstLast); _tcscat(dstFinal,dstLast);
}
else
}else{ {
_tcscpy(srcFinal,f.cFileName); _tcscpy(srcFinal,f.cFileName);
_tcscpy(dstFinal,dstLast); _tcscpy(dstFinal,dstLast);
} }
TRACE("DestinationPath: %s\n", debugstr_aw(dstFinal)); TRACE("DestinationPath: %s\n", debugstr_aw(dstFinal));
if (!(dwFlags & REN_QUIET) && !(dwFlags & REN_TOTAL)) if (!(dwFlags & REN_QUIET) && !(dwFlags & REN_TOTAL))
ConOutPrintf(_T("%s -> %s\n"),srcFinal , dstFinal); ConOutPrintf(_T("%s -> %s\n"),srcFinal , dstFinal);
/* Rename the file */ /* Rename the file */
if (!(dwFlags & REN_NOTHING)) if (!(dwFlags & REN_NOTHING))
{ {
if (MoveFile(srcFinal, dstFinal)) if (MoveFile(srcFinal, dstFinal))
{ {
dwFiles++; dwFiles++;
@ -339,19 +313,15 @@ INT cmd_rename (LPTSTR param)
else else
{ {
if (!(dwFlags & REN_ERROR)) if (!(dwFlags & REN_ERROR))
{
ConErrResPrintf(STRING_REN_ERROR1, GetLastError()); ConErrResPrintf(STRING_REN_ERROR1, GetLastError());
} }
} }
} }
}
while (FindNextFile(hFile, &f)); while (FindNextFile(hFile, &f));
//Closing and Printing errors. //Closing and Printing errors.
FindClose(hFile); FindClose(hFile);
if (!(dwFlags & REN_QUIET)) if (!(dwFlags & REN_QUIET))
{ {
if (dwFiles == 1) if (dwFiles == 1)
@ -361,7 +331,6 @@ INT cmd_rename (LPTSTR param)
} }
freep(arg); freep(arg);
return 0; return 0;
} }