Skip to content

Commit e56756e

Browse files
committed
Use Unix line endings instead of DOS ones, per Magnus.
1 parent e2fee8c commit e56756e

File tree

3 files changed

+329
-329
lines changed

3 files changed

+329
-329
lines changed

src/include/port/win32_msvc/dirent.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
/*
2-
* Headers for port/dirent.c, win32 native implementation of dirent functions
3-
*
4-
* $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.1 2006/06/07 22:24:45 momjian Exp $
5-
*/
6-
7-
#ifndef _WIN32VC_DIRENT_H
8-
#define _WIN32VC_DIRENT_H
9-
struct dirent {
10-
long d_ino;
11-
unsigned short d_reclen;
12-
unsigned short d_namlen;
13-
char d_name[MAX_PATH];
14-
};
15-
16-
typedef struct DIR DIR;
17-
18-
DIR* opendir(const char *);
19-
struct dirent* readdir(DIR *);
20-
int closedir(DIR*);
21-
#endif
1+
/*
2+
* Headers for port/dirent.c, win32 native implementation of dirent functions
3+
*
4+
* $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.2 2006/06/26 12:59:44 momjian Exp $
5+
*/
6+
7+
#ifndef _WIN32VC_DIRENT_H
8+
#define _WIN32VC_DIRENT_H
9+
struct dirent {
10+
long d_ino;
11+
unsigned short d_reclen;
12+
unsigned short d_namlen;
13+
char d_name[MAX_PATH];
14+
};
15+
16+
typedef struct DIR DIR;
17+
18+
DIR* opendir(const char *);
19+
struct dirent* readdir(DIR *);
20+
int closedir(DIR*);
21+
#endif

src/port/dirent.c

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
1-
/*-------------------------------------------------------------------------
2-
*
3-
* dirent.c
4-
* opendir/readdir/closedir for win32/msvc
5-
*
6-
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
7-
* Portions Copyright (c) 1994, Regents of the University of California
8-
*
9-
*
10-
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/dirent.c,v 1.1 2006/06/07 22:24:46 momjian Exp $
12-
*
13-
*-------------------------------------------------------------------------
14-
*/
15-
16-
#include "postgres.h"
17-
#include <dirent.h>
18-
19-
20-
struct DIR {
21-
char *dirname;
22-
struct dirent ret; /* Used to return to caller */
23-
HANDLE handle;
24-
};
25-
26-
DIR* opendir(const char *dirname)
27-
{
28-
DWORD attr;
29-
DIR *d;
30-
31-
/* Make sure it is a directory */
32-
attr = GetFileAttributes(dirname);
33-
if (attr == INVALID_FILE_ATTRIBUTES)
34-
{
35-
errno = ENOENT;
36-
return NULL;
37-
}
38-
if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
39-
{
40-
errno = ENOTDIR;
41-
return NULL;
42-
}
43-
44-
d = malloc(sizeof(DIR));
45-
if (!d)
46-
{
47-
errno = ENOMEM;
48-
return NULL;
49-
}
50-
d->dirname = malloc(strlen(dirname)+4);
51-
if (!d->dirname)
52-
{
53-
errno = ENOMEM;
54-
free(d);
55-
return NULL;
56-
}
57-
strcpy(d->dirname, dirname);
58-
if (d->dirname[strlen(d->dirname)-1] != '/' &&
59-
d->dirname[strlen(d->dirname)-1] != '\\')
60-
strcat(d->dirname,"\\"); /* Append backslash if not already there */
61-
strcat(d->dirname,"*"); /* Search for entries named anything */
62-
d->handle = INVALID_HANDLE_VALUE;
63-
d->ret.d_ino = 0; /* no inodes on win32 */
64-
d->ret.d_reclen = 0; /* not used on win32 */
65-
66-
return d;
67-
}
68-
69-
struct dirent* readdir(DIR * d)
70-
{
71-
WIN32_FIND_DATA fd;
72-
73-
if (d->handle == INVALID_HANDLE_VALUE)
74-
{
75-
d->handle = FindFirstFile(d->dirname, &fd);
76-
if (d->handle == INVALID_HANDLE_VALUE)
77-
{
78-
errno = ENOENT;
79-
return NULL;
80-
}
81-
}
82-
else
83-
{
84-
if (!FindNextFile(d->handle, &fd))
85-
{
86-
if (GetLastError() == ERROR_NO_MORE_FILES)
87-
{
88-
/* No more files, force errno=0 (unlike mingw) */
89-
errno = 0;
90-
return NULL;
91-
}
92-
_dosmaperr(GetLastError());
93-
return NULL;
94-
}
95-
}
96-
strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */
97-
d->ret.d_namlen = strlen(d->ret.d_name);
98-
return &d->ret;
99-
}
100-
101-
int closedir(DIR *d)
102-
{
103-
if (d->handle != INVALID_HANDLE_VALUE)
104-
FindClose(d->handle);
105-
free(d->dirname);
106-
free(d);
107-
return 0;
108-
}
1+
/*-------------------------------------------------------------------------
2+
*
3+
* dirent.c
4+
* opendir/readdir/closedir for win32/msvc
5+
*
6+
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $PostgreSQL: pgsql/src/port/dirent.c,v 1.2 2006/06/26 12:58:17 momjian Exp $
12+
*
13+
*-------------------------------------------------------------------------
14+
*/
15+
16+
#include "postgres.h"
17+
#include <dirent.h>
18+
19+
20+
struct DIR {
21+
char *dirname;
22+
struct dirent ret; /* Used to return to caller */
23+
HANDLE handle;
24+
};
25+
26+
DIR* opendir(const char *dirname)
27+
{
28+
DWORD attr;
29+
DIR *d;
30+
31+
/* Make sure it is a directory */
32+
attr = GetFileAttributes(dirname);
33+
if (attr == INVALID_FILE_ATTRIBUTES)
34+
{
35+
errno = ENOENT;
36+
return NULL;
37+
}
38+
if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
39+
{
40+
errno = ENOTDIR;
41+
return NULL;
42+
}
43+
44+
d = malloc(sizeof(DIR));
45+
if (!d)
46+
{
47+
errno = ENOMEM;
48+
return NULL;
49+
}
50+
d->dirname = malloc(strlen(dirname)+4);
51+
if (!d->dirname)
52+
{
53+
errno = ENOMEM;
54+
free(d);
55+
return NULL;
56+
}
57+
strcpy(d->dirname, dirname);
58+
if (d->dirname[strlen(d->dirname)-1] != '/' &&
59+
d->dirname[strlen(d->dirname)-1] != '\\')
60+
strcat(d->dirname,"\\"); /* Append backslash if not already there */
61+
strcat(d->dirname,"*"); /* Search for entries named anything */
62+
d->handle = INVALID_HANDLE_VALUE;
63+
d->ret.d_ino = 0; /* no inodes on win32 */
64+
d->ret.d_reclen = 0; /* not used on win32 */
65+
66+
return d;
67+
}
68+
69+
struct dirent* readdir(DIR * d)
70+
{
71+
WIN32_FIND_DATA fd;
72+
73+
if (d->handle == INVALID_HANDLE_VALUE)
74+
{
75+
d->handle = FindFirstFile(d->dirname, &fd);
76+
if (d->handle == INVALID_HANDLE_VALUE)
77+
{
78+
errno = ENOENT;
79+
return NULL;
80+
}
81+
}
82+
else
83+
{
84+
if (!FindNextFile(d->handle, &fd))
85+
{
86+
if (GetLastError() == ERROR_NO_MORE_FILES)
87+
{
88+
/* No more files, force errno=0 (unlike mingw) */
89+
errno = 0;
90+
return NULL;
91+
}
92+
_dosmaperr(GetLastError());
93+
return NULL;
94+
}
95+
}
96+
strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */
97+
d->ret.d_namlen = strlen(d->ret.d_name);
98+
return &d->ret;
99+
}
100+
101+
int closedir(DIR *d)
102+
{
103+
if (d->handle != INVALID_HANDLE_VALUE)
104+
FindClose(d->handle);
105+
free(d->dirname);
106+
free(d);
107+
return 0;
108+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy