Icon now supports the res:// protocol

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7328 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2021-09-18 20:24:41 +00:00
parent cc431158fd
commit 167e53df8a
6 changed files with 266 additions and 127 deletions

View file

@ -29,8 +29,8 @@
# include <stdio.h>
# include <unistd.h>
#endif
#include <stdarg.h>
#include <stdio.h>
extern double my_wtof(const wchar_t *str);
extern size_t my_strncpy(TCHAR*Dest, const TCHAR*Src, size_t cchMax);
@ -109,6 +109,49 @@ public:
int sane_system(const TCHAR *command);
template<class S> static size_t freadall(void*b, size_t cb, S*s) { return cb == fread(b, 1, cb, s) ? cb : 0; }
template<class T, class S> static inline size_t freadpod(T&b, S*s) { return freadall(b, sizeof(T), s); }
struct CStdFileStreamOnMemory
{
typedef CStdFileStreamOnMemory S_t;
BYTE*m_Base;
size_t m_cb, m_pos;
template<class T> CStdFileStreamOnMemory(T*p, size_t cb) : m_Base((BYTE*)p), m_cb(cb), m_pos(0) {}
template<class V> static inline bool assignfp(fpos_t*p, V v)
{
if (sizeof(p) >= sizeof(v)) return (*(V*)p = v, true);
UINT t = (UINT) v;
return t == v && sizeof(p) >= sizeof(t) && assignfp(p, t);
}
template<class V> static inline void readfp(V&v, const fpos_t*p) { v = sizeof(p) >= sizeof(v) ? *(V*)p : *(UINT*)p; }
friend inline size_t fclose(S_t*s) { return 0; }
friend int fgetpos(S_t*s, fpos_t*pos) { return assignfp(pos, s->m_pos) ? 0 : 1; }
friend int fsetpos(S_t*s, const fpos_t*pos) { size_t v; readfp(v, pos); return v < s->m_cb ? (s->m_pos = v, 0) : 1; }
friend int fseek(S_t*s, long int offset, int origin)
{
if ((unsigned long) offset != (size_t) offset) return 1; // long int will usually fit in our size_t
size_t newpos, invalid = 0;
switch(origin)
{
case SEEK_SET: newpos = (size_t) offset, invalid = offset < 0; break;
case SEEK_CUR: newpos = s->m_pos + offset; break;
case SEEK_END: newpos = s->m_cb + offset; break;
default: ++invalid;
}
if (!(invalid += s->m_cb <= newpos)) s->m_pos = newpos;
return (int) invalid;
}
friend size_t fread(void*b, size_t e, size_t c, S_t*s)
{
size_t cb = e * c, endpos = s->m_pos + cb;
if (endpos < s->m_pos || cb < c) return 0; // EOF/Overflow
if (s->m_cb < endpos) cb = s->m_cb - s->m_pos; // EOF
memcpy(b, s->m_Base + s->m_pos, cb);
return (s->m_pos += cb, cb);
}
};
#define NSISRT_DEFINEGLOBALS() int g_display_errors=1; FILE *g_output=stdout, *g_errout=stderr
void PrintColorFmtErrMsg(const TCHAR *fmtstr, va_list args);
void PrintColorFmtMsg(unsigned int type, const TCHAR *fmtstr, va_list args);