Introducing functions global_open() and global_fopen() for these purposes:

- Removing duplicate code to generate error message text
- In the future they will most likely check secure_file_priv directory.


modified:
  storage/connect/filamdbf.cpp
  storage/connect/filamfix.cpp
  storage/connect/filamtxt.cpp
  storage/connect/filamvct.cpp
  storage/connect/libdoc.cpp
  storage/connect/maputil.cpp
  storage/connect/plgdbsem.h
  storage/connect/plgdbutl.cpp
  storage/connect/tabfmt.cpp
  storage/connect/tabmul.cpp
  storage/connect/tabxml.cpp
  storage/connect/xindex.cpp
This commit is contained in:
Alexander Barkov 2013-02-06 15:17:34 +04:00
commit 22a8fb03db
12 changed files with 140 additions and 94 deletions

View file

@ -215,10 +215,8 @@ PQRYRES DBFColumns(PGLOBAL g, char *fn, BOOL info)
/**************************************************************************/
PlugSetPath(filename, fn, PlgGetDataPath(g));
if (!(infile = fopen(filename, "rb"))) {
sprintf(g->Message, MSG(CANNOT_OPEN), filename);
if (!(infile= global_fopen(g, MSGID_CANNOT_OPEN, filename, "rb")))
return NULL;
} // endif file
/**************************************************************************/
/* Get the first 32 bytes of the header. */
@ -384,10 +382,8 @@ int DBFBASE::ScanHeader(PGLOBAL g, PSZ fname, int lrecl, char *defpath)
/************************************************************************/
PlugSetPath(filename, fname, defpath);
if (!(infile = fopen(filename, "rb"))) {
sprintf(g->Message, MSG(CANNOT_OPEN), filename);
if (!(infile= global_fopen(g, MSGID_CANNOT_OPEN, filename, "rb")))
return 0; // Assume file does not exist
} // endif file
/************************************************************************/
/* Get the first 32 bytes of the header. */
@ -487,9 +483,6 @@ bool DBFFAM::OpenTableFile(PGLOBAL g)
PlugSetPath(filename, To_File, Tdbp->GetPath());
if (!(Stream = PlugOpenFile(g, filename, opmode))) {
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
opmode, (int)errno, filename);
strcat(strcat(g->Message, ": "), strerror(errno));
#ifdef DEBTRACE
htrc("%s\n", g->Message);
#endif
@ -839,16 +832,18 @@ void DBFFAM::CloseTableFile(PGLOBAL g)
char filename[_MAX_PATH];
PlugSetPath(filename, To_File, Tdbp->GetPath());
Stream = fopen(filename, "r+b");
fseek(Stream, 4, SEEK_SET); // Get header.Records position
fwrite(&n, sizeof(int), 1, Stream);
fclose(Stream);
Stream = NULL;
Records = n; // Update Records value
} // endif n
if ((Stream= global_fopen(g, MSGID_OPEN_MODE_STRERROR, filename, "r+b")))
{
fseek(Stream, 4, SEEK_SET); // Get header.Records position
fwrite(&n, sizeof(int), 1, Stream);
fclose(Stream);
Stream= NULL;
Records= n; // Update Records value
}
} // endif n
} // endif n
} else // Finally close the file
rc = PlugCloseFile(g, To_Fb);