mirror of
https://github.com/reactos/reactos.git
synced 2024-11-23 19:43:31 +08:00
[CMD] Code formatting for IsValidPathName, IsExistingFile, IsExistingDirectory, and use INVALID_FILE_ATTRIBUTES instead of an hardcoded value.
This commit is contained in:
parent
a5634138c3
commit
050df0f56d
@ -297,9 +297,10 @@ LPTSTR *splitspace (LPTSTR, LPINT);
|
||||
VOID freep (LPTSTR *);
|
||||
LPTSTR _stpcpy (LPTSTR, LPCTSTR);
|
||||
VOID StripQuotes(LPTSTR);
|
||||
BOOL IsValidPathName (LPCTSTR);
|
||||
BOOL IsExistingFile (LPCTSTR);
|
||||
BOOL IsExistingDirectory (LPCTSTR);
|
||||
|
||||
BOOL IsValidPathName(IN LPCTSTR pszPath);
|
||||
BOOL IsExistingFile(IN LPCTSTR pszPath);
|
||||
BOOL IsExistingDirectory(IN LPCTSTR pszPath);
|
||||
VOID GetPathCase(TCHAR *, TCHAR *);
|
||||
|
||||
#define PROMPT_NO 0
|
||||
|
@ -532,7 +532,7 @@ FileNameContainsSpecialCharacters(LPTSTR pszFileName)
|
||||
(chr == _T('^')) ||
|
||||
(chr == _T('~')) ||
|
||||
(chr == _T('+')) ||
|
||||
(chr == 0xB4)) // '´'
|
||||
(chr == 0xB4)) // '´'
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@ -669,7 +669,7 @@ VOID CompleteFilename (LPTSTR strIN, BOOL bNext, LPTSTR strOut, UINT cusor)
|
||||
|
||||
/* Don't show files when they are doing 'cd' or 'rd' */
|
||||
if (!ShowAll &&
|
||||
file.dwFileAttributes != 0xFFFFFFFF &&
|
||||
file.dwFileAttributes != INVALID_FILE_ATTRIBUTES &&
|
||||
!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
continue;
|
||||
|
@ -138,7 +138,7 @@ INT ExecuteIf(PARSED_COMMAND *Cmd)
|
||||
attrs = GetFileAttributes(Right);
|
||||
}
|
||||
|
||||
if (attrs == 0xFFFFFFFF)
|
||||
if (attrs == INVALID_FILE_ATTRIBUTES)
|
||||
result = FALSE;
|
||||
else if (IsDir)
|
||||
result = ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
|
||||
|
@ -477,36 +477,34 @@ StripQuotes(TCHAR *in)
|
||||
|
||||
|
||||
/*
|
||||
* Checks if a path is valid (accessible)
|
||||
* Checks if a path is valid (is accessible)
|
||||
*/
|
||||
BOOL IsValidPathName (LPCTSTR pszPath)
|
||||
BOOL IsValidPathName(IN LPCTSTR pszPath)
|
||||
{
|
||||
TCHAR szOldPath[MAX_PATH];
|
||||
BOOL bResult;
|
||||
TCHAR szOldPath[MAX_PATH];
|
||||
|
||||
GetCurrentDirectory (MAX_PATH, szOldPath);
|
||||
bResult = SetCurrentDirectory (pszPath);
|
||||
GetCurrentDirectory(ARRAYSIZE(szOldPath), szOldPath);
|
||||
bResult = SetCurrentDirectory(pszPath);
|
||||
|
||||
SetCurrentDirectory (szOldPath);
|
||||
SetCurrentDirectory(szOldPath);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Checks if a file exists (accessible)
|
||||
* Checks if a file exists (is accessible)
|
||||
*/
|
||||
BOOL IsExistingFile (LPCTSTR pszPath)
|
||||
BOOL IsExistingFile(IN LPCTSTR pszPath)
|
||||
{
|
||||
DWORD attr = GetFileAttributes (pszPath);
|
||||
return (attr != 0xFFFFFFFF && (! (attr & FILE_ATTRIBUTE_DIRECTORY)) );
|
||||
DWORD attr = GetFileAttributes(pszPath);
|
||||
return ((attr != INVALID_FILE_ATTRIBUTES) && !(attr & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
|
||||
BOOL IsExistingDirectory (LPCTSTR pszPath)
|
||||
BOOL IsExistingDirectory(IN LPCTSTR pszPath)
|
||||
{
|
||||
DWORD attr = GetFileAttributes (pszPath);
|
||||
return (attr != 0xFFFFFFFF && (attr & FILE_ATTRIBUTE_DIRECTORY) );
|
||||
DWORD attr = GetFileAttributes(pszPath);
|
||||
return ((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user