https://git.reactos.org/?p=reactos.git;a=commitdiff;h=050df0f56df52aaf628e4…
commit 050df0f56df52aaf628e4cc5dedd9799e42c9489
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Fri Sep 4 00:17:15 2020 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Sep 4 00:24:45 2020 +0200
[CMD] Code formatting for IsValidPathName, IsExistingFile, IsExistingDirectory, and
use INVALID_FILE_ATTRIBUTES instead of an hardcoded value.
---
base/shell/cmd/cmd.h | 7 ++++---
base/shell/cmd/filecomp.c | 4 ++--
base/shell/cmd/if.c | 2 +-
base/shell/cmd/misc.c | 28 +++++++++++++---------------
4 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/base/shell/cmd/cmd.h b/base/shell/cmd/cmd.h
index c4b4cca90ca..205ff8ef7fe 100644
--- a/base/shell/cmd/cmd.h
+++ b/base/shell/cmd/cmd.h
@@ -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
diff --git a/base/shell/cmd/filecomp.c b/base/shell/cmd/filecomp.c
index 060b2122c02..9dfa2943fdc 100644
--- a/base/shell/cmd/filecomp.c
+++ b/base/shell/cmd/filecomp.c
@@ -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;
diff --git a/base/shell/cmd/if.c b/base/shell/cmd/if.c
index 66526ee154a..e219a3db225 100644
--- a/base/shell/cmd/if.c
+++ b/base/shell/cmd/if.c
@@ -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);
diff --git a/base/shell/cmd/misc.c b/base/shell/cmd/misc.c
index cd7a08f7722..97b252e50ed 100644
--- a/base/shell/cmd/misc.c
+++ b/base/shell/cmd/misc.c
@@ -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));
}