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
65f26902
Commit
65f26902
authored
May 05, 2015
by
Andrew Eikum
Committed by
Alexandre Julliard
May 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Support extended pathnames in GetShortPathName.
parent
0d2817b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
10 deletions
+43
-10
path.c
dlls/kernel32/path.c
+23
-5
path.c
dlls/kernel32/tests/path.c
+20
-5
No files found.
dlls/kernel32/path.c
View file @
65f26902
...
@@ -440,7 +440,7 @@ DWORD WINAPI GetLongPathNameA( LPCSTR shortpath, LPSTR longpath, DWORD longlen )
...
@@ -440,7 +440,7 @@ DWORD WINAPI GetLongPathNameA( LPCSTR shortpath, LPSTR longpath, DWORD longlen )
*/
*/
DWORD
WINAPI
GetShortPathNameW
(
LPCWSTR
longpath
,
LPWSTR
shortpath
,
DWORD
shortlen
)
DWORD
WINAPI
GetShortPathNameW
(
LPCWSTR
longpath
,
LPWSTR
shortpath
,
DWORD
shortlen
)
{
{
WCHAR
tmpshortpath
[
MAX_PATHNAME_LEN
]
;
WCHAR
*
tmpshortpath
;
LPCWSTR
p
;
LPCWSTR
p
;
DWORD
sp
=
0
,
lp
=
0
;
DWORD
sp
=
0
,
lp
=
0
;
DWORD
tmplen
;
DWORD
tmplen
;
...
@@ -460,12 +460,28 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD shortl
...
@@ -460,12 +460,28 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD shortl
return
0
;
return
0
;
}
}
/* code below only removes characters from string, never adds, so this is
* the largest buffer that tmpshortpath will need to have */
tmpshortpath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
longpath
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
tmpshortpath
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
return
0
;
}
if
(
longpath
[
0
]
==
'\\'
&&
longpath
[
1
]
==
'\\'
&&
longpath
[
2
]
==
'?'
&&
longpath
[
3
]
==
'\\'
)
{
memcpy
(
tmpshortpath
,
longpath
,
4
*
sizeof
(
WCHAR
));
sp
=
lp
=
4
;
}
/* check for drive letter */
/* check for drive letter */
if
(
longpath
[
0
]
!=
'/'
&&
longpath
[
1
]
==
':'
)
if
(
longpath
[
lp
]
!=
'/'
&&
longpath
[
lp
+
1
]
==
':'
)
{
{
tmpshortpath
[
0
]
=
longpath
[
0
];
tmpshortpath
[
sp
]
=
longpath
[
lp
];
tmpshortpath
[
1
]
=
':'
;
tmpshortpath
[
sp
+
1
]
=
':'
;
sp
=
lp
=
2
;
sp
+=
2
;
lp
+=
2
;
}
}
while
(
longpath
[
lp
])
while
(
longpath
[
lp
])
...
@@ -522,9 +538,11 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD shortl
...
@@ -522,9 +538,11 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD shortl
tmplen
--
;
/* length without 0 */
tmplen
--
;
/* length without 0 */
}
}
HeapFree
(
GetProcessHeap
(),
0
,
tmpshortpath
);
return
tmplen
;
return
tmplen
;
notfound:
notfound:
HeapFree
(
GetProcessHeap
(),
0
,
tmpshortpath
);
TRACE
(
"not found!
\n
"
);
TRACE
(
"not found!
\n
"
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
return
0
;
return
0
;
...
...
dlls/kernel32/tests/path.c
View file @
65f26902
...
@@ -1343,29 +1343,44 @@ static void test_GetLongPathNameW(void)
...
@@ -1343,29 +1343,44 @@ static void test_GetLongPathNameW(void)
static
void
test_GetShortPathNameW
(
void
)
static
void
test_GetShortPathNameW
(
void
)
{
{
WCHAR
test_path
[]
=
{
'L'
,
'o'
,
'n'
,
'g'
,
'D'
,
'i'
,
'r'
,
'e'
,
'c'
,
't'
,
'o'
,
'r'
,
'y'
,
'N'
,
'a'
,
'm'
,
'e'
,
0
};
static
const
WCHAR
extended_prefix
[]
=
{
'\\'
,
'\\'
,
'?'
,
'\\'
,
0
};
WCHAR
path
[
MAX_PATH
];
static
const
WCHAR
test_path
[]
=
{
'L'
,
'o'
,
'n'
,
'g'
,
'D'
,
'i'
,
'r'
,
'e'
,
'c'
,
't'
,
'o'
,
'r'
,
'y'
,
'N'
,
'a'
,
'm'
,
'e'
,
0
};
static
const
WCHAR
name
[]
=
{
't'
,
'e'
,
's'
,
't'
,
0
};
static
const
WCHAR
backSlash
[]
=
{
'\\'
,
0
};
WCHAR
path
[
MAX_PATH
],
tmppath
[
MAX_PATH
];
WCHAR
short_path
[
MAX_PATH
];
WCHAR
short_path
[
MAX_PATH
];
DWORD
length
;
DWORD
length
;
HANDLE
file
;
HANDLE
file
;
int
ret
;
int
ret
;
WCHAR
name
[]
=
{
't'
,
'e'
,
's'
,
't'
,
0
};
WCHAR
backSlash
[]
=
{
'\\'
,
0
};
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
GetTempPathW
(
MAX_PATH
,
path
);
GetTempPathW
(
MAX_PATH
,
tmp
path
);
if
(
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
if
(
GetLastError
()
==
ERROR_CALL_NOT_IMPLEMENTED
)
{
{
win_skip
(
"GetTempPathW is not implemented
\n
"
);
win_skip
(
"GetTempPathW is not implemented
\n
"
);
return
;
return
;
}
}
lstrcpyW
(
path
,
tmppath
);
lstrcatW
(
path
,
test_path
);
lstrcatW
(
path
,
test_path
);
lstrcatW
(
path
,
backSlash
);
lstrcatW
(
path
,
backSlash
);
ret
=
CreateDirectoryW
(
path
,
NULL
);
ret
=
CreateDirectoryW
(
path
,
NULL
);
ok
(
ret
,
"Directory was not created. LastError = %d
\n
"
,
GetLastError
()
);
ok
(
ret
,
"Directory was not created. LastError = %d
\n
"
,
GetLastError
()
);
/* Starting a main part of test */
/* Starting a main part of test */
/* extended path \\?\C:\path\ */
lstrcpyW
(
path
,
extended_prefix
);
lstrcatW
(
path
,
tmppath
);
lstrcatW
(
path
,
test_path
);
lstrcatW
(
path
,
backSlash
);
short_path
[
0
]
=
0
;
length
=
GetShortPathNameW
(
path
,
short_path
,
sizeof
(
short_path
)
/
sizeof
(
*
short_path
)
);
ok
(
length
,
"GetShortPathNameW returned 0.
\n
"
);
lstrcpyW
(
path
,
tmppath
);
lstrcatW
(
path
,
test_path
);
lstrcatW
(
path
,
backSlash
);
length
=
GetShortPathNameW
(
path
,
short_path
,
0
);
length
=
GetShortPathNameW
(
path
,
short_path
,
0
);
ok
(
length
,
"GetShortPathNameW returned 0.
\n
"
);
ok
(
length
,
"GetShortPathNameW returned 0.
\n
"
);
ret
=
GetShortPathNameW
(
path
,
short_path
,
length
);
ret
=
GetShortPathNameW
(
path
,
short_path
,
length
);
...
...
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