|
|
|
@ -854,7 +854,7 @@ bool IsFile(const wchar_t * file)
|
|
|
|
|
struct stat sb;
|
|
|
|
|
char file_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(file, file_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(file, file_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return (stat(file_name, &sb) == 0);
|
|
|
|
@ -876,7 +876,7 @@ char dir_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
|
|
|
|
|
if( !IsFile(dir) )
|
|
|
|
|
{
|
|
|
|
|
if( !WideToUTF8(dir, dir_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(dir, dir_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if( mkdir(dir_name, 0777) < 0 )
|
|
|
|
@ -952,7 +952,7 @@ struct group * result;
|
|
|
|
|
char group_name[WINIX_OS_USERNAME_SIZE];
|
|
|
|
|
char buffer[512];
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(name, group_name, WINIX_OS_USERNAME_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(name, group_name, WINIX_OS_USERNAME_SIZE) )
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if( getgrnam_r(group_name, &gr, buffer, sizeof(buffer)/sizeof(char), &result) != 0 )
|
|
|
|
@ -988,7 +988,7 @@ bool SetPriv(const wchar_t * name, int priv, int group)
|
|
|
|
|
{
|
|
|
|
|
char file_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(name, file_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(name, file_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if( chmod(file_name, priv) < 0 )
|
|
|
|
@ -1046,10 +1046,10 @@ char src_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
char dst_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
FILE * in, * out;
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(src, src_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(src, src_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(dst, dst_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(dst, dst_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
in = fopen(src_name, "rb");
|
|
|
|
@ -1091,7 +1091,7 @@ bool RemoveFile(const wchar_t * file)
|
|
|
|
|
{
|
|
|
|
|
char file_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(file, file_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(file, file_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return unlink(file_name) == 0;
|
|
|
|
@ -1110,10 +1110,10 @@ bool RenameFile(const wchar_t * from, const wchar_t * to)
|
|
|
|
|
char from_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
char to_name[WINIX_OS_PATH_SIZE];
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(from, from_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(from, from_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(to, to_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(to, to_name, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return rename(from_name, to_name) == 0;
|
|
|
|
@ -1137,7 +1137,7 @@ std::ifstream get_file_content;
|
|
|
|
|
if( clear_content )
|
|
|
|
|
content.clear();
|
|
|
|
|
|
|
|
|
|
if( !WideToUTF8(file_path, file, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
if( !wide_to_utf8(file_path, file, WINIX_OS_PATH_SIZE) )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
get_file_content.open(file, std::ios_base::in | std::ios_base::binary);
|
|
|
|
@ -1148,7 +1148,7 @@ std::ifstream get_file_content;
|
|
|
|
|
/*
|
|
|
|
|
* we don't report any errors when converting from UTF8 to wide characters here
|
|
|
|
|
*/
|
|
|
|
|
pt::UTF8ToWide(get_file_content, content);
|
|
|
|
|
pt::utf8_to_wide(get_file_content, content);
|
|
|
|
|
get_file_content.close();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@ -1280,7 +1280,7 @@ void UrlEncode(const wchar_t * in, std::string & out, bool clear_out)
|
|
|
|
|
{
|
|
|
|
|
static std::string ain;
|
|
|
|
|
|
|
|
|
|
pt::WideToUTF8(in, ain);
|
|
|
|
|
pt::wide_to_utf8(in, ain);
|
|
|
|
|
|
|
|
|
|
if( clear_out )
|
|
|
|
|
out.clear();
|
|
|
|
@ -1301,7 +1301,7 @@ void UrlEncode(const wchar_t * in, std::wstring & out, bool clear_out)
|
|
|
|
|
{
|
|
|
|
|
static std::string ain;
|
|
|
|
|
|
|
|
|
|
pt::WideToUTF8(in, ain);
|
|
|
|
|
pt::wide_to_utf8(in, ain);
|
|
|
|
|
|
|
|
|
|
if( clear_out )
|
|
|
|
|
out.clear();
|
|
|
|
@ -1372,7 +1372,7 @@ int c1, c2;
|
|
|
|
|
|
|
|
|
|
url_utf8[index] = 0;
|
|
|
|
|
|
|
|
|
|
return pt::UTF8ToWide(url_utf8, out, false);
|
|
|
|
|
return pt::utf8_to_wide(url_utf8, out, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1416,9 +1416,9 @@ void RemovePostFileTmp(PostFileTab & post_file_tab)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool WideToUTF8(const wchar_t * wide_string, char * utf8, size_t utf8_size)
|
|
|
|
|
bool wide_to_utf8(const wchar_t * wide_string, char * utf8, size_t utf8_size)
|
|
|
|
|
{
|
|
|
|
|
bool res = pt::WideToUTF8(wide_string, utf8, utf8_size);
|
|
|
|
|
bool res = pt::wide_to_utf8(wide_string, utf8, utf8_size);
|
|
|
|
|
|
|
|
|
|
if( !res )
|
|
|
|
|
{
|
|
|
|
@ -1433,9 +1433,9 @@ return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool WideToUTF8(const std::wstring & wide_string, char * utf8, size_t utf8_size)
|
|
|
|
|
bool wide_to_utf8(const std::wstring & wide_string, char * utf8, size_t utf8_size)
|
|
|
|
|
{
|
|
|
|
|
return WideToUTF8(wide_string.c_str(), utf8, utf8_size);
|
|
|
|
|
return wide_to_utf8(wide_string.c_str(), utf8, utf8_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|