mountmgr: Support $HOME paths to define shell folders.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fefb5da4ba
commit
b3ea395681
|
@ -301,7 +301,8 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
||||||
UNICODE_STRING name;
|
UNICODE_STRING name;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
ULONG size = 256;
|
ULONG size = 256;
|
||||||
char *buffer, *backup = NULL;
|
const char *home;
|
||||||
|
char *buffer = NULL, *backup = NULL, *homelink = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
@ -319,8 +320,21 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
||||||
if (!link[0]) link = NULL;
|
if (!link[0]) link = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (link && (!strcmp( link, "$HOME" ) || !strncmp( link, "$HOME/", 6 )) && (home = getenv( "HOME" )))
|
||||||
|
{
|
||||||
|
link += 5;
|
||||||
|
homelink = HeapAlloc( GetProcessHeap(), 0, strlen(home) + strlen(link) + 1 );
|
||||||
|
strcpy( homelink, home );
|
||||||
|
strcat( homelink, link );
|
||||||
|
link = homelink;
|
||||||
|
}
|
||||||
|
|
||||||
/* ignore nonexistent link targets */
|
/* ignore nonexistent link targets */
|
||||||
if (link && stat( link, &st )) return STATUS_OBJECT_NAME_NOT_FOUND;
|
if (link && (stat( link, &st ) || !S_ISDIR( st.st_mode )))
|
||||||
|
{
|
||||||
|
status = STATUS_OBJECT_NAME_NOT_FOUND;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
name.Buffer = (WCHAR *)((char *)in_buff + input->folder_offset);
|
name.Buffer = (WCHAR *)((char *)in_buff + input->folder_offset);
|
||||||
name.Length = input->folder_size;
|
name.Length = input->folder_size;
|
||||||
|
@ -328,11 +342,16 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size ))) return STATUS_NO_MEMORY;
|
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size )))
|
||||||
status = wine_nt_to_unix_file_name( &attr, buffer, &size, FILE_OPEN );
|
{
|
||||||
if (!status) break;
|
status = STATUS_NO_MEMORY;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
status = wine_nt_to_unix_file_name( &attr, buffer, &size, FILE_OPEN_IF );
|
||||||
|
if (status == STATUS_NO_SUCH_FILE) status = STATUS_SUCCESS;
|
||||||
|
if (status == STATUS_SUCCESS) break;
|
||||||
|
if (status != STATUS_BUFFER_TOO_SMALL) goto done;
|
||||||
HeapFree( GetProcessHeap(), 0, buffer );
|
HeapFree( GetProcessHeap(), 0, buffer );
|
||||||
if (status != STATUS_BUFFER_TOO_SMALL) return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input->create_backup)
|
if (input->create_backup)
|
||||||
|
@ -376,6 +395,7 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
||||||
done:
|
done:
|
||||||
HeapFree( GetProcessHeap(), 0, buffer );
|
HeapFree( GetProcessHeap(), 0, buffer );
|
||||||
HeapFree( GetProcessHeap(), 0, backup );
|
HeapFree( GetProcessHeap(), 0, backup );
|
||||||
|
HeapFree( GetProcessHeap(), 0, homelink );
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue