Skip to content

Commit

Permalink
ninewinecfg: use relative symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
9ary committed Mar 21, 2023
1 parent 5ba57d6 commit d9f7f49
Showing 1 changed file with 7 additions and 37 deletions.
44 changes: 7 additions & 37 deletions ninewinecfg/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,36 +230,24 @@ static BOOL remove_file(LPCSTR filename)
static BOOL create_symlink(LPCSTR target, LPCSTR filename)
{
BOOL ret;
char *target_fn, *fn;

if (!(target_fn = unix_filename(target)))
{
ret = FALSE;
goto done;
}
char *fn = unix_filename(filename);

if (!(fn = unix_filename(filename)))
{
ret = FALSE;
goto free_target_fn;
}
if (!fn)
return FALSE;

if (!symlink(target_fn, fn))
if (!symlink(target, fn))
{
TRACE("Symlinked '%s' to '%s'\n", nine_dbgstr_a(fn),
nine_dbgstr_a(target_fn));
nine_dbgstr_a(target));
ret = TRUE;
} else {
ERR("Failed to symlinked '%s' to '%s'\n", nine_dbgstr_a(fn),
nine_dbgstr_a(target_fn));
nine_dbgstr_a(target));
ret = FALSE;
}

HeapFree(GetProcessHeap(), 0, fn);
free_target_fn:
HeapFree(GetProcessHeap(), 0, target_fn);

done:
return ret;
}

Expand Down Expand Up @@ -468,8 +456,6 @@ static void nine_set(BOOL status, BOOL NoOtherArch)

if (status)
{
HMODULE hmod;

if (!nine_install_forwarder())
{
ERR("Failed to install forwarder\n");
Expand All @@ -485,23 +471,7 @@ static void nine_set(BOOL status, BOOL NoOtherArch)
remove_file(dst);
}

hmod = LoadLibraryExA(fn_forwarder_dll, NULL, DONT_RESOLVE_DLL_REFERENCES);
if (hmod)
{
CHAR buf[MAX_PATH];
DWORD len = GetModuleFileNameA(hmod, (LPSTR)buf, sizeof(buf));

if (len && len < sizeof(buf))
create_symlink(buf, dst);
else
ERR("GetModuleFileNameA failed to get file path\n");

FreeLibrary(hmod);
} else {
LPWSTR msg = load_message(GetLastError());
ERR("Couldn't load %s: %s\n", fn_forwarder_dll, nine_dbgstr_w(msg));
LocalFree(msg);
}
create_symlink(fn_forwarder_dll, dst);
} else {
if (is_nine_symlink(dst))
{
Expand Down

0 comments on commit d9f7f49

Please sign in to comment.