mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 12:06:32 +00:00
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
1 changed files with 26 additions and 6 deletions
|
@ -301,7 +301,8 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
|||
UNICODE_STRING name;
|
||||
NTSTATUS status;
|
||||
ULONG size = 256;
|
||||
char *buffer, *backup = NULL;
|
||||
const char *home;
|
||||
char *buffer = NULL, *backup = NULL, *homelink = NULL;
|
||||
struct stat st;
|
||||
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 && (!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 */
|
||||
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.Length = input->folder_size;
|
||||
|
@ -328,11 +342,16 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
|||
|
||||
for (;;)
|
||||
{
|
||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size ))) return STATUS_NO_MEMORY;
|
||||
status = wine_nt_to_unix_file_name( &attr, buffer, &size, FILE_OPEN );
|
||||
if (!status) break;
|
||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size )))
|
||||
{
|
||||
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 );
|
||||
if (status != STATUS_BUFFER_TOO_SMALL) return status;
|
||||
}
|
||||
|
||||
if (input->create_backup)
|
||||
|
@ -376,6 +395,7 @@ static NTSTATUS define_shell_folder( const void *in_buff, SIZE_T insize )
|
|||
done:
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
HeapFree( GetProcessHeap(), 0, backup );
|
||||
HeapFree( GetProcessHeap(), 0, homelink );
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue