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
ba7c5975
Commit
ba7c5975
authored
Oct 18, 2013
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move pgfnames() from libpgport to libpgcommon
It requires pstrdup() from libpgcommon.
parent
cab5dc5d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
93 deletions
+112
-93
src/bin/initdb/nls.mk
src/bin/initdb/nls.mk
+1
-1
src/common/Makefile
src/common/Makefile
+1
-1
src/common/pgfnames.c
src/common/pgfnames.c
+109
-0
src/port/dirmod.c
src/port/dirmod.c
+0
-90
src/tools/msvc/Mkvcbuild.pm
src/tools/msvc/Mkvcbuild.pm
+1
-1
No files found.
src/bin/initdb/nls.mk
View file @
ba7c5975
# src/bin/initdb/nls.mk
CATALOG_NAME
=
initdb
AVAIL_LANGUAGES
=
cs de es fr it ja pl pt_BR ru zh_CN
GETTEXT_FILES
=
findtimezone.c initdb.c ../../common/exec.c ../../common/fe_memutils.c ../../common/wait_error.c ../../port/dirmod.c
GETTEXT_FILES
=
findtimezone.c initdb.c ../../common/exec.c ../../common/fe_memutils.c ../../common/
pgfnames.c ../../common/
wait_error.c ../../port/dirmod.c
GETTEXT_TRIGGERS
=
simple_prompt
src/common/Makefile
View file @
ba7c5975
...
...
@@ -23,7 +23,7 @@ include $(top_builddir)/src/Makefile.global
override CPPFLAGS
:
= -DFRONTEND $(CPPFLAGS)
LIBS
+=
$(PTHREAD_LIBS)
OBJS_COMMON
=
exec.o relpath.o wait_error.o
OBJS_COMMON
=
exec.o
pgfnames.o
relpath.o wait_error.o
OBJS_FRONTEND
=
$(OBJS_COMMON)
fe_memutils.o
...
...
src/common/pgfnames.c
0 → 100644
View file @
ba7c5975
/*-------------------------------------------------------------------------
*
* pgfnames.c
* directory handling functions
*
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/common/pgfnames.c
*
*-------------------------------------------------------------------------
*/
#ifndef FRONTEND
#include "postgres.h"
#else
#include "postgres_fe.h"
#endif
#include <dirent.h>
/*
* pgfnames
*
* return a list of the names of objects in the argument directory. Caller
* must call pgfnames_cleanup later to free the memory allocated by this
* function.
*/
char
**
pgfnames
(
const
char
*
path
)
{
DIR
*
dir
;
struct
dirent
*
file
;
char
**
filenames
;
int
numnames
=
0
;
int
fnsize
=
200
;
/* enough for many small dbs */
dir
=
opendir
(
path
);
if
(
dir
==
NULL
)
{
#ifndef FRONTEND
elog
(
WARNING
,
"could not open directory
\"
%s
\"
: %m"
,
path
);
#else
fprintf
(
stderr
,
_
(
"could not open directory
\"
%s
\"
: %s
\n
"
),
path
,
strerror
(
errno
));
#endif
return
NULL
;
}
filenames
=
(
char
**
)
palloc
(
fnsize
*
sizeof
(
char
*
));
errno
=
0
;
while
((
file
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
file
->
d_name
,
"."
)
!=
0
&&
strcmp
(
file
->
d_name
,
".."
)
!=
0
)
{
if
(
numnames
+
1
>=
fnsize
)
{
fnsize
*=
2
;
filenames
=
(
char
**
)
repalloc
(
filenames
,
fnsize
*
sizeof
(
char
*
));
}
filenames
[
numnames
++
]
=
pstrdup
(
file
->
d_name
);
}
errno
=
0
;
}
#ifdef WIN32
/*
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
* released version
*/
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
errno
=
0
;
#endif
if
(
errno
)
{
#ifndef FRONTEND
elog
(
WARNING
,
"could not read directory
\"
%s
\"
: %m"
,
path
);
#else
fprintf
(
stderr
,
_
(
"could not read directory
\"
%s
\"
: %s
\n
"
),
path
,
strerror
(
errno
));
#endif
}
filenames
[
numnames
]
=
NULL
;
closedir
(
dir
);
return
filenames
;
}
/*
* pgfnames_cleanup
*
* deallocate memory used for filenames
*/
void
pgfnames_cleanup
(
char
**
filenames
)
{
char
**
fn
;
for
(
fn
=
filenames
;
*
fn
;
fn
++
)
pfree
(
*
fn
);
pfree
(
filenames
);
}
src/port/dirmod.c
View file @
ba7c5975
...
...
@@ -28,7 +28,6 @@
#endif
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#if defined(WIN32) || defined(__CYGWIN__)
...
...
@@ -352,95 +351,6 @@ pgwin32_is_junction(char *path)
#endif
/* defined(WIN32) && !defined(__CYGWIN__) */
/*
* pgfnames
*
* return a list of the names of objects in the argument directory. Caller
* must call pgfnames_cleanup later to free the memory allocated by this
* function.
*/
char
**
pgfnames
(
const
char
*
path
)
{
DIR
*
dir
;
struct
dirent
*
file
;
char
**
filenames
;
int
numnames
=
0
;
int
fnsize
=
200
;
/* enough for many small dbs */
dir
=
opendir
(
path
);
if
(
dir
==
NULL
)
{
#ifndef FRONTEND
elog
(
WARNING
,
"could not open directory
\"
%s
\"
: %m"
,
path
);
#else
fprintf
(
stderr
,
_
(
"could not open directory
\"
%s
\"
: %s
\n
"
),
path
,
strerror
(
errno
));
#endif
return
NULL
;
}
filenames
=
(
char
**
)
palloc
(
fnsize
*
sizeof
(
char
*
));
errno
=
0
;
while
((
file
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strcmp
(
file
->
d_name
,
"."
)
!=
0
&&
strcmp
(
file
->
d_name
,
".."
)
!=
0
)
{
if
(
numnames
+
1
>=
fnsize
)
{
fnsize
*=
2
;
filenames
=
(
char
**
)
repalloc
(
filenames
,
fnsize
*
sizeof
(
char
*
));
}
filenames
[
numnames
++
]
=
pstrdup
(
file
->
d_name
);
}
errno
=
0
;
}
#ifdef WIN32
/*
* This fix is in mingw cvs (runtime/mingwex/dirent.c rev 1.4), but not in
* released version
*/
if
(
GetLastError
()
==
ERROR_NO_MORE_FILES
)
errno
=
0
;
#endif
if
(
errno
)
{
#ifndef FRONTEND
elog
(
WARNING
,
"could not read directory
\"
%s
\"
: %m"
,
path
);
#else
fprintf
(
stderr
,
_
(
"could not read directory
\"
%s
\"
: %s
\n
"
),
path
,
strerror
(
errno
));
#endif
}
filenames
[
numnames
]
=
NULL
;
closedir
(
dir
);
return
filenames
;
}
/*
* pgfnames_cleanup
*
* deallocate memory used for filenames
*/
void
pgfnames_cleanup
(
char
**
filenames
)
{
char
**
fn
;
for
(
fn
=
filenames
;
*
fn
;
fn
++
)
pfree
(
*
fn
);
pfree
(
filenames
);
}
/*
* rmtree
*
...
...
src/tools/msvc/Mkvcbuild.pm
View file @
ba7c5975
...
...
@@ -74,7 +74,7 @@ sub mkvcbuild
win32error.c win32setlocale.c)
;
our
@pgcommonallfiles
=
qw(
exec.c relpath.c wait_error.c)
;
exec.c
pgfnames.c
relpath.c wait_error.c)
;
our
@pgcommonfrontendfiles
=
(
@pgcommonallfiles
,
qw(fe_memutils.c)
);
...
...
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