#ifdef FEATURE_UNIX_FILENAME_COMPLETION
-VOID CompleteFilename (LPTSTR str, INT charcount)
+VOID CompleteFilename (LPTSTR str, UINT charcount)
{
WIN32_FIND_DATA file;
HANDLE hFile;
if(!perfectmatch)
{
-#ifdef __REACTOS__
- Beep (440, 50);
-#else
MessageBeep (-1);
-#endif
}
}
else
}
}
-#ifdef __REACTOS__
- Beep (440, 50);
-#else
MessageBeep (-1);
-#endif
}
}
else
{
/* no match found */
-#ifdef __REACTOS__
- Beep (440, 50);
-#else
MessageBeep (-1);
-#endif
return FALSE;
}
/* number of quotes in the string */
INT nQuotes = 0;
/* used in for loops */
- INT i;
+ UINT i;
/* Char number to break the string at */
INT PBreak = 0;
INT SBreak = 0;
nQuotes++;
/* Find the prefix and suffix */
- if(nQuotes % 2 && nQuotes > 1)
+ if(nQuotes % 2 && nQuotes >= 1)
{
/* Odd number of quotes. Just start from the last " */
/* THis is the way MS does it, and is an easy way out */
szSearch = szSearch1;
/* Move one char past */
szSearch++;
- szSearch[0] = _T('\0');
+ szSearch[0] = _T('\0');
_tcscpy(szPrefix,str);
return;
}
}
- int compare(const void *arg1,const void *arg2)
+ int __cdecl compare(const void *arg1,const void *arg2)
{
FileName * File1;
FileName * File2;
return ret;
}
-VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, INT cusor)
+VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
{
/* Length of string before we complete it */
INT StartLength;
/* Number of files */
INT FileListSize = 0;
/* Used for loops */
- INT i;
+ UINT i;
/* Editable string of what was passed in */
TCHAR str[MAX_PATH];
/* Keeps track of what element was last selected */
static INT Sel;
BOOL NeededQuote = FALSE;
+ BOOL ShowAll = TRUE;
+ TCHAR * line = strIN;
+
strOut[0] = _T('\0');
+ while (_istspace (*line))
+ line++;
+ if(!_tcsnicmp (line, _T("rd "), 3) || !_tcsnicmp (line, _T("cd "), 3))
+ ShowAll = FALSE;
+
/* Copy the string, str can be edited and orginal should not be */
_tcscpy(str,strIN);
_tcscpy(szOrginal,strIN);
no quote at the END of the full name */
FindPrefixAndSuffix(str,szPrefix,szBaseWord);
/* Strip quotes */
- while(i < _tcslen(szBaseWord)+1)
+ for(i = 0; i < _tcslen(szBaseWord); )
{
if(szBaseWord[i] == _T('\"'))
memmove(&szBaseWord[i],&szBaseWord[i + 1], _tcslen(&szBaseWord[i]) * sizeof(TCHAR));
/* Start the search for all the files */
GetFullPathName(szBaseWord, MAX_PATH, szSearchPath, NULL);
if(StartLength > 0)
+ {
_tcscat(szSearchPath,_T("*"));
+ }
_tcscpy(LastSearch,szSearchPath);
_tcscpy(LastPrefix,szPrefix);
}
if(!_tcscmp (file.cFileName, _T(".")) ||
!_tcscmp (file.cFileName, _T("..")))
continue;
+
+ /* Don't show files when they are doing 'cd' or 'rd' */
+ if(!ShowAll &&
+ file.dwFileAttributes != 0xFFFFFFFF &&
+ !(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ continue;
+ }
+
/* Add the file to the list of files */
if(FileList == NULL)
{
}while(FindNextFile(hFile,&file));
-
+ /* Check the size of the list to see if we
+ found any matches */
+ if(FileListSize == 0)
+ {
+ _tcscpy(strOut,szOrginal);
+ CloseHandle(hFile);
+ if(FileList != NULL)
+ free(FileList);
+ return;
+
+ }
/* Sort the files */
qsort(FileList,FileListSize,sizeof(FileName), compare);
}
/* insert the quoation and move things around */
- if(szPrefix[LastSpace + 1] == _T('\"') && LastSpace != -1)
+ if(szPrefix[LastSpace + 1] != _T('\"') && LastSpace != -1)
{
- /* add another char or you will lose a null char ending */
- _tcsncat(szPrefix,&szPrefix[_tcslen(szPrefix) - 1],1);
- for(i = _tcslen(szPrefix) - 1; i > LastSpace; i--)
- {
- szPrefix[i] = szPrefix[i - 1];
- }
+ memmove ( &szPrefix[LastSpace+1], &szPrefix[LastSpace], (_tcslen(szPrefix)-LastSpace+1) * sizeof(TCHAR) );
- if(LastSpace + 1 == _tcslen(szPrefix))
+ if((UINT)(LastSpace + 1) == _tcslen(szPrefix))
{
_tcscat(szPrefix,_T("\""));
}