mirror of
https://github.com/reactos/reactos.git
synced 2024-06-21 13:31:38 +00: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 *);
|
VOID freep (LPTSTR *);
|
||||||
LPTSTR _stpcpy (LPTSTR, LPCTSTR);
|
LPTSTR _stpcpy (LPTSTR, LPCTSTR);
|
||||||
VOID StripQuotes(LPTSTR);
|
VOID StripQuotes(LPTSTR);
|
||||||
BOOL IsValidPathName (LPCTSTR);
|
|
||||||
BOOL IsExistingFile (LPCTSTR);
|
BOOL IsValidPathName(IN LPCTSTR pszPath);
|
||||||
BOOL IsExistingDirectory (LPCTSTR);
|
BOOL IsExistingFile(IN LPCTSTR pszPath);
|
||||||
|
BOOL IsExistingDirectory(IN LPCTSTR pszPath);
|
||||||
VOID GetPathCase(TCHAR *, TCHAR *);
|
VOID GetPathCase(TCHAR *, TCHAR *);
|
||||||
|
|
||||||
#define PROMPT_NO 0
|
#define PROMPT_NO 0
|
||||||
|
|
|
@ -532,7 +532,7 @@ FileNameContainsSpecialCharacters(LPTSTR pszFileName)
|
||||||
(chr == _T('^')) ||
|
(chr == _T('^')) ||
|
||||||
(chr == _T('~')) ||
|
(chr == _T('~')) ||
|
||||||
(chr == _T('+')) ||
|
(chr == _T('+')) ||
|
||||||
(chr == 0xB4)) // '´'
|
(chr == 0xB4)) // '´'
|
||||||
{
|
{
|
||||||
return TRUE;
|
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' */
|
/* Don't show files when they are doing 'cd' or 'rd' */
|
||||||
if (!ShowAll &&
|
if (!ShowAll &&
|
||||||
file.dwFileAttributes != 0xFFFFFFFF &&
|
file.dwFileAttributes != INVALID_FILE_ATTRIBUTES &&
|
||||||
!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -138,7 +138,7 @@ INT ExecuteIf(PARSED_COMMAND *Cmd)
|
||||||
attrs = GetFileAttributes(Right);
|
attrs = GetFileAttributes(Right);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attrs == 0xFFFFFFFF)
|
if (attrs == INVALID_FILE_ATTRIBUTES)
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
else if (IsDir)
|
else if (IsDir)
|
||||||
result = ((attrs & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
|
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;
|
BOOL bResult;
|
||||||
|
TCHAR szOldPath[MAX_PATH];
|
||||||
|
|
||||||
GetCurrentDirectory (MAX_PATH, szOldPath);
|
GetCurrentDirectory(ARRAYSIZE(szOldPath), szOldPath);
|
||||||
bResult = SetCurrentDirectory (pszPath);
|
bResult = SetCurrentDirectory(pszPath);
|
||||||
|
|
||||||
SetCurrentDirectory (szOldPath);
|
SetCurrentDirectory(szOldPath);
|
||||||
|
|
||||||
return bResult;
|
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);
|
DWORD attr = GetFileAttributes(pszPath);
|
||||||
return (attr != 0xFFFFFFFF && (! (attr & FILE_ATTRIBUTE_DIRECTORY)) );
|
return ((attr != INVALID_FILE_ATTRIBUTES) && !(attr & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL IsExistingDirectory(IN LPCTSTR pszPath)
|
||||||
BOOL IsExistingDirectory (LPCTSTR pszPath)
|
|
||||||
{
|
{
|
||||||
DWORD attr = GetFileAttributes (pszPath);
|
DWORD attr = GetFileAttributes(pszPath);
|
||||||
return (attr != 0xFFFFFFFF && (attr & FILE_ATTRIBUTE_DIRECTORY) );
|
return ((attr != INVALID_FILE_ATTRIBUTES) && (attr & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue