mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Make file-existence test a per-platform function.
NFC in this commit, but this will allow me to do something more subtle and OS-specific in each OS's implementation of it.
This commit is contained in:
parent
36764ffbbe
commit
bbebdc8280
@ -164,7 +164,6 @@ void logfopen(void *handle)
|
|||||||
{
|
{
|
||||||
struct LogContext *ctx = (struct LogContext *)handle;
|
struct LogContext *ctx = (struct LogContext *)handle;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
FILE *fp;
|
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
/* Prevent repeat calls */
|
/* Prevent repeat calls */
|
||||||
@ -184,10 +183,8 @@ void logfopen(void *handle)
|
|||||||
conf_get_str(ctx->conf, CONF_host),
|
conf_get_str(ctx->conf, CONF_host),
|
||||||
conf_get_int(ctx->conf, CONF_port), &tm);
|
conf_get_int(ctx->conf, CONF_port), &tm);
|
||||||
|
|
||||||
fp = f_open(ctx->currlogfilename, "r", FALSE); /* file already present? */
|
if (open_for_write_would_lose_data(ctx->currlogfilename)) {
|
||||||
if (fp) {
|
|
||||||
int logxfovr = conf_get_int(ctx->conf, CONF_logxfovr);
|
int logxfovr = conf_get_int(ctx->conf, CONF_logxfovr);
|
||||||
fclose(fp);
|
|
||||||
if (logxfovr != LGXF_ASK) {
|
if (logxfovr != LGXF_ASK) {
|
||||||
mode = ((logxfovr == LGXF_OVR) ? 2 : 1);
|
mode = ((logxfovr == LGXF_OVR) ? 2 : 1);
|
||||||
} else
|
} else
|
||||||
|
1
putty.h
1
putty.h
@ -1467,6 +1467,7 @@ Filename *filename_deserialise(void *data, int maxsize, int *used);
|
|||||||
char *get_username(void); /* return value needs freeing */
|
char *get_username(void); /* return value needs freeing */
|
||||||
char *get_random_data(int bytes, const char *device); /* used in cmdgen.c */
|
char *get_random_data(int bytes, const char *device); /* used in cmdgen.c */
|
||||||
char filename_char_sanitise(char c); /* rewrite special pathname chars */
|
char filename_char_sanitise(char c); /* rewrite special pathname chars */
|
||||||
|
int open_for_write_would_lose_data(const Filename *fn);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exports and imports from timing.c.
|
* Exports and imports from timing.c.
|
||||||
|
@ -349,3 +349,14 @@ char *make_dir_path(const char *path, mode_t mode)
|
|||||||
pos += strspn(path + pos, "/");
|
pos += strspn(path + pos, "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int open_for_write_would_lose_data(const Filename *fn)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
if ((fp = f_open(fn, "r", FALSE)) != NULL) {
|
||||||
|
fclose(fp);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -587,3 +587,14 @@ FontSpec *fontspec_deserialise(void *vdata, int maxsize, int *used)
|
|||||||
GET_32BIT_MSB_FIRST(end + 4),
|
GET_32BIT_MSB_FIRST(end + 4),
|
||||||
GET_32BIT_MSB_FIRST(end + 8));
|
GET_32BIT_MSB_FIRST(end + 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int open_for_write_would_lose_data(const Filename *fn)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
if ((fp = f_open(fn, "r", FALSE)) != NULL) {
|
||||||
|
fclose(fp);
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user