예제 #1
0
static bool TryLoadMemTrace()
{
    ScopedMem<WCHAR> dllPath(path::GetAppPath(L"memtrace.dll"));
    if (!LoadLibrary(dllPath))
        return false;
    return true;
}
예제 #2
0
void
ProtocolSettings::_Init()
{
	// Find protocol add-on
	BPath dllPath(fAddOn->Path());
	BFile file(dllPath.Path(), B_READ_ONLY);
	if (file.InitCheck() < B_OK) {
		fStatus = file.InitCheck();
		return;
	}

	BResources resources(&file);
	if (resources.InitCheck() != B_OK) {
		fStatus = resources.InitCheck();
		return;
	}

	size_t size;
	const void* data = resources.LoadResource(B_MESSAGE_TYPE,
		kProtocolSettingsTemplate, &size);
	if (!data) {
		fStatus = B_BAD_VALUE;
		return;
	}

	// Load protocol's settings template
	fTemplate->Unflatten((const char*)data);
}
bool IsValidJRE(const char* path)
{
    std::string dllPath(path);
    if (dllPath[dllPath.size() - 1] != '\\')
    {
        dllPath += "\\";
    }
    return FileExists(dllPath + "bin\\server\\jvm.dll") || FileExists(dllPath + "bin\\client\\jvm.dll");
}
예제 #4
0
static bool TryLoadMemTrace()
{
    ScopedMem<TCHAR> exePath(GetExePath());
    ScopedMem<TCHAR> exeDir(path::GetDir(exePath));
    ScopedMem<TCHAR> dllPath(path::Join(exeDir, _T("memtrace.dll")));
    if (!LoadLibrary(dllPath))
        return false;
    return true;
}
예제 #5
0
static CFBundleRef createWebKitBundle()
{
    if (CFBundleRef existingBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"))) {
        CFRetain(existingBundle);
        return existingBundle;
    }

    wchar_t dllPathBuffer[MAX_PATH];
    DWORD length = ::GetModuleFileNameW(instanceHandle(), dllPathBuffer, WTF_ARRAY_LENGTH(dllPathBuffer));
    ASSERT(length);
    ASSERT(length < WTF_ARRAY_LENGTH(dllPathBuffer));

    RetainPtr<CFStringRef> dllPath(AdoptCF, CFStringCreateWithCharactersNoCopy(0, reinterpret_cast<const UniChar*>(dllPathBuffer), length, kCFAllocatorNull));
    RetainPtr<CFURLRef> dllURL(AdoptCF, CFURLCreateWithFileSystemPath(0, dllPath.get(), kCFURLWindowsPathStyle, false));
    RetainPtr<CFURLRef> dllDirectoryURL(AdoptCF, CFURLCreateCopyDeletingLastPathComponent(0, dllURL.get()));
    RetainPtr<CFURLRef> resourcesDirectoryURL(AdoptCF, CFURLCreateCopyAppendingPathComponent(0, dllDirectoryURL.get(), CFSTR("WebKit.resources"), true));

    return CFBundleCreate(0, resourcesDirectoryURL.get());
}
AVSValue __cdecl Waifu2x(AVSValue args, void *, IScriptEnvironment* env) {
	enum {
		ARG_CLIP,
		ARG_NR,
		ARG_SCALE,
		ARG_JOBS,
		ARG_MODELS,
	};

	PClip clip = args[ARG_CLIP].AsClip();

	int nr = args[ARG_NR].Defined() ? args[ARG_NR].AsInt() : 1;
	int scale = args[ARG_SCALE].Defined() ? args[ARG_SCALE].AsInt() : 2;

	int jobs = args[ARG_JOBS].Defined() ? args[ARG_JOBS].AsInt() : 0;
	if (jobs <= 0) {
		SYSTEM_INFO systemInfo;
		GetSystemInfo(&systemInfo);
		jobs = systemInfo.dwNumberOfProcessors;
	}

	std::string modelsDir;
	if (args[ARG_MODELS].Defined()) {
		modelsDir.assign(args[ARG_MODELS].AsString());
	} else {
		char dllPathChars[MAX_PATH] = { 0 };
		GetModuleFileNameA((HINSTANCE)&__ImageBase, dllPathChars, _countof(dllPathChars));

		// TODO: multibyte dll name may not work.
		std::string dllPath(dllPathChars);
		modelsDir.assign(dllPath.substr(0, dllPath.find_last_of('\\')) + "\\models");
		if (modelsDir.size() > MAX_PATH) {
			// TODO: need testing
			env->ThrowError("The models directory path is too long.");
		}
	}

	auto filter = new Waifu2xVideoFilter(clip, nr, scale, jobs, modelsDir, env);
	filter->Initialize(env);
	return filter;
}
예제 #7
0
static bool IsBrowserPluginInstalled()
{
    ScopedMem<WCHAR> dllPath(GetInstalledBrowserPluginPath());
    return file::Exists(dllPath);
}