Commit 2a6d007c authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

If a source directory doesn't exist, use the install root instead.

parent 6a976373
......@@ -210,23 +210,14 @@ MSIFOLDER *get_loaded_folder( MSIPACKAGE *package, LPCWSTR dir )
return NULL;
}
LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
BOOL set_prop, MSIFOLDER **folder)
static LPWSTR get_source_root( MSIPACKAGE *package )
{
MSIFOLDER *f;
LPWSTR p, path = NULL;
TRACE("Working to resolve %s\n",debugstr_w(name));
LPWSTR path, p;
if (!name)
return NULL;
/* source directories appear to always be at the root */
if (source)
{
path = msi_dup_property( package, cszSourceDir );
if (!path)
{
if (path)
return path;
path = msi_dup_property( package, cszDatabase );
if (path)
{
......@@ -234,15 +225,25 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
if (p)
*(p+1) = 0;
}
}
if (folder)
*folder = get_loaded_folder( package, name );
return path;
}
}
LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
BOOL set_prop, MSIFOLDER **folder)
{
MSIFOLDER *f;
LPWSTR p, path = NULL;
TRACE("Working to resolve %s\n",debugstr_w(name));
if (!name)
return NULL;
/* special resolving for Target and Source root dir */
if (strcmpW(name,cszTargetDir)==0 || strcmpW(name,cszSourceDir)==0)
{
if (!source)
{
LPWSTR check_path;
check_path = msi_dup_property( package, cszTargetDir );
if (!check_path)
......@@ -257,6 +258,9 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
if (strcmpiW(path,check_path)!=0)
MSI_SetPropertyW(package,cszTargetDir,path);
msi_free(check_path);
}
else
path = get_source_root( package );
if (folder)
*folder = get_loaded_folder( package, name );
return path;
......@@ -269,13 +273,19 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
if (folder)
*folder = f;
if (f->ResolvedTarget)
if (!source && f->ResolvedTarget)
{
path = strdupW( f->ResolvedTarget );
TRACE(" already resolved to %s\n",debugstr_w(path));
return path;
}
else if (f->Property)
else if (source && f->ResolvedSource)
{
path = strdupW( f->ResolvedSource );
TRACE(" (source)already resolved to %s\n",debugstr_w(path));
return path;
}
else if (!source && f->Property)
{
path = build_directory_name( 2, f->Property, NULL );
......@@ -292,13 +302,34 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
TRACE(" ! Parent is %s\n", debugstr_w(parent));
p = resolve_folder(package, parent, source, set_prop, NULL);
if (!source)
{
TRACE(" TargetDefault = %s\n", debugstr_w(f->TargetDefault));
path = build_directory_name( 3, p, f->TargetDefault, NULL );
f->ResolvedTarget = strdupW( path );
TRACE(" resolved into %s\n",debugstr_w(path));
TRACE("target -> %s\n", debugstr_w(path));
if (set_prop)
MSI_SetPropertyW(package,name,path);
}
else
{
if (f->SourceDefault && f->SourceDefault[0]!='.')
path = build_directory_name( 3, p, f->SourceDefault, NULL );
else
path = strdupW(p);
TRACE("source -> %s\n", debugstr_w(path));
/* if the directory doesn't exist, use the root */
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
{
msi_free( path );
path = get_source_root( package );
TRACE("defaulting to %s\n", debugstr_w(path));
}
else
f->ResolvedSource = strdupW( path );
}
msi_free(p);
}
return path;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment