MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / create_file_names

Function create_file_names

extern/btyacc/main.c:301–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299
300
301void create_file_names()
302{
303 int i, len;
304
305 char* tmpdir = getenv("TMPDIR");
306 if (tmpdir == 0)
307 tmpdir = DEFAULT_TMPDIR;
308
309 len = strlen(tmpdir);
310 i = len + strlen(temp_form) + 1;
311 if (len && tmpdir[len-1] != DIR_CHAR)
312 ++i;
313
314 action_file_name = MALLOC(i);
315 if (action_file_name == 0)
316 no_space();
317 text_file_name = MALLOC(i);
318 if (text_file_name == 0)
319 no_space();
320 union_file_name = MALLOC(i);
321 if (union_file_name == 0)
322 no_space();
323
324 strcpy(action_file_name, tmpdir);
325 strcpy(text_file_name, tmpdir);
326 strcpy(union_file_name, tmpdir);
327
328 if (len && tmpdir[len - 1] != DIR_CHAR)
329 {
330 action_file_name[len] = DIR_CHAR;
331 text_file_name[len] = DIR_CHAR;
332 union_file_name[len] = DIR_CHAR;
333 ++len;
334 }
335
336 strcpy(action_file_name + len, temp_form);
337 strcpy(text_file_name + len, temp_form);
338 strcpy(union_file_name + len, temp_form);
339
340 action_file_name[len + 5] = 'a';
341 text_file_name[len + 5] = 't';
342 union_file_name[len + 5] = 'u';
343
344 if(mktemp(action_file_name) == NULL) {
345 fprintf(stderr, "btyacc: Cannot create temporary file\n");
346 exit(1);
347 }
348 if(mktemp(text_file_name) == NULL) {
349 fprintf(stderr, "btyacc: Cannot create temporary file\n");
350 exit(1);
351 }
352 if(mktemp(union_file_name) == NULL) {
353 fprintf(stderr, "btyacc: Cannot create temporary file\n");
354 exit(1);
355 }
356
357 len = strlen(file_prefix);
358

Callers 1

open_filesFunction · 0.85

Calls 1

no_spaceFunction · 0.85

Tested by

no test coverage detected