Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
01a2b9c6
Commit
01a2b9c6
authored
Sep 07, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winecfg: Use mountmgr to manage shell folders.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0a8776d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
68 deletions
+61
-68
drive.c
programs/winecfg/drive.c
+52
-0
theme.c
programs/winecfg/theme.c
+7
-68
winecfg.h
programs/winecfg/winecfg.h
+2
-0
No files found.
programs/winecfg/drive.c
View file @
01a2b9c6
...
@@ -370,3 +370,55 @@ void apply_drive_changes(void)
...
@@ -370,3 +370,55 @@ void apply_drive_changes(void)
}
}
CloseHandle
(
mgr
);
CloseHandle
(
mgr
);
}
}
void
query_shell_folder
(
const
WCHAR
*
path
,
char
*
dest
,
unsigned
int
len
)
{
UNICODE_STRING
nt_name
;
HANDLE
mgr
;
if
((
mgr
=
open_mountmgr
())
==
INVALID_HANDLE_VALUE
)
return
;
if
(
!
RtlDosPathNameToNtPathName_U
(
path
,
&
nt_name
,
NULL
,
NULL
))
{
CloseHandle
(
mgr
);
return
;
}
DeviceIoControl
(
mgr
,
IOCTL_MOUNTMGR_QUERY_SHELL_FOLDER
,
nt_name
.
Buffer
,
nt_name
.
Length
,
dest
,
len
,
NULL
,
NULL
);
RtlFreeUnicodeString
(
&
nt_name
);
}
void
set_shell_folder
(
const
WCHAR
*
path
,
const
char
*
dest
)
{
struct
mountmgr_shell_folder
*
ioctl
;
UNICODE_STRING
nt_name
;
HANDLE
mgr
;
DWORD
len
;
if
((
mgr
=
open_mountmgr
())
==
INVALID_HANDLE_VALUE
)
return
;
if
(
!
RtlDosPathNameToNtPathName_U
(
path
,
&
nt_name
,
NULL
,
NULL
))
{
CloseHandle
(
mgr
);
return
;
}
len
=
sizeof
(
*
ioctl
)
+
nt_name
.
Length
;
if
(
dest
)
len
+=
strlen
(
dest
)
+
1
;
if
(
!
(
ioctl
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
return
;
ioctl
->
folder_offset
=
sizeof
(
*
ioctl
);
ioctl
->
folder_size
=
nt_name
.
Length
;
memcpy
(
(
char
*
)
ioctl
+
ioctl
->
folder_offset
,
nt_name
.
Buffer
,
nt_name
.
Length
);
if
(
dest
)
{
ioctl
->
symlink_offset
=
ioctl
->
folder_offset
+
ioctl
->
folder_size
;
strcpy
(
(
char
*
)
ioctl
+
ioctl
->
symlink_offset
,
dest
);
}
else
ioctl
->
symlink_offset
=
0
;
DeviceIoControl
(
mgr
,
IOCTL_MOUNTMGR_DEFINE_SHELL_FOLDER
,
ioctl
,
len
,
NULL
,
0
,
NULL
,
NULL
);
HeapFree
(
GetProcessHeap
(),
0
,
ioctl
);
RtlFreeUnicodeString
(
&
nt_name
);
}
programs/winecfg/theme.c
View file @
01a2b9c6
...
@@ -28,12 +28,6 @@
...
@@ -28,12 +28,6 @@
#include <stdarg.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#define COBJMACROS
#define COBJMACROS
...
@@ -765,25 +759,14 @@ static void init_shell_folder_listview_headers(HWND dialog) {
...
@@ -765,25 +759,14 @@ static void init_shell_folder_listview_headers(HWND dialog) {
/* Reads the currently set shell folder symbol link targets into asfiInfo. */
/* Reads the currently set shell folder symbol link targets into asfiInfo. */
static
void
read_shell_folder_link_targets
(
void
)
{
static
void
read_shell_folder_link_targets
(
void
)
{
WCHAR
wszPath
[
MAX_PATH
];
WCHAR
wszPath
[
MAX_PATH
];
HRESULT
hr
;
int
i
;
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
asfiInfo
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
asfiInfo
);
i
++
)
{
asfiInfo
[
i
].
szLinkTarget
[
0
]
=
'\0'
;
asfiInfo
[
i
].
szLinkTarget
[
0
]
=
'\0'
;
hr
=
SHGetFolderPathW
(
NULL
,
asfiInfo
[
i
].
nFolder
|
CSIDL_FLAG_DONT_VERIFY
,
NULL
,
if
(
SUCCEEDED
(
SHGetFolderPathW
(
NULL
,
asfiInfo
[
i
].
nFolder
|
CSIDL_FLAG_DONT_VERIFY
,
NULL
,
SHGFP_TYPE_CURRENT
,
wszPath
);
SHGFP_TYPE_CURRENT
,
wszPath
)))
if
(
SUCCEEDED
(
hr
))
{
query_shell_folder
(
wszPath
,
asfiInfo
[
i
].
szLinkTarget
,
FILENAME_MAX
);
char
*
pszUnixPath
=
wine_get_unix_file_name
(
wszPath
);
}
if
(
pszUnixPath
)
{
struct
stat
statPath
;
if
(
!
lstat
(
pszUnixPath
,
&
statPath
)
&&
S_ISLNK
(
statPath
.
st_mode
))
{
int
cLen
=
readlink
(
pszUnixPath
,
asfiInfo
[
i
].
szLinkTarget
,
FILENAME_MAX
-
1
);
if
(
cLen
>=
0
)
asfiInfo
[
i
].
szLinkTarget
[
cLen
]
=
'\0'
;
}
HeapFree
(
GetProcessHeap
(),
0
,
pszUnixPath
);
}
}
}
}
}
static
void
update_shell_folder_listview
(
HWND
dialog
)
{
static
void
update_shell_folder_listview
(
HWND
dialog
)
{
...
@@ -904,56 +887,12 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
...
@@ -904,56 +887,12 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
static
void
apply_shell_folder_changes
(
void
)
{
static
void
apply_shell_folder_changes
(
void
)
{
WCHAR
wszPath
[
MAX_PATH
];
WCHAR
wszPath
[
MAX_PATH
];
char
szBackupPath
[
FILENAME_MAX
],
szUnixPath
[
FILENAME_MAX
],
*
pszUnixPath
=
NULL
;
int
i
;
int
i
;
struct
stat
statPath
;
HRESULT
hr
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
asfiInfo
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
asfiInfo
);
i
++
)
{
/* Ignore nonexistent link targets */
if
(
SUCCEEDED
(
SHGetFolderPathW
(
NULL
,
asfiInfo
[
i
].
nFolder
|
CSIDL_FLAG_CREATE
,
NULL
,
if
(
asfiInfo
[
i
].
szLinkTarget
[
0
]
&&
stat
(
asfiInfo
[
i
].
szLinkTarget
,
&
statPath
))
SHGFP_TYPE_CURRENT
,
wszPath
)))
continue
;
set_shell_folder
(
wszPath
,
asfiInfo
[
i
].
szLinkTarget
);
hr
=
SHGetFolderPathW
(
NULL
,
asfiInfo
[
i
].
nFolder
|
CSIDL_FLAG_CREATE
,
NULL
,
SHGFP_TYPE_CURRENT
,
wszPath
);
if
(
FAILED
(
hr
))
continue
;
/* Retrieve the corresponding unix path. */
pszUnixPath
=
wine_get_unix_file_name
(
wszPath
);
if
(
!
pszUnixPath
)
continue
;
lstrcpyA
(
szUnixPath
,
pszUnixPath
);
HeapFree
(
GetProcessHeap
(),
0
,
pszUnixPath
);
/* Derive name for folder backup. */
lstrcpyA
(
szBackupPath
,
szUnixPath
);
lstrcatA
(
szBackupPath
,
".winecfg"
);
if
(
lstat
(
szUnixPath
,
&
statPath
))
continue
;
/* Move old folder/link out of the way. */
if
(
S_ISLNK
(
statPath
.
st_mode
))
{
if
(
unlink
(
szUnixPath
))
continue
;
/* Unable to remove link. */
}
else
{
if
(
!*
asfiInfo
[
i
].
szLinkTarget
)
{
continue
;
/* We are done. Old was real folder, as new shall be. */
}
else
{
if
(
rename
(
szUnixPath
,
szBackupPath
))
{
/* Move folder out of the way. */
continue
;
/* Unable to move old folder. */
}
}
}
/* Create new link/folder. */
if
(
*
asfiInfo
[
i
].
szLinkTarget
)
{
symlink
(
asfiInfo
[
i
].
szLinkTarget
,
szUnixPath
);
}
else
{
/* If there's a backup folder, restore it. Else create new folder. */
if
(
!
lstat
(
szBackupPath
,
&
statPath
)
&&
S_ISDIR
(
statPath
.
st_mode
))
{
rename
(
szBackupPath
,
szUnixPath
);
}
else
{
mkdir
(
szUnixPath
,
0777
);
}
}
}
}
}
}
...
...
programs/winecfg/winecfg.h
View file @
01a2b9c6
...
@@ -117,6 +117,8 @@ BOOL add_drive(char letter, const char *targetpath, const char *device,
...
@@ -117,6 +117,8 @@ BOOL add_drive(char letter, const char *targetpath, const char *device,
const
WCHAR
*
label
,
DWORD
serial
,
DWORD
type
);
const
WCHAR
*
label
,
DWORD
serial
,
DWORD
type
);
void
delete_drive
(
struct
drive
*
pDrive
);
void
delete_drive
(
struct
drive
*
pDrive
);
void
apply_drive_changes
(
void
);
void
apply_drive_changes
(
void
);
void
query_shell_folder
(
const
WCHAR
*
path
,
char
*
dest
,
unsigned
int
len
);
void
set_shell_folder
(
const
WCHAR
*
path
,
const
char
*
dest
);
BOOL
browse_for_unix_folder
(
HWND
dialog
,
WCHAR
*
pszPath
);
BOOL
browse_for_unix_folder
(
HWND
dialog
,
WCHAR
*
pszPath
);
extern
struct
drive
drives
[
26
];
/* one for each drive letter */
extern
struct
drive
drives
[
26
];
/* one for each drive letter */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment