mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 02:43:09 +00:00
[CMD]
Fix whitespace (part 4/x) (convert tabs into 4-space indent). svn path=/trunk/; revision=59383
This commit is contained in:
parent
16ca7b2a1d
commit
3f69dc1614
10 changed files with 3077 additions and 3168 deletions
|
@ -189,25 +189,21 @@ typedef struct _DirSwitchesFlags
|
|||
} stTimeField; /* The time field to display or use for sorting */
|
||||
} DIRSWITCHFLAGS, *LPDIRSWITCHFLAGS;
|
||||
|
||||
|
||||
typedef struct _DIRFINDLISTNODE
|
||||
{
|
||||
WIN32_FIND_DATA stFindInfo;
|
||||
struct _DIRFINDLISTNODE *ptrNext;
|
||||
} DIRFINDLISTNODE, *PDIRFINDLISTNODE;
|
||||
|
||||
|
||||
typedef BOOL
|
||||
(WINAPI *PGETFREEDISKSPACEEX)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
|
||||
|
||||
|
||||
/* Globally save the # of dirs, files and bytes,
|
||||
* probabaly later pass them to functions. Rob Lake */
|
||||
static ULONG recurse_dir_cnt;
|
||||
static ULONG recurse_file_cnt;
|
||||
static ULONGLONG recurse_bytes;
|
||||
|
||||
|
||||
/*
|
||||
* help
|
||||
*
|
||||
|
@ -220,8 +216,6 @@ DirHelp(VOID)
|
|||
ConOutResPaging(TRUE, STRING_DIR_HELP1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* DirReadParameters
|
||||
*
|
||||
|
@ -585,7 +579,7 @@ PrintDirectoryHeader(LPTSTR szPath, LPDIRSWITCHFLAGS lpFlags)
|
|||
!GetVolumeInformation(szRootName, szVolName, 80, &dwSerialNr,
|
||||
NULL, NULL, NULL, 0))
|
||||
{
|
||||
return(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* print drive info */
|
||||
|
@ -738,7 +732,6 @@ GetUserDiskFreeSpace(LPCTSTR lpRoot,
|
|||
* print_summary: prints dir summary
|
||||
* Added by Rob Lake 06/17/98 to compact code
|
||||
* Just copied Tim's Code and patched it a bit
|
||||
*
|
||||
*/
|
||||
static INT
|
||||
PrintSummary(LPTSTR szPath,
|
||||
|
@ -752,7 +745,6 @@ PrintSummary(LPTSTR szPath,
|
|||
TCHAR szBuffer[64];
|
||||
ULARGE_INTEGER uliFree;
|
||||
|
||||
|
||||
/* Here we check if we didn't find anything */
|
||||
if (!(ulFiles + ulDirs))
|
||||
{
|
||||
|
@ -761,7 +753,6 @@ PrintSummary(LPTSTR szPath,
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* In bare format we don't print results */
|
||||
if (lpFlags->bBareFormat)
|
||||
return 0;
|
||||
|
@ -834,7 +825,6 @@ getName(const TCHAR* file, TCHAR * dest)
|
|||
else
|
||||
iLen = (end - file);
|
||||
|
||||
|
||||
_tcsncpy(dest, file, iLen);
|
||||
*(dest + iLen) = _T('\0');
|
||||
|
||||
|
@ -951,8 +941,7 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
|||
iColumns --;
|
||||
|
||||
/* A last check at iColumns to avoid division by zero */
|
||||
if (!(iColumns))
|
||||
iColumns = 1;
|
||||
if (!iColumns) iColumns = 1;
|
||||
|
||||
/* Calculate the lines that will be printed */
|
||||
iLines = (USHORT)((dwCount + iColumns - 1) / iColumns);
|
||||
|
@ -972,8 +961,7 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
|||
temp = (i * iColumns) + j;
|
||||
}
|
||||
|
||||
if (temp >= dwCount)
|
||||
break;
|
||||
if (temp >= dwCount) break;
|
||||
|
||||
if (ptrFiles[temp]->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
_stprintf(szTempFname, _T("[%s]"), ptrFiles[temp]->cFileName);
|
||||
|
@ -1000,13 +988,13 @@ DirPrintOldList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
|||
TCHAR * szCurPath, /* [IN] Full path of current directory */
|
||||
LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */
|
||||
{
|
||||
DWORD i; /* An indexer for "for"s */
|
||||
TCHAR szName[10]; /* The name of file */
|
||||
TCHAR szExt[5]; /* The extension of file */
|
||||
TCHAR szDate[30],szTime[30]; /* Used to format time and date */
|
||||
TCHAR szSize[30]; /* The size of file */
|
||||
int iSizeFormat; /* The format of size field */
|
||||
ULARGE_INTEGER u64FileSize; /* The file size */
|
||||
DWORD i; /* An indexer for "for"s */
|
||||
TCHAR szName[10]; /* The name of file */
|
||||
TCHAR szExt[5]; /* The extension of file */
|
||||
TCHAR szDate[30],szTime[30]; /* Used to format time and date */
|
||||
TCHAR szSize[30]; /* The size of file */
|
||||
int iSizeFormat; /* The format of size field */
|
||||
ULARGE_INTEGER u64FileSize; /* The file size */
|
||||
|
||||
for (i = 0; i < dwCount && !bCtrlBreak; i++)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ VOID CompleteFilename (LPTSTR str, UINT charcount)
|
|||
if (count < 0)
|
||||
count = 0;
|
||||
|
||||
/* find how many '"'s there is typed already.*/
|
||||
/* find how many '"'s there is typed already. */
|
||||
step = count;
|
||||
while (step > 0)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ VOID CompleteFilename (LPTSTR str, UINT charcount)
|
|||
c++;
|
||||
step--;
|
||||
}
|
||||
/* if c is odd, then user typed " before name, else not.*/
|
||||
/* if c is odd, then user typed " before name, else not. */
|
||||
|
||||
/* find front of word */
|
||||
if (str[count] == _T('"') || (c % 2))
|
||||
|
@ -197,7 +197,6 @@ VOID CompleteFilename (LPTSTR str, UINT charcount)
|
|||
/*
|
||||
* returns 1 if at least one match, else returns 0
|
||||
*/
|
||||
|
||||
BOOL ShowCompletionMatches (LPTSTR str, INT charcount)
|
||||
{
|
||||
WIN32_FIND_DATA file;
|
||||
|
@ -381,8 +380,10 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
|
|||
|
||||
/* Count number of " */
|
||||
for(i = 0; i < _tcslen(str); i++)
|
||||
{
|
||||
if(str[i] == _T('\"'))
|
||||
nQuotes++;
|
||||
}
|
||||
|
||||
/* Find the prefix and suffix */
|
||||
if(nQuotes % 2 && nQuotes >= 1)
|
||||
|
@ -465,7 +466,6 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
|
|||
SBreak = i;
|
||||
if((str[i] == _T(' ') || str[i] == _T('\\')) && !bInside)
|
||||
PBreak = i;
|
||||
|
||||
}
|
||||
SBreak++;
|
||||
PBreak++;
|
||||
|
@ -479,9 +479,7 @@ VOID FindPrefixAndSuffix(LPTSTR strIN, LPTSTR szPrefix, LPTSTR szSuffix)
|
|||
allow the next stuff to stay inside one set of quotes
|
||||
otherwise you would have multiple sets of quotes*/
|
||||
_tcscpy(&szPrefix[_tcslen(szPrefix) - 2],_T("\\"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
if(szPrefix[i] == _T(' ') && !bInside)
|
||||
LastSpace = i;
|
||||
|
||||
}
|
||||
|
||||
/* insert the quotation and move things around */
|
||||
if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
|
||||
{
|
||||
|
@ -788,9 +786,11 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
|
|||
if(!NeededQuote)
|
||||
{
|
||||
for(i = 0; i < _tcslen(strOut); i++)
|
||||
{
|
||||
if(strOut[i] == _T('\"'))
|
||||
NeededQuote = !NeededQuote;
|
||||
}
|
||||
}
|
||||
|
||||
if(szPrefix[_tcslen(szPrefix) - 1] == _T('\"') || NeededQuote)
|
||||
_tcscat(strOut,_T("\""));
|
||||
|
@ -800,6 +800,5 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
|
|||
//DiffLength = EndLength - StartLength;
|
||||
if(FileList != NULL)
|
||||
cmd_free(FileList);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -48,18 +48,13 @@ typedef struct tagHISTORY
|
|||
LPTSTR string;
|
||||
} HIST_ENTRY, * LPHIST_ENTRY;
|
||||
|
||||
static INT size,
|
||||
max_size=100;
|
||||
|
||||
|
||||
static INT size, max_size=100;
|
||||
|
||||
static LPHIST_ENTRY Top;
|
||||
static LPHIST_ENTRY Bottom;
|
||||
|
||||
|
||||
static LPHIST_ENTRY curr_ptr=0;
|
||||
|
||||
|
||||
VOID InitHistory(VOID);
|
||||
VOID History_move_to_bottom(VOID);
|
||||
VOID History (INT dir, LPTSTR commandline);
|
||||
|
@ -73,7 +68,6 @@ static VOID add_at_bottom(LPTSTR string);
|
|||
VOID set_size(INT new_size);
|
||||
|
||||
|
||||
|
||||
INT CommandHistory (LPTSTR param)
|
||||
{
|
||||
LPTSTR tmp;
|
||||
|
@ -154,8 +148,6 @@ VOID InitHistory(VOID)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VOID CleanHistory(VOID)
|
||||
{
|
||||
while (Bottom->next!=Top)
|
||||
|
@ -198,8 +190,6 @@ VOID del(LPHIST_ENTRY item)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*free string's mem*/
|
||||
if (item->string)
|
||||
cmd_free(item->string);
|
||||
|
@ -216,11 +206,8 @@ VOID del(LPHIST_ENTRY item)
|
|||
static
|
||||
VOID add_at_bottom(LPTSTR string)
|
||||
{
|
||||
|
||||
|
||||
LPHIST_ENTRY tmp;
|
||||
|
||||
|
||||
/*delete first entry if maximum number of entries is reached*/
|
||||
while(size>=max_size)
|
||||
del(Top->prev);
|
||||
|
@ -231,13 +218,11 @@ VOID add_at_bottom(LPTSTR string)
|
|||
if (*string==_T('\0'))
|
||||
return;
|
||||
|
||||
|
||||
/*if new entry is the same than the last do not add it*/
|
||||
if(size)
|
||||
if(_tcscmp(string,Bottom->next->string)==0)
|
||||
return;
|
||||
|
||||
|
||||
/*fill bottom with string, it will become Bottom->next*/
|
||||
Bottom->string=cmd_alloc((_tcslen(string)+1)*sizeof(TCHAR));
|
||||
_tcscpy(Bottom->string,string);
|
||||
|
@ -245,7 +230,6 @@ VOID add_at_bottom(LPTSTR string)
|
|||
/*save Bottom value*/
|
||||
tmp=Bottom;
|
||||
|
||||
|
||||
/*create new void Bottom*/
|
||||
Bottom=cmd_alloc(sizeof(HIST_ENTRY));
|
||||
Bottom->next=tmp;
|
||||
|
@ -256,15 +240,12 @@ VOID add_at_bottom(LPTSTR string)
|
|||
|
||||
/*set new size*/
|
||||
size++;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID History_move_to_bottom(VOID)
|
||||
{
|
||||
curr_ptr=Bottom;
|
||||
|
||||
}
|
||||
|
||||
LPCTSTR PeekHistory(INT dir)
|
||||
|
@ -306,7 +287,6 @@ LPCTSTR PeekHistory(INT dir)
|
|||
|
||||
VOID History (INT dir, LPTSTR commandline)
|
||||
{
|
||||
|
||||
if(dir==0)
|
||||
{
|
||||
add_at_bottom(commandline);
|
||||
|
@ -320,7 +300,6 @@ VOID History (INT dir, LPTSTR commandline)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if(dir<0)/*key up*/
|
||||
{
|
||||
if (curr_ptr->next==Top || curr_ptr==Top)
|
||||
|
@ -334,20 +313,13 @@ VOID History (INT dir, LPTSTR commandline)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
curr_ptr = curr_ptr->next;
|
||||
if(curr_ptr->string)
|
||||
_tcscpy(commandline,curr_ptr->string);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(dir>0)
|
||||
{
|
||||
|
||||
if (curr_ptr->prev==Bottom || curr_ptr==Bottom)
|
||||
{
|
||||
#ifdef WRAP_HISTORY
|
||||
|
@ -362,7 +334,6 @@ VOID History (INT dir, LPTSTR commandline)
|
|||
curr_ptr=curr_ptr->prev;
|
||||
if(curr_ptr->string)
|
||||
_tcscpy(commandline,curr_ptr->string);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,8 +270,6 @@ INT cmd_chdir (LPTSTR param)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef INCLUDE_CMD_MKDIR
|
||||
|
||||
/* Helper funtion for mkdir to make directories in a path.
|
||||
|
@ -301,7 +299,9 @@ MakeFullPath(TCHAR * DirPath)
|
|||
path[n] = _T('\0');
|
||||
if( !CreateDirectory(path, NULL) &&
|
||||
(GetLastError() != ERROR_ALREADY_EXISTS))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
} while (p != NULL);
|
||||
|
||||
return TRUE;
|
||||
|
@ -309,7 +309,6 @@ MakeFullPath(TCHAR * DirPath)
|
|||
|
||||
/*
|
||||
* MD / MKDIR
|
||||
*
|
||||
*/
|
||||
INT cmd_mkdir (LPTSTR param)
|
||||
{
|
||||
|
@ -356,7 +355,6 @@ INT cmd_mkdir (LPTSTR param)
|
|||
#ifdef INCLUDE_CMD_RMDIR
|
||||
/*
|
||||
* RD / RMDIR
|
||||
*
|
||||
*/
|
||||
BOOL DeleteFolder(LPTSTR FileName)
|
||||
{
|
||||
|
@ -392,6 +390,7 @@ BOOL DeleteFolder(LPTSTR FileName)
|
|||
}
|
||||
return RemoveDirectory(FileName);
|
||||
}
|
||||
|
||||
INT cmd_rmdir (LPTSTR param)
|
||||
{
|
||||
TCHAR ch;
|
||||
|
@ -497,7 +496,6 @@ INT cmd_rmdir (LPTSTR param)
|
|||
|
||||
/*
|
||||
* set the exitflag to true
|
||||
*
|
||||
*/
|
||||
INT CommandExit (LPTSTR param)
|
||||
{
|
||||
|
@ -519,19 +517,17 @@ INT CommandExit (LPTSTR param)
|
|||
nErrorLevel = _ttoi(param);
|
||||
ExitBatch();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
bExit = TRUE;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_CMD_REM
|
||||
/*
|
||||
* does nothing
|
||||
*
|
||||
*/
|
||||
INT CommandRem (LPTSTR param)
|
||||
{
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
* 06-Nov-1999 (Eric Kohl)
|
||||
* Added PagePrompt() and FilePrompt().
|
||||
*
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
|
||||
* Remove all hardcode string to En.rc
|
||||
* 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>
|
||||
* Remove all hardcoded strings in En.rc
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
@ -63,9 +63,8 @@ cgetchar (VOID)
|
|||
(irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||
(irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL))
|
||||
{
|
||||
;
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
@ -93,7 +92,6 @@ VOID GetPathCase( TCHAR * Path, TCHAR * OutPath)
|
|||
_tcscpy(TempPath, _T(""));
|
||||
_tcscpy(OutPath, _T(""));
|
||||
|
||||
|
||||
for(i = 0; i < _tcslen(Path); i++)
|
||||
{
|
||||
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
|
||||
* are spaces and slashes ('/').
|
||||
*/
|
||||
|
||||
LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards, BOOL handle_plus)
|
||||
{
|
||||
LPTSTR *arg;
|
||||
|
@ -364,7 +361,8 @@ LPTSTR *split (LPTSTR s, LPINT args, BOOL expand_wildcards, BOOL handle_plus)
|
|||
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 ;)
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
VOID freep (LPTSTR *p)
|
||||
{
|
||||
|
@ -444,7 +441,6 @@ VOID freep (LPTSTR *p)
|
|||
cmd_free(p);
|
||||
}
|
||||
|
||||
|
||||
LPTSTR _stpcpy (LPTSTR dest, LPCTSTR src)
|
||||
{
|
||||
_tcscpy (dest, src);
|
||||
|
@ -464,11 +460,9 @@ StripQuotes(TCHAR *in)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Checks if a path is valid (accessible)
|
||||
*/
|
||||
|
||||
BOOL IsValidPathName (LPCTSTR pszPath)
|
||||
{
|
||||
TCHAR szOldPath[MAX_PATH];
|
||||
|
@ -486,7 +480,6 @@ BOOL IsValidPathName (LPCTSTR pszPath)
|
|||
/*
|
||||
* Checks if a file exists (accessible)
|
||||
*/
|
||||
|
||||
BOOL IsExistingFile (LPCTSTR pszPath)
|
||||
{
|
||||
DWORD attr = GetFileAttributes (pszPath);
|
||||
|
@ -605,8 +598,7 @@ INT FilePromptYN (UINT resID)
|
|||
|
||||
return PROMPT_NO;
|
||||
|
||||
|
||||
/* unfinished sollution */
|
||||
/* unfinished solution */
|
||||
#if 0
|
||||
RemoveBreakHandler ();
|
||||
ConInDisable ();
|
||||
|
@ -665,7 +657,6 @@ INT FilePromptYNA (UINT resID)
|
|||
return PROMPT_NO;
|
||||
else if (_tcsncmp(p, &szMsg[2], 1) == 0)
|
||||
return PROMPT_ALL;
|
||||
|
||||
#if 0
|
||||
else if (*p == _T('\03'))
|
||||
return PROMPT_BREAK;
|
||||
|
@ -673,8 +664,7 @@ INT FilePromptYNA (UINT resID)
|
|||
|
||||
return PROMPT_NO;
|
||||
|
||||
|
||||
/* unfinished sollution */
|
||||
/* unfinished solution */
|
||||
#if 0
|
||||
RemoveBreakHandler ();
|
||||
ConInDisable ();
|
||||
|
|
|
@ -11,12 +11,15 @@ static BOOL CreateJunction(LPCTSTR LinkName, LPCTSTR TargetName)
|
|||
{
|
||||
/* Structure for reparse point daya when ReparseTag is one of
|
||||
* the tags defined by Microsoft. Copied from MinGW winnt.h */
|
||||
typedef struct _REPARSE_DATA_BUFFER {
|
||||
typedef struct _REPARSE_DATA_BUFFER
|
||||
{
|
||||
DWORD ReparseTag;
|
||||
WORD ReparseDataLength;
|
||||
WORD Reserved;
|
||||
_ANONYMOUS_UNION union {
|
||||
struct {
|
||||
_ANONYMOUS_UNION union
|
||||
{
|
||||
struct
|
||||
{
|
||||
WORD SubstituteNameOffset;
|
||||
WORD SubstituteNameLength;
|
||||
WORD PrintNameOffset;
|
||||
|
@ -24,14 +27,16 @@ static BOOL CreateJunction(LPCTSTR LinkName, LPCTSTR TargetName)
|
|||
ULONG Flags;
|
||||
WCHAR PathBuffer[1];
|
||||
} SymbolicLinkReparseBuffer;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
WORD SubstituteNameOffset;
|
||||
WORD SubstituteNameLength;
|
||||
WORD PrintNameOffset;
|
||||
WORD PrintNameLength;
|
||||
WCHAR PathBuffer[1];
|
||||
} MountPointReparseBuffer;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
BYTE DataBuffer[1];
|
||||
} GenericReparseBuffer;
|
||||
} DUMMYUNIONNAME;
|
||||
|
@ -45,7 +50,7 @@ static BOOL CreateJunction(LPCTSTR LinkName, LPCTSTR TargetName)
|
|||
|
||||
TCHAR TargetFullPath[MAX_PATH];
|
||||
#ifdef UNICODE
|
||||
#define TargetFullPathW TargetFullPath
|
||||
#define TargetFullPathW TargetFullPath
|
||||
#else
|
||||
WCHAR TargetFullPathW[MAX_PATH];
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,8 @@ enum
|
|||
};
|
||||
|
||||
enum
|
||||
{ /* Move status flags */
|
||||
{
|
||||
/* Move status flags */
|
||||
MOVE_SOURCE_IS_DIR = 0x001,
|
||||
MOVE_SOURCE_IS_FILE = 0x002,
|
||||
MOVE_DEST_IS_DIR = 0x004,
|
||||
|
@ -54,7 +55,7 @@ enum
|
|||
|
||||
static INT MoveOverwrite (LPTSTR fn)
|
||||
{
|
||||
/*ask the user if they want to override*/
|
||||
/* ask the user if they want to override */
|
||||
INT res;
|
||||
ConOutResPrintf(STRING_MOVE_HELP1, fn);
|
||||
res = FilePromptYNA (0);
|
||||
|
@ -98,7 +99,7 @@ INT cmd_move (LPTSTR param)
|
|||
WIN32_FIND_DATA findBuffer;
|
||||
HANDLE hFile;
|
||||
|
||||
/* used only when source and destination directories are on different volume*/
|
||||
/* used only when source and destination directories are on different volume */
|
||||
HANDLE hDestFile;
|
||||
WIN32_FIND_DATA findDestBuffer;
|
||||
TCHAR szMoveDest[MAX_PATH];
|
||||
|
@ -114,7 +115,6 @@ INT cmd_move (LPTSTR param)
|
|||
DWORD dwMoveFlags = 0;
|
||||
DWORD dwMoveStatusFlags = 0;
|
||||
|
||||
|
||||
if (!_tcsncmp (param, _T("/?"), 2))
|
||||
{
|
||||
#if 0
|
||||
|
@ -186,7 +186,6 @@ INT cmd_move (LPTSTR param)
|
|||
dwMoveStatusFlags |= MOVE_SOURCE_HAS_WILD;
|
||||
}
|
||||
|
||||
|
||||
/* get destination */
|
||||
GetFullPathName (pszDest, MAX_PATH, szDestPath, NULL);
|
||||
TRACE ("Destination: %s\n", debugstr_aw(szDestPath));
|
||||
|
@ -203,7 +202,6 @@ INT cmd_move (LPTSTR param)
|
|||
ErrorMessage (GetLastError (), arg[i]);
|
||||
freep (arg);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/* check for special cases "." and ".." and if found skip them */
|
||||
|
@ -252,7 +250,6 @@ INT cmd_move (LPTSTR param)
|
|||
ErrorMessage (GetLastError (), arg[i]);
|
||||
freep (arg);
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
/* check for special cases "." and ".." and if found skip them */
|
||||
|
@ -294,7 +291,6 @@ INT cmd_move (LPTSTR param)
|
|||
if (IsExistingDirectory(szSrcPath))
|
||||
{
|
||||
/* source is directory */
|
||||
|
||||
if (dwMoveStatusFlags & MOVE_SOURCE_IS_FILE)
|
||||
{
|
||||
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 (IsExistingDirectory(szDestPath))
|
||||
{
|
||||
/* destination is existing directory */
|
||||
|
@ -324,7 +319,6 @@ INT cmd_move (LPTSTR param)
|
|||
dwMoveStatusFlags |= MOVE_DEST_EXISTS;
|
||||
|
||||
dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED;
|
||||
|
||||
}
|
||||
if (IsExistingFile(szDestPath))
|
||||
{
|
||||
|
@ -335,7 +329,6 @@ INT cmd_move (LPTSTR param)
|
|||
_tcscpy (szFullDestPath, szDestPath);
|
||||
|
||||
dwMoveFlags |= MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH | MOVEFILE_COPY_ALLOWED;
|
||||
|
||||
}
|
||||
|
||||
TRACE ("Move Status Flags: 0x%X\n",dwMoveStatusFlags);
|
||||
|
@ -350,7 +343,6 @@ INT cmd_move (LPTSTR param)
|
|||
freep(arg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(dwMoveStatusFlags & (MOVE_DEST_IS_FILE | MOVE_DEST_IS_DIR)))
|
||||
{
|
||||
/* destination doesn't exist */
|
||||
|
@ -384,7 +376,6 @@ INT cmd_move (LPTSTR param)
|
|||
if (nOverwrite == PROMPT_ALL)
|
||||
dwFlags |= MOVE_OVER_YES;
|
||||
|
||||
|
||||
ConOutPrintf (_T("%s => %s "), szSrcPath, szFullDestPath);
|
||||
|
||||
/* are we really supposed to do something */
|
||||
|
@ -426,7 +417,8 @@ INT cmd_move (LPTSTR param)
|
|||
FoundFile = FindNextFile (hDestFile, &findDestBuffer);
|
||||
|
||||
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);
|
||||
(pszSrcDirPointer)--;
|
||||
(pszDestDirPointer)--;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
* PARSER.C - command parsing.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
|
|
@ -150,7 +150,6 @@ INT cmd_rename (LPTSTR param)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* Get destination pattern and source pattern*/
|
||||
for (i = 0; i < args; i++)
|
||||
{
|
||||
|
@ -158,16 +157,10 @@ INT cmd_rename (LPTSTR param)
|
|||
continue;
|
||||
dstPattern = arg[i]; //we save the Last argument as dstPattern
|
||||
srcPattern = arg[i-1];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (_tcschr(srcPattern, _T('\\'))) //Checking if the Source (srcPattern) is a Path to the file
|
||||
{
|
||||
|
||||
bPath= TRUE;
|
||||
|
||||
//Splitting srcPath and srcFile.
|
||||
|
@ -182,8 +175,6 @@ INT cmd_rename (LPTSTR param)
|
|||
}
|
||||
_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.
|
||||
{
|
||||
dstFILE = _tcschr(dstPattern, _T('\\'));
|
||||
|
@ -202,16 +193,12 @@ INT cmd_rename (LPTSTR param)
|
|||
freep(arg);
|
||||
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:
|
||||
|
@ -220,18 +207,19 @@ INT cmd_rename (LPTSTR param)
|
|||
if(_tcschr(dstPattern, _T('\\')))
|
||||
{
|
||||
error_syntax(dstPattern);
|
||||
|
||||
freep(arg);
|
||||
return 1;
|
||||
}else dstFILE=dstPattern;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstFILE=dstPattern;
|
||||
}
|
||||
}
|
||||
|
||||
//Checking Wildcards.
|
||||
if (_tcschr(dstFILE, _T('*')) || _tcschr(dstFILE, _T('?')))
|
||||
bDstWildcard = TRUE;
|
||||
|
||||
|
||||
|
||||
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));
|
||||
|
||||
|
@ -239,15 +227,12 @@ INT cmd_rename (LPTSTR param)
|
|||
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (!(dwFlags & REN_ERROR))
|
||||
error_file_not_found();
|
||||
|
||||
if (!(dwFlags & REN_ERROR)) error_file_not_found();
|
||||
}
|
||||
do
|
||||
{
|
||||
/* ignore "." and ".." */
|
||||
if (!_tcscmp (f.cFileName, _T(".")) ||
|
||||
!_tcscmp (f.cFileName, _T("..")))
|
||||
if (!_tcscmp (f.cFileName, _T(".")) || !_tcscmp (f.cFileName, _T("..")))
|
||||
continue;
|
||||
|
||||
/* 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
|
||||
* wildcards, unless option /S is used */
|
||||
if ((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
&& bDstWildcard
|
||||
&& !(dwFlags & REN_SUBDIR))
|
||||
if ((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||
bDstWildcard && !(dwFlags & REN_SUBDIR))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -292,46 +278,34 @@ INT cmd_rename (LPTSTR param)
|
|||
else
|
||||
{
|
||||
*r = *q;
|
||||
if (*p != 0)
|
||||
p++;
|
||||
if (*p != 0) p++;
|
||||
q++;
|
||||
r++;
|
||||
}
|
||||
}
|
||||
*r = 0;
|
||||
//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);
|
||||
|
||||
_tcscat(srcFinal,f.cFileName);
|
||||
|
||||
_tcscpy(dstFinal,dstPath);
|
||||
_tcscat(dstFinal,dstLast);
|
||||
|
||||
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
_tcscpy(srcFinal,f.cFileName);
|
||||
_tcscpy(dstFinal,dstLast);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
TRACE("DestinationPath: %s\n", debugstr_aw(dstFinal));
|
||||
|
||||
|
||||
if (!(dwFlags & REN_QUIET) && !(dwFlags & REN_TOTAL))
|
||||
|
||||
ConOutPrintf(_T("%s -> %s\n"),srcFinal , dstFinal);
|
||||
|
||||
/* Rename the file */
|
||||
if (!(dwFlags & REN_NOTHING))
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (MoveFile(srcFinal, dstFinal))
|
||||
{
|
||||
dwFiles++;
|
||||
|
@ -339,19 +313,15 @@ INT cmd_rename (LPTSTR param)
|
|||
else
|
||||
{
|
||||
if (!(dwFlags & REN_ERROR))
|
||||
{
|
||||
ConErrResPrintf(STRING_REN_ERROR1, GetLastError());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (FindNextFile(hFile, &f));
|
||||
//Closing and Printing errors.
|
||||
|
||||
//Closing and Printing errors.
|
||||
FindClose(hFile);
|
||||
|
||||
|
||||
if (!(dwFlags & REN_QUIET))
|
||||
{
|
||||
if (dwFiles == 1)
|
||||
|
@ -361,7 +331,6 @@ INT cmd_rename (LPTSTR param)
|
|||
}
|
||||
|
||||
freep(arg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ INT cmd_set (LPTSTR param)
|
|||
Success = seta_eval ( skip_ws(param+2) );
|
||||
if(!Success)
|
||||
{
|
||||
/*might seem random but this is what windows xp does */
|
||||
/* might seem random but this is what windows xp does */
|
||||
nErrorLevel = 9165;
|
||||
}
|
||||
return !Success;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue