Clean up IsDirectory

This commit is contained in:
Andrew Schwartzmeyer
2016-10-14 15:42:59 -07:00
parent 2a6b84ed1b
commit 8b3e8be1bc
2 changed files with 3 additions and 18 deletions
+2 -11
View File
@@ -7,7 +7,7 @@
#include "getfileowner.h"
#include "isdirectory.h"
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <pwd.h>
@@ -25,20 +25,11 @@
//! char* is marshaled as an LPStr, which on Linux is UTF-8.
//! @endparblock
//!
//! @exception errno Passes this error via errno to GetLastError:
//! - ERROR_INVALID_PARAMETER: parameter is not valid
//!
//! @retval true if directory, false otherwise
//!
bool IsDirectory(const char* path)
{
errno = 0;
if (!path)
{
errno = ERROR_INVALID_PARAMETER;
return false;
}
assert(path);
struct stat buf;
int32_t ret = GetStat(path, &buf);
+1 -7
View File
@@ -21,11 +21,5 @@ TEST(IsDirectoryTest, BinLsIsNotDirectory)
TEST(IsDirectoryTest, ReturnsFalseForFakeDirectory)
{
EXPECT_FALSE(IsDirectory("SomeMadeUpFileNameThatDoesNotExist"));
EXPECT_EQ(errno, ERROR_FILE_NOT_FOUND);
}
TEST(IsDirectoryTest, ReturnsFalseForNullInput)
{
EXPECT_FALSE(IsDirectory(NULL));
EXPECT_EQ(errno, ERROR_INVALID_PARAMETER);
EXPECT_EQ(ENOENT, errno);
}