tahoma2d/toonz/sources/image/compatibility/tfile_io.c
Rozhuk Ivan a7b6545028 Add FreeBSD (tested) and other BSD systems (not tested) to build and run.
I fail to build TIFF code: it requires access to libtiff internals but it
unavailable with libtiff prom ports. Probably pre build form
thirdparty/tiff-4.0.3 should fix this, but I don't check this.
Tiff code disabled for work but available in options.

I fail with SSE2 too, there is some mess with class initialization:
TRaster32P rout32 = rout; have no idea how to fix it.
If some one want to play with it, then try to build with
CFLAGS+= -DUSE_SSE2 -DDWORD=uint32_t -D_aligned_malloc=aligned_alloc -D_aligned_free=free
on non windows system.

FarmServer::queryHwInfo() - now uses TSystem::***() to collect system info,
to avoid code duplication.

Add pthread as required lib.
2021-08-31 11:10:48 -04:00

93 lines
1.9 KiB
C

#include "tfile_io.h"
#ifdef _WIN32
#include <windows.h>
#include <assert.h>
static LPSTR AtlW2AHelper(LPSTR lpa, LPCWSTR lpw, int nChars, UINT acp) {
assert(lpw != NULL);
assert(lpa != NULL);
/*
verify that no illegal character present
since lpa was allocated based on the size of lpw
don t worry about the number of chars
*/
lpa[0] = '\0';
WideCharToMultiByte(acp, 0, lpw, -1, lpa, nChars, NULL, NULL);
return lpa;
}
char *convertWCHAR2CHAR(const wchar_t *fname) {
int size = 0;
LPCWSTR lpw = fname;
char *name = NULL;
char *outName = 0;
if (lpw) {
LPSTR pStr = 0;
size = (lstrlenW(lpw) + 1) * 2;
pStr = (LPSTR)malloc(size * sizeof(char));
name = AtlW2AHelper(pStr, lpw, size, 0);
}
return name;
}
#else
#include <stdlib.h>
char *convertWCHAR2CHAR(const wchar_t *wc) {
int count = 0;
const wchar_t *ptr = wc;
char *c = 0;
char *buff;
while ((*ptr) != '\0') {
++count;
++ptr;
}
c = (char *)malloc((count + 1) * sizeof(char));
buff = c;
ptr = wc;
while ((*ptr) != '\0') {
*c = *ptr;
++c;
++ptr;
}
*c = 0;
return buff;
}
#endif
/*-----------------------------------*/
#if defined(MACOSX) || defined(LINUX) || defined(FREEBSD)
FILE *_wfopen(const wchar_t *fname, const wchar_t *mode) {
char *cfname = convertWCHAR2CHAR(fname);
char *cmode = convertWCHAR2CHAR(mode);
FILE *f = fopen(cfname, cmode);
free(cfname);
free(cmode);
return f;
}
/*-----------------------------------*/
int _wstat(const wchar_t *fname, struct stat *buf) {
char *cfname = convertWCHAR2CHAR(fname);
int rc = stat(cfname, buf);
free(cfname);
return rc;
}
/*-----------------------------------*/
int _wremove(const wchar_t *fname) {
char *cfname = convertWCHAR2CHAR(fname);
int rc = remove(cfname);
free(cfname);
return rc;
}
#endif