* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
- *
+ *
* Contributor(s): Alexandr Kuznetsov, Andrea Weikert
*
* ***** END GPL LICENSE BLOCK *****
*/
-#ifdef WIN32
-
#ifndef _WIN32_IE
#define _WIN32_IE 0x0501
#endif
FILE * ufopen(const char * filename, const char * mode)
{
- FILE * f = NULL;
+ FILE *f = NULL;
UTF16_ENCODE(filename);
UTF16_ENCODE (mode);
- if(filename_16 && mode_16) f = _wfopen(filename_16, mode_16);
+ if (filename_16 && mode_16) {
+ f = _wfopen(filename_16, mode_16);
+ }
UTF16_UN_ENCODE(mode);
UTF16_UN_ENCODE(filename);
- if(!f)
- {
- if(f=fopen(filename,mode))
+ if (!f) {
+ if ((f = fopen(filename, mode))) {
printf("WARNING: %s is not utf path. Please update it.\n",filename);
+ }
}
return f;
int f = -1;
UTF16_ENCODE(filename);
- if(filename_16) f = _wopen(filename_16, oflag, pmode);
+ if (filename_16) {
+ f = _wopen(filename_16, oflag, pmode);
+ }
UTF16_UN_ENCODE(filename);
- if(f==-1)
- {
- if((f=open(filename,oflag, pmode))!=-1)
+ if (f == -1) {
+ if ((f=open(filename,oflag, pmode)) != -1) {
printf("WARNING: %s is not utf path. Please update it.\n",filename);
+ }
}
return f;
UTF16_ENCODE(oldname);
UTF16_ENCODE (newname);
- if(oldname_16 && newname_16) r = _wrename(oldname_16, newname_16);
+ if (oldname_16 && newname_16) r = _wrename(oldname_16, newname_16);
UTF16_UN_ENCODE(newname);
UTF16_UN_ENCODE(oldname);
BOOL r = 0;
UTF16_ENCODE(pathname);
- if(pathname_16) r = CreateDirectoryW(pathname_16, NULL);
+ if (pathname_16) r = CreateDirectoryW(pathname_16, NULL);
UTF16_UN_ENCODE(pathname);
- return r?0:-1;
+ return r ? 0 : -1;
}
char * u_alloc_getenv(const char *varname)
char * r = 0;
wchar_t * str;
UTF16_ENCODE(varname);
- if(varname_16){ str = _wgetenv(varname_16);
- r = alloc_utf_8_from_16(str,0);}
+ if (varname_16) {
+ str = _wgetenv(varname_16);
+ r = alloc_utf_8_from_16(str, 0);
+ }
UTF16_UN_ENCODE(varname);
return r;
{
int r = 0;
wchar_t * str;
- if(!buffsize) return r;
+ if (!buffsize) return r;
UTF16_ENCODE(varname);
- if(varname_16)
- {
- str = _wgetenv(varname_16);
- conv_utf_16_to_8(str, value, buffsize);
- r = 1;
- }
+ if (varname_16) {
+ str = _wgetenv(varname_16);
+ conv_utf_16_to_8(str, value, buffsize);
+ r = 1;
+ }
UTF16_UN_ENCODE(varname);
- if(!r) value[0] = 0;
+ if (!r) value[0] = 0;
return r;
}
-
-
int uputenv(const char *name, const char *value)
{
int r = -1;
- UTF16_ENCODE(name)
- UTF16_ENCODE(value)
- if(name_16 && value_16) {
- if(SetEnvironmentVariableW(name_16,value_16)!=0)
- r =0;
- else r = -1;
+ UTF16_ENCODE(name);
+ UTF16_ENCODE(value);
+ if (name_16 && value_16) {
+ r = (SetEnvironmentVariableW(name_16,value_16)!= 0) ? 0 : -1;
}
- UTF16_UN_ENCODE(value)
- UTF16_UN_ENCODE(name)
+ UTF16_UN_ENCODE(value);
+ UTF16_UN_ENCODE(name);
return r;
}
-
-#endif