commit bb9bb2324852db731d81ee8c1f16a9b0b0fc31df
Author: Roman Fomin <rfomin@gmail.com>
AuthorDate: Tue Oct 29 18:48:26 2024 +0700
Commit: GitHub <noreply@github.com>
CommitDate: Tue Oct 29 12:48:26 2024 +0100
Remove unused functions, remove `struct __dir` from header (#1711)
This should fix building with old Windows headers.
---
win32/win_opendir.c | 88 +++++------------------------------------------------
win32/win_opendir.h | 20 ------------
2 files changed, 8 insertions(+), 100 deletions(-)
diff --git a/win32/win_opendir.c b/win32/win_opendir.c
index 0c7c91ed..59a5979b 100644
--- a/win32/win_opendir.c
+++ b/win32/win_opendir.c
@@ -45,6 +45,14 @@ SOFTWARE.
#define FILE_NAME_NORMALIZED 0
#endif /* FILE_NAME_NORMALIZED */
+struct __dir
+{
+ struct dirent *entries;
+ intptr_t fd;
+ long int count;
+ long int index;
+};
+
int closedir(DIR *dirp)
{
struct __dir *data = NULL;
@@ -327,52 +335,6 @@ DIR *opendir(const char *name)
return dirp;
}
-DIR *_wopendir(const wchar_t *name)
-{
- DIR *dirp = NULL;
- wchar_t *wname = __get_buffer();
- int size = 0;
- if (!wname)
- {
- errno = ENOMEM;
- return NULL;
- }
- size = (int) wcslen(name);
- if (size > NTFS_MAX_PATH)
- {
- free(wname);
- return NULL;
- }
- memcpy(wname + 4, name, sizeof(wchar_t) * (size + 1));
- dirp = __internal_opendir(wname, size + 5);
- free(wname);
- return dirp;
-}
-
-DIR *fdopendir(intptr_t fd)
-{
- DIR *dirp = NULL;
- wchar_t *wname = __get_buffer();
- int size = 0;
-
- if (!wname)
- {
- errno = ENOMEM;
- return NULL;
- }
- size = GetFinalPathNameByHandleW((HANDLE) fd, wname + 4, NTFS_MAX_PATH,
- FILE_NAME_NORMALIZED);
- if (0 == size)
- {
- free(wname);
- errno = ENOTDIR;
- return NULL;
- }
- dirp = __internal_opendir(wname, size + 5);
- free(wname);
- return dirp;
-}
-
struct dirent *readdir(DIR *dirp)
{
struct __dir *data = (struct __dir *) dirp;
@@ -388,38 +350,4 @@ struct dirent *readdir(DIR *dirp)
return NULL;
}
-void seekdir(DIR *dirp, long int offset)
-{
- if (dirp)
- {
- struct __dir *data = (struct __dir *) dirp;
- data->index = (offset < data->count) ? offset : data->index;
- }
-}
-
-void rewinddir(DIR *dirp)
-{
- seekdir(dirp, 0);
-}
-
-long int telldir(DIR *dirp)
-{
- if (!dirp)
- {
- errno = EBADF;
- return -1;
- }
- return ((struct __dir *) dirp)->count;
-}
-
-intptr_t dirfd(DIR *dirp)
-{
- if (!dirp)
- {
- errno = EINVAL;
- return -1;
- }
- return ((struct __dir *) dirp)->fd;
-}
-
#endif /* _WIN32 */
diff --git a/win32/win_opendir.h b/win32/win_opendir.h
index 94c9d2c8..bfc62622 100644
--- a/win32/win_opendir.h
+++ b/win32/win_opendir.h
@@ -99,32 +99,12 @@ struct dirent
char d_name[NAME_MAX];
};
-struct __dir
-{
- struct dirent *entries;
- intptr_t fd;
- long int count;
- long int index;
-};
-
int closedir(DIR *dirp);
DIR *opendir(const char *name);
-DIR *_wopendir(const wchar_t *name);
-
-DIR *fdopendir(intptr_t fd);
-
struct dirent *readdir(DIR *dirp);
-void seekdir(DIR *dirp, long int offset);
-
-void rewinddir(DIR *dirp);
-
-long int telldir(DIR *dirp);
-
-intptr_t dirfd(DIR *dirp);
-
#endif /* WIN_OPENDIR_H */
#endif /* _WIN32 */