Example #1
0
bool luaT_script::run(const tstring& script, tstring* error)
{
    TW2U w2u(script.c_str());
    luaL_loadstring(L, w2u);
    if (!lua_pcall(L, 0, 0, 0))
        return true;
    if (error)
        error->assign( lua_toerror(L) );
    lua_pop(L, 1);
    return false;
}
sciter::value ApplicationWindow::startRemoveFromDevice(sciter::value _ip)
{
    sciter::string ip = _ip.to_string();
    std::string ipUni = w2u(ip);
    
    auto deviceInfo = raumserverInstallerObject->getDeviceInformation(ipUni);
    if (deviceInfo.ip.empty())
        return false;
    raumserverInstallerObject->startRemoveFromDevice(deviceInfo);

    return true;
}
Example #3
0
	bool set_language(const std::wstring& l, bool refresh) {
		if (l == L"") {
			return false;
		}
		if (!fs::exists(workpath / l)) {
			return false;
		}
		language = l;
		cache_language = &(cache_alllang[l]);
		cache_domain = nullptr;
		if (refresh) {
			try {
				file::write_stream(workpath / L"default").write<std::string>(w2u(l));
			}
			catch (...) {
			}
		}
		return true;
	}
Example #4
0
	String w2u(const WString& wstr) {
		return w2u(wstr.c_str(), wstr.size());
#if 0
		size_t len = wstr.size();
		String result;

		result.resize(len * AX_UTF8_LEN_MAX);
		if (sizeof(wchar_t) == sizeof(UTF16)) {
			const UTF16* srcstart = (UTF16*)&wstr[0];
			const UTF16* srcend = srcstart + len;
			UTF8* dststart = (UTF8*)&result[0];
			UTF8* dstend = dststart + result.size();
			ConversionResult cr = ConvertUTF16toUTF8(&srcstart, srcend, &dststart, dstend, strictConversion);
			result.resize(dststart - (UTF8*)&result[0]);
		}

		return result;
#endif
	}
Example #5
0
	FileInfoSeq PathUtil::getFileInfos(const String& base, const String& path, const String& filters, int flags) {
		FileInfoSeq fileinfos;
		_wfinddata_t finddata;
		long handle;
		int num_files = 0;
		size_t baselen = base.length();

		Filter filter(filters);

		String pattern = path;
		if (!PathUtil::isDirectoryLetter(pattern[pattern.length() - 1])) {
			pattern += '/';
		}
		pattern += '*';

		handle = _wfindfirst(const_cast<wchar_t *>(u2w(pattern).c_str()), &finddata);
		if (handle == -1) {
			_findclose(handle);
			return fileinfos;
		}

		do {
			FileInfo info;
			if (finddata.attrib & _A_SUBDIR) {
				if (!wcscmp(finddata.name, L".") || !wcscmp(finddata.name, L"..")) {
					continue;
				}

				if (!(flags & File::List_needCVS)) {
					if (!wcscmp(finddata.name, L"CVS")) {
						continue;
					}
				}

				if (flags & File::List_nodirectory) {
					continue;
				}

				if (flags & File::List_filterDirectory) {
					if (!filter.In(w2u(finddata.name)))
						continue;
				}

				info.isDir = true;
			} else {
				if (flags & File::List_nofile) {
					continue;
				}

				if (!(flags & File::List_nofilterfile)) {
					if (!filter.In(w2u(finddata.name)))
						continue;
				}

				info.isDir = false;
			}

			info.fullpath = (path + "/" + w2u(finddata.name)).c_str() + baselen;
			info.filetype = File::Stdio;
			info.filesize = finddata.size;
			info.filetime = finddata.time_write;
			info.localtime = *_localtime64(&finddata.time_write);

			PathUtil::splitPath(info.fullpath, info.filepath, info.filename, info.fileext);
			info.filename = PathUtil::removeDir(info.fullpath);

			fileinfos.push_back(info);

			num_files++;

		} while (_wfindnext(handle, &finddata) != -1);

		_findclose(handle);

		if (flags & File::List_sort) {
			std::sort(fileinfos.begin(), fileinfos.end(), CmpFileInfoNameLess);
		}

		return fileinfos;
	}
Example #6
0
	String l2u(const String& lstr) {
		return w2u(l2w(lstr));
	}
Example #7
0
	String l2u(const char* localstr) {
		WString ws = l2w(localstr);
		return w2u(ws);
	}