Skip to content

Commit

Permalink
PAL unused functions cleanup (dotnet#1313)
Browse files Browse the repository at this point in the history
* Remove some unused PAL functions

* Remove SearchPathA

* Remove most of the clr::fs stuff

* Remove GetFileInformationByHandle

* Remove CompareFileTime from public PAL surface

* Remove GetLongPathName

* Remove GetShortPathName

* Remove some directory and file related functions

Make some of the functions private, but keep them in PAL as
too many PAL tests were using them and transforming those tests would
be waste of time.

* Remove non-existent PAL tests from the paltestlist.txt
  • Loading branch information
janvorli authored and jkotas committed Jan 7, 2020
1 parent 1ffda0f commit 578fe57
Show file tree
Hide file tree
Showing 128 changed files with 166 additions and 7,159 deletions.
5 changes: 0 additions & 5 deletions src/coreclr/src/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ nativeStringResourceTable_mscorrc_debug
#sscanf_s

#CopyFileW
#CreateDirectoryW
#CreateFileMappingA
#CreateFileMappingW
#CreateFileA
Expand Down Expand Up @@ -120,12 +119,10 @@ nativeStringResourceTable_mscorrc_debug
#GetFileSize
#GetFullPathNameW
#GetLastError
#GetLongPathNameW
#GetModuleFileNameW
#GetNumaHighestNodeNumber
#GetProcAddress
#GetProcessHeap
#GetShortPathNameW
#GetStdHandle
#GetSystemInfo
#GetSystemTime
Expand Down Expand Up @@ -159,12 +156,10 @@ nativeStringResourceTable_mscorrc_debug
#ReadFile
#ReleaseMutex
#ReleaseSemaphore
#RemoveDirectoryW
#ResetEvent
#ResumeThread
#SearchPathW
#SetEvent
#SetFileAttributesW
#SetFilePointer
#SetLastError
#SetErrorMode
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/src/inc/clr/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@
#define _clr_fs_h_

#include "fs/path.h"
#include "fs/file.h"
#include "fs/dir.h"

#endif // _clr_fs_h_
129 changes: 0 additions & 129 deletions src/coreclr/src/inc/clr/fs/dir.h

This file was deleted.

40 changes: 0 additions & 40 deletions src/coreclr/src/inc/clr/fs/file.h

This file was deleted.

75 changes: 0 additions & 75 deletions src/coreclr/src/inc/clr/fs/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,13 @@

#include "clr/str.h"

#ifndef LONG_FORMAT_PATH_PREFIX
#define LONG_FORMAT_PATH_PREFIX W("\\\\?\\")
#endif

namespace clr
{
namespace fs
{
// This list taken from ndp/clr/src/bcl/system/io/path.cs
SELECTANY WCHAR const g_rgInvalidPathChars[] =
{ W('"'), W('<'), W('>'), W('|'), W('\0'), (WCHAR)1, (WCHAR)2, (WCHAR)3, (WCHAR)4, (WCHAR)5, (WCHAR)6,
(WCHAR)7, (WCHAR)8, (WCHAR)9, (WCHAR)10, (WCHAR)11, (WCHAR)12, (WCHAR)13, (WCHAR)14,
(WCHAR)15, (WCHAR)16, (WCHAR)17, (WCHAR)18, (WCHAR)19, (WCHAR)20, (WCHAR)21, (WCHAR)22,
(WCHAR)23, (WCHAR)24, (WCHAR)25, (WCHAR)26, (WCHAR)27, (WCHAR)28, (WCHAR)29, (WCHAR)30,
(WCHAR)31 };

class Path
{
public:
//-----------------------------------------------------------------------------------------
static inline bool
Exists(
LPCWSTR wzPath)
{
DWORD attrs = WszGetFileAttributes(wzPath);
return (attrs != INVALID_FILE_ATTRIBUTES);
}

//-----------------------------------------------------------------------------------------
// Returns true if wzPath represents a long format path (i.e., prefixed with '\\?\').
static inline bool
HasLongFormatPrefix(LPCWSTR wzPath)
{
_ASSERTE(!clr::str::IsNullOrEmpty(wzPath)); // Must check this first.
return wcscmp(wzPath, LONG_FORMAT_PATH_PREFIX) == 0;
}

//-----------------------------------------------------------------------------------------
// Returns true if wzPath represents a relative path.
static inline bool
Expand Down Expand Up @@ -89,51 +59,6 @@ namespace clr

return true;
}

//-----------------------------------------------------------------------------------------
// Combines two path parts. wzPathLeft must be a directory path and may be either absolute
// or relative. wzPathRight may be a directory or file path and must be relative. The
// result is placed in wzBuffer and the number of chars written is placed in pcchBuffer on
// success; otherwise an error HRESULT is returned.
static HRESULT
Combine(LPCWSTR wzPathLeft, LPCWSTR wzPathRight, __in DWORD *pcchBuffer, __out_ecount(*pcchBuffer) LPWSTR wzBuffer)
{
STATIC_CONTRACT_NOTHROW;

HRESULT hr = S_OK;

if (clr::str::IsNullOrEmpty(wzPathLeft) || clr::str::IsNullOrEmpty(wzPathRight) || pcchBuffer == nullptr)
return E_INVALIDARG;

LPWSTR wzBuf = wzBuffer;
size_t cchBuf = *pcchBuffer;

IfFailRet(StringCchCopyExW(wzBuf, cchBuf, wzPathLeft, &wzBuf, &cchBuf, STRSAFE_NULL_ON_FAILURE));
IfFailRet(StringCchCatExW(wzBuf, cchBuf, wzBuf[-1] == DIRECTORY_SEPARATOR_CHAR_W ? W("") : DIRECTORY_SEPARATOR_STR_W, &wzBuf, &cchBuf, STRSAFE_NULL_ON_FAILURE));
IfFailRet(StringCchCatExW(wzBuf, cchBuf, wzPathRight, &wzBuf, &cchBuf, STRSAFE_NULL_ON_FAILURE));

return S_OK;
}

//-----------------------------------------------------------------------------------------
// Checks if the path provided is valid within the specified constraints.
// ***NOTE: does not yet check for invalid path characters.
static bool
IsValid(LPCWSTR wzPath, DWORD cchPath, bool fAllowLongFormat)
{
if (clr::str::IsNullOrEmpty(wzPath))
return false;

bool fIsLongFormat = HasLongFormatPrefix(wzPath);

if (fIsLongFormat && !fAllowLongFormat)
return false;

if (!fIsLongFormat && cchPath > _MAX_PATH)
return false;

return true;
}
};
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/src/inc/longfilepathwrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ MoveFileExWrapper(
_In_ DWORD dwFlags
);

BOOL
CreateDirectoryWrapper(
_In_ LPCWSTR lpPathName,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes
);

DWORD
SearchPathWrapper(
_In_opt_ LPCWSTR lpPath,
Expand Down
10 changes: 0 additions & 10 deletions src/coreclr/src/inc/winwrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
// winbase.h
#undef GetBinaryType
#undef GetShortPathName
#undef GetLongPathName
#undef GetEnvironmentStrings
#undef FreeEnvironmentStrings
#undef FormatMessage
Expand Down Expand Up @@ -94,20 +93,15 @@
#undef GetSystemDirectory
#undef GetTempPath
#undef GetTempFileName
#undef SetCurrentDirectory
#undef GetCurrentDirectory
#undef CreateDirectory
#undef RemoveDirectory
#undef GetFullPathName
#undef CreateFile
#undef SetFileAttributes
#undef GetFileAttributes
#undef GetFileAttributesEx
#undef DeleteFile
#undef FindFirstFileEx
#undef FindFirstFile
#undef FindNextFile
#undef SearchPath
#undef CopyFile
#undef CopyFileEx
#undef MoveFile
Expand All @@ -125,7 +119,6 @@

#undef SendMessage
#undef CharLower
#undef CharNext
#undef MessageBox
#undef GetClassName
#undef LoadString
Expand Down Expand Up @@ -181,7 +174,6 @@
#define WszGetMessage GetMessageW
#define WszSendMessage SendMessageW
#define WszCharLower CharLowerW
#define WszCharNext CharNextW
#define WszMessageBox LateboundMessageBoxW
#define WszGetClassName GetClassNameW
#define WszLoadString LoadStringW
Expand Down Expand Up @@ -234,7 +226,6 @@
#define WszFindFirstFileEx FindFirstFileExWrapper
#define WszFindNextFile FindNextFileW
#define WszMoveFileEx MoveFileExWrapper
#define WszCreateDirectory CreateDirectoryWrapper

//Can not use extended syntax
#define WszGetFullPathName GetFullPathNameW
Expand All @@ -252,7 +243,6 @@
//NOTE: IF the following API's are enabled ensure that they can work with LongFile Names
//See the usage and implementation of above API's
//
//#define WszSetCurrentDirectory SetCurrentDirectoryW
//#define WszGetBinaryType GetBinaryTypeWrapper //Coresys does not seem to have this API

#if FEATURE_PAL
Expand Down
Loading

0 comments on commit 578fe57

Please sign in to comment.