Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
e56756e9
Commit
e56756e9
authored
Jun 26, 2006
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Unix line endings instead of DOS ones, per Magnus.
parent
e2fee8cf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
329 additions
and
329 deletions
+329
-329
src/include/port/win32_msvc/dirent.h
src/include/port/win32_msvc/dirent.h
+21
-21
src/port/dirent.c
src/port/dirent.c
+108
-108
src/port/win32error.c
src/port/win32error.c
+200
-200
No files found.
src/include/port/win32_msvc/dirent.h
View file @
e56756e9
/*
/*
* Headers for port/dirent.c, win32 native implementation of dirent functions
* Headers for port/dirent.c, win32 native implementation of dirent functions
*
*
* $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.
1 2006/06/07 22:24:45 momjian Exp $
* $PostgreSQL: pgsql/src/include/port/win32_msvc/dirent.h,v 1.
2 2006/06/26 12:59:44 momjian Exp $
*/
*/
#ifndef _WIN32VC_DIRENT_H
#ifndef _WIN32VC_DIRENT_H
#define _WIN32VC_DIRENT_H
#define _WIN32VC_DIRENT_H
struct
dirent
{
struct
dirent
{
long
d_ino
;
long
d_ino
;
unsigned
short
d_reclen
;
unsigned
short
d_reclen
;
unsigned
short
d_namlen
;
unsigned
short
d_namlen
;
char
d_name
[
MAX_PATH
];
char
d_name
[
MAX_PATH
];
};
};
typedef
struct
DIR
DIR
;
typedef
struct
DIR
DIR
;
DIR
*
opendir
(
const
char
*
);
DIR
*
opendir
(
const
char
*
);
struct
dirent
*
readdir
(
DIR
*
);
struct
dirent
*
readdir
(
DIR
*
);
int
closedir
(
DIR
*
);
int
closedir
(
DIR
*
);
#endif
#endif
src/port/dirent.c
View file @
e56756e9
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
*
*
* dirent.c
* dirent.c
* opendir/readdir/closedir for win32/msvc
* opendir/readdir/closedir for win32/msvc
*
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/dirent.c,v 1.
1 2006/06/07 22:24:46 momjian Exp $
* $PostgreSQL: pgsql/src/port/dirent.c,v 1.
2 2006/06/26 12:58:17 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include "postgres.h"
#include "postgres.h"
#include <dirent.h>
#include <dirent.h>
struct
DIR
{
struct
DIR
{
char
*
dirname
;
char
*
dirname
;
struct
dirent
ret
;
/* Used to return to caller */
struct
dirent
ret
;
/* Used to return to caller */
HANDLE
handle
;
HANDLE
handle
;
};
};
DIR
*
opendir
(
const
char
*
dirname
)
DIR
*
opendir
(
const
char
*
dirname
)
{
{
DWORD
attr
;
DWORD
attr
;
DIR
*
d
;
DIR
*
d
;
/* Make sure it is a directory */
/* Make sure it is a directory */
attr
=
GetFileAttributes
(
dirname
);
attr
=
GetFileAttributes
(
dirname
);
if
(
attr
==
INVALID_FILE_ATTRIBUTES
)
if
(
attr
==
INVALID_FILE_ATTRIBUTES
)
{
{
errno
=
ENOENT
;
errno
=
ENOENT
;
return
NULL
;
return
NULL
;
}
}
if
((
attr
&
FILE_ATTRIBUTE_DIRECTORY
)
!=
FILE_ATTRIBUTE_DIRECTORY
)
if
((
attr
&
FILE_ATTRIBUTE_DIRECTORY
)
!=
FILE_ATTRIBUTE_DIRECTORY
)
{
{
errno
=
ENOTDIR
;
errno
=
ENOTDIR
;
return
NULL
;
return
NULL
;
}
}
d
=
malloc
(
sizeof
(
DIR
));
d
=
malloc
(
sizeof
(
DIR
));
if
(
!
d
)
if
(
!
d
)
{
{
errno
=
ENOMEM
;
errno
=
ENOMEM
;
return
NULL
;
return
NULL
;
}
}
d
->
dirname
=
malloc
(
strlen
(
dirname
)
+
4
);
d
->
dirname
=
malloc
(
strlen
(
dirname
)
+
4
);
if
(
!
d
->
dirname
)
if
(
!
d
->
dirname
)
{
{
errno
=
ENOMEM
;
errno
=
ENOMEM
;
free
(
d
);
free
(
d
);
return
NULL
;
return
NULL
;
}
}
strcpy
(
d
->
dirname
,
dirname
);
strcpy
(
d
->
dirname
,
dirname
);
if
(
d
->
dirname
[
strlen
(
d
->
dirname
)
-
1
]
!=
'/'
&&
if
(
d
->
dirname
[
strlen
(
d
->
dirname
)
-
1
]
!=
'/'
&&
d
->
dirname
[
strlen
(
d
->
dirname
)
-
1
]
!=
'\\'
)
d
->
dirname
[
strlen
(
d
->
dirname
)
-
1
]
!=
'\\'
)
strcat
(
d
->
dirname
,
"
\\
"
);
/* Append backslash if not already there */
strcat
(
d
->
dirname
,
"
\\
"
);
/* Append backslash if not already there */
strcat
(
d
->
dirname
,
"*"
);
/* Search for entries named anything */
strcat
(
d
->
dirname
,
"*"
);
/* Search for entries named anything */
d
->
handle
=
INVALID_HANDLE_VALUE
;
d
->
handle
=
INVALID_HANDLE_VALUE
;
d
->
ret
.
d_ino
=
0
;
/* no inodes on win32 */
d
->
ret
.
d_ino
=
0
;
/* no inodes on win32 */
d
->
ret
.
d_reclen
=
0
;
/* not used on win32 */
d
->
ret
.
d_reclen
=
0
;
/* not used on win32 */
return
d
;
return
d
;
}
}
struct
dirent
*
readdir
(
DIR
*
d
)
struct
dirent
*
readdir
(
DIR
*
d
)
{
{
WIN32_FIND_DATA
fd
;
WIN32_FIND_DATA
fd
;
if
(
d
->
handle
==
INVALID_HANDLE_VALUE
)
if
(
d
->
handle
==
INVALID_HANDLE_VALUE
)
{
{
d
->
handle
=
FindFirstFile
(
d
->
dirname
,
&
fd
);
d
->
handle
=
FindFirstFile
(
d
->
dirname
,
&
fd
);
if
(
d
->
handle
==
INVALID_HANDLE_VALUE
)
if
(
d
->
handle
==
INVALID_HANDLE_VALUE
)
{
{
errno
=
ENOENT
;
errno
=
ENOENT
;
return
NULL
;
return
NULL
;
}
}
}
}
else
else
{
{
if
(
!
FindNextFile
(
d
->
handle
,
&
fd
))
if
(
!
FindNextFile
(
d
->
handle
,
&
fd
))
{
{
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
{
{
/* No more files, force errno=0 (unlike mingw) */
/* No more files, force errno=0 (unlike mingw) */
errno
=
0
;
errno
=
0
;
return
NULL
;
return
NULL
;
}
}
_dosmaperr
(
GetLastError
());
_dosmaperr
(
GetLastError
());
return
NULL
;
return
NULL
;
}
}
}
}
strcpy
(
d
->
ret
.
d_name
,
fd
.
cFileName
);
/* Both strings are MAX_PATH long */
strcpy
(
d
->
ret
.
d_name
,
fd
.
cFileName
);
/* Both strings are MAX_PATH long */
d
->
ret
.
d_namlen
=
strlen
(
d
->
ret
.
d_name
);
d
->
ret
.
d_namlen
=
strlen
(
d
->
ret
.
d_name
);
return
&
d
->
ret
;
return
&
d
->
ret
;
}
}
int
closedir
(
DIR
*
d
)
int
closedir
(
DIR
*
d
)
{
{
if
(
d
->
handle
!=
INVALID_HANDLE_VALUE
)
if
(
d
->
handle
!=
INVALID_HANDLE_VALUE
)
FindClose
(
d
->
handle
);
FindClose
(
d
->
handle
);
free
(
d
->
dirname
);
free
(
d
->
dirname
);
free
(
d
);
free
(
d
);
return
0
;
return
0
;
}
}
src/port/win32error.c
View file @
e56756e9
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
*
*
* win32error.c
* win32error.c
* Map win32 error codes to errno values
* Map win32 error codes to errno values
*
*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/win32error.c,v 1.
1 2006/06/07 22:24:46 momjian Exp $
* $PostgreSQL: pgsql/src/port/win32error.c,v 1.
2 2006/06/26 12:58:43 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
#include "postgres.h"
#include "postgres.h"
static
const
struct
static
const
struct
{
{
DWORD
winerr
;
DWORD
winerr
;
int
doserr
;
int
doserr
;
}
doserrors
[]
=
}
doserrors
[]
=
{
{
{
{
ERROR_INVALID_FUNCTION
,
EINVAL
ERROR_INVALID_FUNCTION
,
EINVAL
},
},
{
{
ERROR_FILE_NOT_FOUND
,
ENOENT
ERROR_FILE_NOT_FOUND
,
ENOENT
},
},
{
{
ERROR_PATH_NOT_FOUND
,
ENOENT
ERROR_PATH_NOT_FOUND
,
ENOENT
},
},
{
{
ERROR_TOO_MANY_OPEN_FILES
,
EMFILE
ERROR_TOO_MANY_OPEN_FILES
,
EMFILE
},
},
{
{
ERROR_ACCESS_DENIED
,
EACCES
ERROR_ACCESS_DENIED
,
EACCES
},
},
{
{
ERROR_INVALID_HANDLE
,
EBADF
ERROR_INVALID_HANDLE
,
EBADF
},
},
{
{
ERROR_ARENA_TRASHED
,
ENOMEM
ERROR_ARENA_TRASHED
,
ENOMEM
},
},
{
{
ERROR_NOT_ENOUGH_MEMORY
,
ENOMEM
ERROR_NOT_ENOUGH_MEMORY
,
ENOMEM
},
},
{
{
ERROR_INVALID_BLOCK
,
ENOMEM
ERROR_INVALID_BLOCK
,
ENOMEM
},
},
{
{
ERROR_BAD_ENVIRONMENT
,
E2BIG
ERROR_BAD_ENVIRONMENT
,
E2BIG
},
},
{
{
ERROR_BAD_FORMAT
,
ENOEXEC
ERROR_BAD_FORMAT
,
ENOEXEC
},
},
{
{
ERROR_INVALID_ACCESS
,
EINVAL
ERROR_INVALID_ACCESS
,
EINVAL
},
},
{
{
ERROR_INVALID_DATA
,
EINVAL
ERROR_INVALID_DATA
,
EINVAL
},
},
{
{
ERROR_INVALID_DRIVE
,
ENOENT
ERROR_INVALID_DRIVE
,
ENOENT
},
},
{
{
ERROR_CURRENT_DIRECTORY
,
EACCES
ERROR_CURRENT_DIRECTORY
,
EACCES
},
},
{
{
ERROR_NOT_SAME_DEVICE
,
EXDEV
ERROR_NOT_SAME_DEVICE
,
EXDEV
},
},
{
{
ERROR_NO_MORE_FILES
,
ENOENT
ERROR_NO_MORE_FILES
,
ENOENT
},
},
{
{
ERROR_LOCK_VIOLATION
,
EACCES
ERROR_LOCK_VIOLATION
,
EACCES
},
},
{
{
ERROR_SHARING_VIOLATION
,
EACCES
ERROR_SHARING_VIOLATION
,
EACCES
},
},
{
{
ERROR_BAD_NETPATH
,
ENOENT
ERROR_BAD_NETPATH
,
ENOENT
},
},
{
{
ERROR_NETWORK_ACCESS_DENIED
,
EACCES
ERROR_NETWORK_ACCESS_DENIED
,
EACCES
},
},
{
{
ERROR_BAD_NET_NAME
,
ENOENT
ERROR_BAD_NET_NAME
,
ENOENT
},
},
{
{
ERROR_FILE_EXISTS
,
EEXIST
ERROR_FILE_EXISTS
,
EEXIST
},
},
{
{
ERROR_CANNOT_MAKE
,
EACCES
ERROR_CANNOT_MAKE
,
EACCES
},
},
{
{
ERROR_FAIL_I24
,
EACCES
ERROR_FAIL_I24
,
EACCES
},
},
{
{
ERROR_INVALID_PARAMETER
,
EINVAL
ERROR_INVALID_PARAMETER
,
EINVAL
},
},
{
{
ERROR_NO_PROC_SLOTS
,
EAGAIN
ERROR_NO_PROC_SLOTS
,
EAGAIN
},
},
{
{
ERROR_DRIVE_LOCKED
,
EACCES
ERROR_DRIVE_LOCKED
,
EACCES
},
},
{
{
ERROR_BROKEN_PIPE
,
EPIPE
ERROR_BROKEN_PIPE
,
EPIPE
},
},
{
{
ERROR_DISK_FULL
,
ENOSPC
ERROR_DISK_FULL
,
ENOSPC
},
},
{
{
ERROR_INVALID_TARGET_HANDLE
,
EBADF
ERROR_INVALID_TARGET_HANDLE
,
EBADF
},
},
{
{
ERROR_INVALID_HANDLE
,
EINVAL
ERROR_INVALID_HANDLE
,
EINVAL
},
},
{
{
ERROR_WAIT_NO_CHILDREN
,
ECHILD
ERROR_WAIT_NO_CHILDREN
,
ECHILD
},
},
{
{
ERROR_CHILD_NOT_COMPLETE
,
ECHILD
ERROR_CHILD_NOT_COMPLETE
,
ECHILD
},
},
{
{
ERROR_DIRECT_ACCESS_HANDLE
,
EBADF
ERROR_DIRECT_ACCESS_HANDLE
,
EBADF
},
},
{
{
ERROR_NEGATIVE_SEEK
,
EINVAL
ERROR_NEGATIVE_SEEK
,
EINVAL
},
},
{
{
ERROR_SEEK_ON_DEVICE
,
EACCES
ERROR_SEEK_ON_DEVICE
,
EACCES
},
},
{
{
ERROR_DIR_NOT_EMPTY
,
ENOTEMPTY
ERROR_DIR_NOT_EMPTY
,
ENOTEMPTY
},
},
{
{
ERROR_NOT_LOCKED
,
EACCES
ERROR_NOT_LOCKED
,
EACCES
},
},
{
{
ERROR_BAD_PATHNAME
,
ENOENT
ERROR_BAD_PATHNAME
,
ENOENT
},
},
{
{
ERROR_MAX_THRDS_REACHED
,
EAGAIN
ERROR_MAX_THRDS_REACHED
,
EAGAIN
},
},
{
{
ERROR_LOCK_FAILED
,
EACCES
ERROR_LOCK_FAILED
,
EACCES
},
},
{
{
ERROR_ALREADY_EXISTS
,
EEXIST
ERROR_ALREADY_EXISTS
,
EEXIST
},
},
{
{
ERROR_FILENAME_EXCED_RANGE
,
ENOENT
ERROR_FILENAME_EXCED_RANGE
,
ENOENT
},
},
{
{
ERROR_NESTING_NOT_ALLOWED
,
EAGAIN
ERROR_NESTING_NOT_ALLOWED
,
EAGAIN
},
},
{
{
ERROR_NOT_ENOUGH_QUOTA
,
ENOMEM
ERROR_NOT_ENOUGH_QUOTA
,
ENOMEM
}
}
};
};
void
void
_dosmaperr
(
unsigned
long
e
)
_dosmaperr
(
unsigned
long
e
)
{
{
int
i
;
int
i
;
if
(
e
==
0
)
if
(
e
==
0
)
{
{
errno
=
0
;
errno
=
0
;
return
;
return
;
}
}
for
(
i
=
0
;
i
<
lengthof
(
doserrors
);
i
++
)
for
(
i
=
0
;
i
<
lengthof
(
doserrors
);
i
++
)
{
{
if
(
doserrors
[
i
].
winerr
==
e
)
if
(
doserrors
[
i
].
winerr
==
e
)
{
{
errno
=
doserrors
[
i
].
doserr
;
errno
=
doserrors
[
i
].
doserr
;
#ifndef FRONTEND
#ifndef FRONTEND
ereport
(
DEBUG5
,
ereport
(
DEBUG5
,
(
errmsg_internal
(
"mapped win32 error code %lu to %d"
,
(
errmsg_internal
(
"mapped win32 error code %lu to %d"
,
e
,
errno
)));
e
,
errno
)));
#else
#else
fprintf
(
stderr
,
_
(
"mapped win32 error code %lu to %d"
),
e
,
errno
);
fprintf
(
stderr
,
_
(
"mapped win32 error code %lu to %d"
),
e
,
errno
);
#endif
#endif
return
;
return
;
}
}
}
}
#ifndef FRONTEND
#ifndef FRONTEND
ereport
(
LOG
,
ereport
(
LOG
,
(
errmsg_internal
(
"unrecognized win32 error code: %lu"
,
(
errmsg_internal
(
"unrecognized win32 error code: %lu"
,
e
)));
e
)));
#else
#else
fprintf
(
stderr
,
_
(
"unrecognized win32 error code: %lu"
),
e
);
fprintf
(
stderr
,
_
(
"unrecognized win32 error code: %lu"
),
e
);
#endif
#endif
errno
=
EINVAL
;
errno
=
EINVAL
;
return
;
return
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment