| File src/utils/utils.c changed (mode: 100644) (index 676a636f3..c8a996dae) |
| ... |
... |
enclose_in_dquotes(const char *str) |
| 406 |
406 |
} |
} |
| 407 |
407 |
|
|
| 408 |
408 |
const char * |
const char * |
| 409 |
|
make_name_unique(const char *filename) |
|
|
409 |
|
make_name_unique(const char filename[]) |
| 410 |
410 |
{ |
{ |
| 411 |
411 |
static char unique[PATH_MAX]; |
static char unique[PATH_MAX]; |
| 412 |
412 |
size_t len; |
size_t len; |
| |
| ... |
... |
make_name_unique(const char *filename) |
| 414 |
414 |
|
|
| 415 |
415 |
#ifndef _WIN32 |
#ifndef _WIN32 |
| 416 |
416 |
len = snprintf(unique, sizeof(unique), "%s_%u%u_00", filename, getppid(), |
len = snprintf(unique, sizeof(unique), "%s_%u%u_00", filename, getppid(), |
| 417 |
|
getpid()); |
|
|
417 |
|
get_pid()); |
| 418 |
418 |
#else |
#else |
| 419 |
|
/* TODO: fix name uniqualization on Windows */ |
|
| 420 |
|
len = snprintf(unique, sizeof(unique), "%s_%u%u_00", filename, 0, 0); |
|
|
419 |
|
/* TODO: think about better name uniqualization on Windows. */ |
|
420 |
|
len = snprintf(unique, sizeof(unique), "%s_%u_00", filename, get_pid()); |
| 421 |
421 |
#endif |
#endif |
| 422 |
422 |
i = 0; |
i = 0; |
| 423 |
423 |
|
|
| |
| ... |
... |
make_name_unique(const char *filename) |
| 428 |
428 |
return unique; |
return unique; |
| 429 |
429 |
} |
} |
| 430 |
430 |
|
|
|
431 |
|
unsigned int |
|
432 |
|
get_pid(void) |
|
433 |
|
{ |
|
434 |
|
#ifndef _WIN32 |
|
435 |
|
return getpid(); |
|
436 |
|
#else |
|
437 |
|
return GetCurrentProcessId(); |
|
438 |
|
#endif |
|
439 |
|
} |
|
440 |
|
|
| 431 |
441 |
char * |
char * |
| 432 |
442 |
get_command_name(const char line[], int raw, size_t buf_len, char buf[]) |
get_command_name(const char line[], int raw, size_t buf_len, char buf[]) |
| 433 |
443 |
{ |
{ |
| File src/utils/utils.h changed (mode: 100644) (index 4da208e35..2aaa8f0fe) |
| ... |
... |
const char * enclose_in_dquotes(const char *str); |
| 70 |
70 |
int my_chdir(const char *path); |
int my_chdir(const char *path); |
| 71 |
71 |
/* Makes filename unique by adding an unique suffix to it. |
/* Makes filename unique by adding an unique suffix to it. |
| 72 |
72 |
* Returns pointer to a statically allocated buffer */ |
* Returns pointer to a statically allocated buffer */ |
| 73 |
|
const char * make_name_unique(const char *filename); |
|
|
73 |
|
const char * make_name_unique(const char filename[]); |
|
74 |
|
/* Returns process identification in a portable way. */ |
|
75 |
|
unsigned int get_pid(void); |
| 74 |
76 |
/* Finds command name in the command line and writes it to the buf. |
/* Finds command name in the command line and writes it to the buf. |
| 75 |
77 |
* Raw mode will preserve quotes on Windows. |
* Raw mode will preserve quotes on Windows. |
| 76 |
78 |
* Returns a pointer to the argument list. */ |
* Returns a pointer to the argument list. */ |