Commits (1)
......@@ -12475,7 +12475,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
break;
if (strchr(&args[6], '\\'))
break;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
if (!get_cache_fn_subdir(rip.bbs, cache_path, sizeof(cache_path), "RIP"))
break;
strcat(cache_path, &args[6]);
fexistcase(cache_path);
......@@ -12596,7 +12596,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
* parameters, should be set to "10".
*/
handled = true;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
if (!get_cache_fn_subdir(rip.bbs, cache_path, sizeof(cache_path), "RIP"))
break;
GET_XY();
arg1 = parse_mega(&args[4], 2);
......@@ -13142,7 +13142,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
handled = true;
if (rip.clipboard == NULL)
break;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
if (!get_cache_fn_subdir(rip.bbs, cache_path, sizeof(cache_path), "RIP"))
break;
strcat(cache_path, &args[1]);
icn = fopen(cache_path, "wb");
......@@ -13280,7 +13280,7 @@ do_rip_command(int level, int sublevel, int cmd, const char *rawargs)
break;
if (arg3 < 0 || arg3 == 0 || arg3 == 5)
break;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
if (!get_cache_fn_subdir(rip.bbs, cache_path, sizeof(cache_path), "RIP"))
break;
size_t cpln = strlen(cache_path);
if (arg1 == 0) { // Download (from BBS)
......@@ -13907,7 +13907,7 @@ do_skypix(char *buf, size_t len)
p = sarg;
else
p++;
if (!get_cache_fn_base(rip.bbs, cache_path, sizeof(cache_path)))
if (!get_cache_fn_subdir(rip.bbs, cache_path, sizeof(cache_path), "SkyPix"))
break;
char *dldir = strdup(rip.bbs->dldir);
strcpy(rip.bbs->dldir, cache_path);
......
......@@ -2158,6 +2158,22 @@ int get_cache_fn_base(struct bbslist *bbs, char *fn, size_t fnsz)
return 1;
}
int get_cache_fn_subdir(struct bbslist *bbs, char *fn, size_t fnsz, const char *subdir)
{
int ret;
ret = get_cache_fn_base(bbs, fn, fnsz);
if (ret == 0)
return ret;
strcat(fn, subdir);
backslash(fn);
if (!isdir(fn))
mkpath(fn);
if (!isdir(fn))
return 0;
return 1;
}
static int clean_path(char *fn, size_t fnsz)
{
char *fp;
......@@ -2203,7 +2219,7 @@ static void apc_handler(char *strbuf, size_t slen, void *apcd)
if (!clean_path(fn, sizeof(fn)))
return;
p++;
sz = (slen - (p-strbuf)) * 3 / 4 + 1;
sz = (slen - (p-strbuf)) * 3 + 3 / 4 + 1;
buf = malloc(sz);
if (!buf)
return;
......
......@@ -30,5 +30,6 @@ BOOL doterm(struct bbslist *);
void mousedrag(struct vmem_cell *scrollback);
void get_cterm_size(int *cols, int *rows, int ns);
int get_cache_fn_base(struct bbslist *bbs, char *fn, size_t fnsz);
int get_cache_fn_subdir(struct bbslist *bbs, char *fn, size_t fnsz, const char *subdir);
#endif