1.1 Binary file icons/vym.ico has changed
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/mkdtemp.cpp Wed Dec 05 14:58:03 2007 +0000
2.3 @@ -0,0 +1,67 @@
2.4 +#include <stdint.h>
2.5 +#include <string.h>
2.6 +#include <errno.h>
2.7 +#include <io.h>
2.8 +#include <sys/time.h>
2.9 +
2.10 +extern "C" {
2.11 +pid_t getpid (void);
2.12 +}
2.13 +
2.14 +char *
2.15 +mkdtemp(char *tmpl)
2.16 +{
2.17 + // Implementation based on GLIBC implementation.
2.18 +
2.19 + static const char letters[] =
2.20 + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
2.21 +
2.22 + static uint64_t value;
2.23 +
2.24 + const unsigned int ATTEMPTS_MIN = (62 * 62 * 62);
2.25 +
2.26 + int save_errno = errno;
2.27 +
2.28 + size_t len = strlen(tmpl);
2.29 + if (len < 6 || strcmp(&tmpl[len - 6], "XXXXXX"))
2.30 + {
2.31 + errno = EINVAL;
2.32 + return NULL;
2.33 + }
2.34 +
2.35 + char *XXXXXX = &tmpl[len - 6];
2.36 +
2.37 + uint64_t random_time_bits = time(NULL);
2.38 +
2.39 + value += (random_time_bits ^ getpid());
2.40 +
2.41 + unsigned int count;
2.42 + for (count = 0; count < ATTEMPTS_MIN; value += 7777, ++count)
2.43 + {
2.44 + uint64_t v = value;
2.45 +
2.46 + XXXXXX[0] = letters[v % 62];
2.47 + v /= 62;
2.48 + XXXXXX[1] = letters[v % 62];
2.49 + v /= 62;
2.50 + XXXXXX[2] = letters[v % 62];
2.51 + v /= 62;
2.52 + XXXXXX[3] = letters[v % 62];
2.53 + v /= 62;
2.54 + XXXXXX[4] = letters[v % 62];
2.55 + v /= 62;
2.56 + XXXXXX[5] = letters[v % 62];
2.57 +
2.58 + if (mkdir(tmpl) == 0)
2.59 + {
2.60 + errno = save_errno;
2.61 + return tmpl;
2.62 + }
2.63 +
2.64 + if (errno != EEXIST)
2.65 + return NULL;
2.66 + }
2.67 +
2.68 + errno = EEXIST;
2.69 + return NULL;
2.70 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/mkdtemp.h Wed Dec 05 14:58:03 2007 +0000
3.3 @@ -0,0 +1,6 @@
3.4 +#ifndef MKDTEMP_H
3.5 +#define MKDTEMP_H
3.6 +
3.7 +extern char *mkdtemp(char *_template);
3.8 +
3.9 +#endif
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/vym.rc Wed Dec 05 14:58:03 2007 +0000
4.3 @@ -0,0 +1,1 @@
4.4 +IDI_ICON1 ICON DISCARDABLE "icons/vym.ico"