summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2020-06-09 15:08:21 -0600
committerEduardo Chappa <chappa@washington.edu>2020-06-09 15:08:21 -0600
commitffe8da91ab561da34976c82aa5c5780f2925798f (patch)
treebcbc48cb7e627265c31bf71f37b8aad28b1d7e11
parent822c94d924415969073cd1dd090a8302ce4e9b4c (diff)
downloadalpine-ffe8da91ab561da34976c82aa5c5780f2925798f.tar.xz
* Fixes in the Windows code for the new external browser capability.
-rw-r--r--pith/init.c28
-rw-r--r--pith/osdep/creatdir.c10
-rw-r--r--pith/pine.hlp2
3 files changed, 34 insertions, 6 deletions
diff --git a/pith/init.c b/pith/init.c
index 5528943a..7b9377d6 100644
--- a/pith/init.c
+++ b/pith/init.c
@@ -623,10 +623,16 @@ html_dir_clean(int force)
{
HTML_LOG_S *h, prev, *j;
time_t now = time(0);
+#ifndef _WINDOWS
DIR *dirp;
struct dirent *d;
+#else
+ struct _finddata_t dbuf;
+ char buf[_MAX_PATH + 4];
+ long findrv;
+#endif /* _WINDOWS */
struct stat sbuf;
- char fpath[MAXPATH];
+ char fpath[MAXPATH], *fname;
int delete_happened = 0;
/* these are barriers to try to not to enter here */
@@ -640,18 +646,32 @@ html_dir_clean(int force)
if(our_stat(h->dir, &sbuf) < 0)
continue;
if((sbuf.st_mode & S_IFMT) == S_IFDIR){
+#ifndef _WINDOWS
if((dirp = opendir(h->dir)) != NULL){
while ((d = readdir(dirp)) != NULL){
- if(!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
+ fname = d->d_name;
+#else /* _WINDOWS */
+ snprintf(buf, sizeof(buf), "%s%s*.*", ps_global->html_dir, (ps_global->html_dir[strlen(ps_global->html_dir)-1] == '\\') ? "" : "\\");
+ buf[sizeof(buf)-1] = '\0';
+ if((findrv = _findfirst(buf, &dbuf)) < 0)
+ return;
+ do {
+ fname = fname_to_utf8(dbuf.name);
+#endif /* _WINDOWS */
+ if(!strcmp(fname, ".") || !strcmp(fname, ".."))
continue;
- if(strlen(h->dir) + strlen(d->d_name) + 3 < MAXPATH){
- snprintf(fpath, sizeof(fpath) - 1, "%s%s%s", h->dir, S_FILESEP, d->d_name);
+ if(strlen(h->dir) + strlen(fname) + 3 < MAXPATH){
+ snprintf(fpath, sizeof(fpath) - 1, "%s%s%s", h->dir, S_FILESEP, fname);
fpath[sizeof(fpath)-1] = '\0';
our_unlink(fpath);
}
+#ifndef _WINDOWS
}
closedir(dirp);
}
+#else /* _WINDOWS */
+ } while(_findnext(findrv, &dbuf) == 0);
+#endif /* _WINDOWS */
if(!our_rmdir(h->dir)){
h->to_delete = 0; /* mark it deleted */
delete_happened++;
diff --git a/pith/osdep/creatdir.c b/pith/osdep/creatdir.c
index 56ee4a75..380e9583 100644
--- a/pith/osdep/creatdir.c
+++ b/pith/osdep/creatdir.c
@@ -90,7 +90,15 @@ create_random_dir(char *dir, size_t len)
/* Some systems need this, on others we don't care if it fails */
our_chown(dir, getuid(), getgid());
#else
- dir = _mktemp(dir);
+ { int i;
+ char *s = &dir[strlen(dir) - 6];
+ for(i = 0; i < 10; i++){
+ sprintf(s, "%x%x%x", (unsigned int)(random() % 256), (unsigned int)(random() % 256),
+ (unsigned int)(random() % 256));
+ if(our_mkdir(dir, 0700) == 0) return dir;
+ }
+ *dir = '\0'; /* if we are here, we failed! */
+ }
#endif /* !_WINDOWS */
return(0);
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 3740b9c0..a52a7e10 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 438 2020-06-09 03:08:26
+Alpine Commit 439 2020-06-09 15:08:16
============= h_news =================
<HTML>
<HEAD>