Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
f9a19f57
Commit
f9a19f57
authored
Jun 28, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jun 30, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32: Implement PathYetAnotherMakeUniqueName().
parent
7ef53600
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
11 deletions
+108
-11
shellpath.c
dlls/shell32/shellpath.c
+26
-11
shellpath.c
dlls/shell32/tests/shellpath.c
+82
-0
No files found.
dlls/shell32/shellpath.c
View file @
f9a19f57
...
...
@@ -537,22 +537,37 @@ BOOL WINAPI PathMakeUniqueNameAW(
/*************************************************************************
* PathYetAnotherMakeUniqueName [SHELL32.75]
*
* NOTES
* exported by ordinal
*/
BOOL
WINAPI
PathYetAnotherMakeUniqueName
(
LPWSTR
lpszBuffer
,
LPCWSTR
lpszPathName
,
LPCWSTR
lpszShortName
,
LPCWSTR
lpszLongName
)
BOOL
WINAPI
PathYetAnotherMakeUniqueName
(
LPWSTR
buffer
,
LPCWSTR
path
,
LPCWSTR
shortname
,
LPCWSTR
longname
)
{
FIXME
(
"(%p, %s, %s ,%s):stub.
\n
"
,
lpszBuffer
,
debugstr_w
(
lpszPathName
),
debugstr_w
(
lpszShortName
),
debugstr_w
(
lpszLongName
));
WCHAR
pathW
[
MAX_PATH
],
retW
[
MAX_PATH
];
const
WCHAR
*
file
,
*
ext
;
int
i
=
2
;
TRACE
(
"(%p, %s, %s, %s)
\n
"
,
buffer
,
debugstr_w
(
path
),
debugstr_w
(
shortname
),
debugstr_w
(
longname
));
file
=
longname
?
longname
:
shortname
;
PathCombineW
(
pathW
,
path
,
file
);
strcpyW
(
retW
,
pathW
);
PathRemoveExtensionW
(
pathW
);
ext
=
PathFindExtensionW
(
file
);
/* now try to make it unique */
while
(
PathFileExistsW
(
retW
))
{
static
const
WCHAR
fmtW
[]
=
{
'%'
,
's'
,
' '
,
'('
,
'%'
,
'd'
,
')'
,
'%'
,
's'
,
0
};
sprintfW
(
retW
,
fmtW
,
pathW
,
i
,
ext
);
i
++
;
}
strcpyW
(
buffer
,
retW
);
TRACE
(
"ret - %s
\n
"
,
debugstr_w
(
buffer
));
return
TRUE
;
}
/*
########## cleaning and resolving paths ##########
*/
...
...
dlls/shell32/tests/shellpath.c
View file @
f9a19f57
...
...
@@ -101,6 +101,7 @@ static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR,UINT);
static
HRESULT
(
WINAPI
*
pSHGetKnownFolderPath
)(
REFKNOWNFOLDERID
,
DWORD
,
HANDLE
,
PWSTR
*
);
static
HRESULT
(
WINAPI
*
pSHSetKnownFolderPath
)(
REFKNOWNFOLDERID
,
DWORD
,
HANDLE
,
PWSTR
);
static
HRESULT
(
WINAPI
*
pSHGetFolderPathEx
)(
REFKNOWNFOLDERID
,
DWORD
,
HANDLE
,
LPWSTR
,
DWORD
);
static
BOOL
(
WINAPI
*
pPathYetAnotherMakeUniqueName
)(
PWSTR
,
PCWSTR
,
PCWSTR
,
PCWSTR
);
static
DLLVERSIONINFO
shellVersion
=
{
0
};
static
LPMALLOC
pMalloc
;
...
...
@@ -207,6 +208,7 @@ static void loadShell32(void)
pILFindLastID
=
(
void
*
)
GetProcAddress
(
hShell32
,
(
LPCSTR
)
16
);
GET_PROC
(
SHFileOperationA
)
GET_PROC
(
SHGetMalloc
)
GET_PROC
(
PathYetAnotherMakeUniqueName
)
ok
(
pSHGetMalloc
!=
NULL
,
"shell32 is missing SHGetMalloc
\n
"
);
if
(
pSHGetMalloc
)
...
...
@@ -2631,6 +2633,85 @@ static void test_DoEnvironmentSubst(void)
}
}
static
void
test_PathYetAnotherMakeUniqueName
(
void
)
{
static
const
WCHAR
shortW
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
'.'
,
't'
,
's'
,
't'
,
0
};
static
const
WCHAR
short2W
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
' '
,
'('
,
'2'
,
')'
,
'.'
,
't'
,
's'
,
't'
,
0
};
static
const
WCHAR
tmpW
[]
=
{
't'
,
'm'
,
'p'
,
0
};
static
const
WCHAR
longW
[]
=
{
'n'
,
'a'
,
'm'
,
'e'
,
0
};
static
const
WCHAR
long2W
[]
=
{
'n'
,
'a'
,
'm'
,
'e'
,
' '
,
'('
,
'2'
,
')'
,
0
};
WCHAR
nameW
[
MAX_PATH
],
buffW
[
MAX_PATH
],
pathW
[
MAX_PATH
];
HANDLE
file
;
BOOL
ret
;
if
(
!
pPathYetAnotherMakeUniqueName
)
{
win_skip
(
"PathYetAnotherMakeUniqueName() is not available.
\n
"
);
return
;
}
if
(
0
)
{
/* crashes on Windows */
ret
=
pPathYetAnotherMakeUniqueName
(
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
!
ret
,
"got %d
\n
"
,
ret
);
ret
=
pPathYetAnotherMakeUniqueName
(
nameW
,
NULL
,
NULL
,
NULL
);
ok
(
!
ret
,
"got %d
\n
"
,
ret
);
}
GetTempPathW
(
sizeof
(
pathW
)
/
sizeof
(
WCHAR
),
pathW
);
/* Using short name only first */
nameW
[
0
]
=
0
;
ret
=
pPathYetAnotherMakeUniqueName
(
nameW
,
pathW
,
shortW
,
NULL
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
lstrcpyW
(
buffW
,
pathW
);
lstrcatW
(
buffW
,
shortW
);
ok
(
!
lstrcmpW
(
nameW
,
buffW
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
nameW
),
wine_dbgstr_w
(
buffW
));
/* now create a file with this name and get next name */
file
=
CreateFileW
(
nameW
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
ok
(
file
!=
NULL
,
"got %p
\n
"
,
file
);
nameW
[
0
]
=
0
;
ret
=
pPathYetAnotherMakeUniqueName
(
nameW
,
pathW
,
shortW
,
NULL
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
lstrcpyW
(
buffW
,
pathW
);
lstrcatW
(
buffW
,
short2W
);
ok
(
!
lstrcmpW
(
nameW
,
buffW
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
nameW
),
wine_dbgstr_w
(
buffW
));
CloseHandle
(
file
);
/* Using short and long */
nameW
[
0
]
=
0
;
ret
=
pPathYetAnotherMakeUniqueName
(
nameW
,
pathW
,
tmpW
,
longW
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
lstrcpyW
(
buffW
,
pathW
);
lstrcatW
(
buffW
,
longW
);
ok
(
!
lstrcmpW
(
nameW
,
buffW
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
nameW
),
wine_dbgstr_w
(
buffW
));
file
=
CreateFileW
(
nameW
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_DELETE_ON_CLOSE
,
NULL
);
ok
(
file
!=
NULL
,
"got %p
\n
"
,
file
);
nameW
[
0
]
=
0
;
ret
=
pPathYetAnotherMakeUniqueName
(
nameW
,
pathW
,
tmpW
,
longW
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
lstrcpyW
(
buffW
,
pathW
);
lstrcatW
(
buffW
,
long2W
);
ok
(
!
lstrcmpW
(
nameW
,
buffW
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
nameW
),
wine_dbgstr_w
(
buffW
));
CloseHandle
(
file
);
/* Using long only */
nameW
[
0
]
=
0
;
ret
=
pPathYetAnotherMakeUniqueName
(
nameW
,
pathW
,
NULL
,
longW
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
lstrcpyW
(
buffW
,
pathW
);
lstrcatW
(
buffW
,
longW
);
ok
(
!
lstrcmpW
(
nameW
,
buffW
),
"got %s, expected %s
\n
"
,
wine_dbgstr_w
(
nameW
),
wine_dbgstr_w
(
buffW
));
}
START_TEST
(
shellpath
)
{
if
(
!
init
())
return
;
...
...
@@ -2659,5 +2740,6 @@ START_TEST(shellpath)
test_SHGetFolderPathEx
();
test_knownFolders
();
test_DoEnvironmentSubst
();
test_PathYetAnotherMakeUniqueName
();
}
}
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