MCPcopy Create free account
hub / github.com/MariaDB/server / DeleteIndexFile

Method DeleteIndexFile

storage/connect/tabdos.cpp:249–331  ·  view source on GitHub ↗

/ DeleteIndexFile: Delete DOS/UNIX index file(s) using platform API. */ /

Source from the content-addressed store, hash-verified

247/* DeleteIndexFile: Delete DOS/UNIX index file(s) using platform API. */
248/***********************************************************************/
249bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
250 {
251 PCSZ ftype;
252 char filename[_MAX_PATH];
253 bool sep, rc = false;
254
255 if (!To_Indx)
256 return false; // No index
257
258 // If true indexes are in separate files
259 sep = GetBoolCatInfo("SepIndex", false);
260
261 if (!sep && pxdf) {
262 safe_strcpy(g->Message, sizeof(g->Message), MSG(NO_RECOV_SPACE));
263 return true;
264 } // endif sep
265
266 switch (Recfm) {
267 case RECFM_VAR: ftype = ".dnx"; break;
268 case RECFM_FIX: ftype = ".fnx"; break;
269 case RECFM_BIN: ftype = ".bnx"; break;
270 case RECFM_VCT: ftype = ".vnx"; break;
271 case RECFM_CSV: ftype = ".cnx"; break;
272 case RECFM_DBF: ftype = ".dbx"; break;
273 default:
274 snprintf(g->Message, sizeof(g->Message), MSG(BAD_RECFM_VAL), Recfm);
275 return true;
276 } // endswitch Ftype
277
278 /*********************************************************************/
279 /* Check for existence of an index file. */
280 /*********************************************************************/
281 if (sep) {
282 // Indexes are save in separate files
283#if defined(_WIN32)
284 char drive[_MAX_DRIVE];
285#else
286 char *drive = NULL;
287#endif
288 char direc[_MAX_DIR];
289 char fname[_MAX_FNAME];
290 bool all = !pxdf;
291
292 if (all)
293 pxdf = To_Indx;
294
295 for (; pxdf; pxdf = pxdf->GetNext()) {
296 _splitpath(Ofn, drive, direc, fname, NULL);
297 safe_strcat(fname, sizeof(fname), "_");
298 safe_strcat(fname, sizeof(fname), pxdf->GetName());
299 _makepath(filename, drive, direc, fname, ftype);
300 PlugSetPath(filename, filename, GetPath());
301#if defined(_WIN32)
302 if (!DeleteFile(filename))
303 rc |= (GetLastError() != ERROR_FILE_NOT_FOUND);
304#else // UNIX
305 if (remove(filename))
306 rc |= (errno != ENOENT);

Callers 3

ResetTableOptMethod · 0.80
MakeIndexMethod · 0.80
external_lockMethod · 0.80

Calls 10

safe_strcpyFunction · 0.85
_splitpathFunction · 0.85
safe_strcatFunction · 0.85
_makepathFunction · 0.85
GetLastErrorFunction · 0.85
removeFunction · 0.85
PlugRemoveTypeFunction · 0.85
PlugSetPathFunction · 0.70
GetNextMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected