Skip to content

Commit 1d240ef

Browse files
committed
Remove GetLStat
1 parent b4b2278 commit 1d240ef

7 files changed

Lines changed: 7 additions & 159 deletions

File tree

src/libpsl-native/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
add_library(psl-native SHARED
22
getstat.cpp
3-
getlstat.cpp
43
getpwuid.cpp
54
getuserfrompid.cpp
65
getfileowner.cpp

src/libpsl-native/src/getlstat.cpp

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/libpsl-native/src/getlstat.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/libpsl-native/src/isfile.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
//! @author Andrew Schwartzmeyer <andschwa@microsoft.com>
33
//! @brief returns if the path exists
44

5-
#include "getlstat.h"
65
#include "isfile.h"
76

8-
#include <errno.h>
7+
#include <assert.h>
98
#include <sys/types.h>
109
#include <sys/stat.h>
1110
#include <pwd.h>
@@ -24,21 +23,12 @@
2423
//! char* is marshaled as an LPStr, which on Linux is UTF-8.
2524
//! @endparblock
2625
//!
27-
//! @exception errno Passes this error via errno to GetLastError:
28-
//! - ERROR_INVALID_PARAMETER: parameter is not valid
29-
//!
3026
//! @retval true if path exists, false otherwise
3127
//!
3228
bool IsFile(const char* path)
3329
{
34-
errno = 0;
35-
36-
if (!path)
37-
{
38-
errno = ERROR_INVALID_PARAMETER;
39-
return false;
40-
}
30+
assert(path);
4131

4232
struct stat buf;
43-
return GetLStat(path, &buf) == 0;
33+
return lstat(path, &buf) == 0;
4434
}

src/libpsl-native/src/issymlink.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
//! @author George FLeming <v-geflem@microsoft.com>
33
//! @brief returns whether a path is a symbolic link
44

5-
#include "getlstat.h"
65
#include "issymlink.h"
76

8-
#include <errno.h>
7+
#include <assert.h>
98
#include <sys/types.h>
109
#include <sys/stat.h>
1110
#include <unistd.h>
@@ -22,36 +21,15 @@
2221
//! char* is marshaled as an LPStr, which on Linux is UTF-8.
2322
//! @endparblock
2423
//!
25-
//! @exception errno Passes these errors via errno to GetLastError:
26-
//! - ERROR_INVALID_PARAMETER: parameter is not valid
27-
//! - ERROR_FILE_NOT_FOUND: file does not exist
28-
//! - ERROR_ACCESS_DENIED: access is denied
29-
//! - ERROR_FILE_NOT_FOUND: the system cannot find the file specified
30-
//! - ERROR_INVALID_ADDRESS: attempt to access invalid address
31-
//! - ERROR_STOPPED_ON_SYMLINK: the operation stopped after reaching a symbolic link
32-
//! - ERROR_GEN_FAILURE: device attached to the system is not functioning
33-
//! - ERROR_NO_SUCH_USER: there was no corresponding entry in the utmp-file
34-
//! - ERROR_INVALID_NAME: filename, directory name, or volume label syntax is incorrect
35-
//! - ERROR_BUFFER_OVERFLOW: file name is too long
36-
//! - ERROR_INVALID_FUNCTION: incorrect function
37-
//! - ERROR_BAD_PATH_NAME: pathname is too long, or contains invalid characters
38-
//!
3924
//! @retval true if path is a symbolic link, false otherwise
4025
//!
4126

4227
bool IsSymLink(const char* path)
4328
{
44-
errno = 0;
45-
46-
// Check parameters
47-
if (!path)
48-
{
49-
errno = ERROR_INVALID_PARAMETER;
50-
return false;
51-
}
29+
assert(path);
5230

5331
struct stat buf;
54-
int32_t ret = GetLStat(path, &buf);
32+
int32_t ret = lstat(path, &buf);
5533
if (ret != 0)
5634
{
5735
return false;

src/libpsl-native/test/test-isfile.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,5 @@ TEST(IsFileTest, BinLsIsFile)
2020
TEST(IsFileTest, CannotGetOwnerOfFakeFile)
2121
{
2222
EXPECT_FALSE(IsFile("SomeMadeUpFileNameThatDoesNotExist"));
23-
EXPECT_EQ(errno, ERROR_FILE_NOT_FOUND);
24-
}
25-
26-
TEST(IsFileTest, ReturnsFalseForNullInput)
27-
{
28-
EXPECT_FALSE(IsFile(NULL));
29-
EXPECT_EQ(errno, ERROR_INVALID_PARAMETER);
23+
EXPECT_EQ(errno, ENOENT);
3024
}

src/libpsl-native/test/test-issymlink.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ class isSymLinkTest : public ::testing::Test
5555
}
5656
};
5757

58-
TEST_F(isSymLinkTest, FilePathNameIsNull)
59-
{
60-
EXPECT_FALSE(IsSymLink(NULL));
61-
EXPECT_EQ(ERROR_INVALID_PARAMETER, errno);
62-
}
63-
6458
TEST_F(isSymLinkTest, FilePathNameDoesNotExist)
6559
{
6660
std::string invalidFile = "/tmp/symlinktest_invalidFile";

0 commit comments

Comments
 (0)