winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
November 2018
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
951 discussions
Start a n
N
ew thread
Jacek Caban : server: Fix pipe server listen queue initialization.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 62393d09e68a96e2764239fee632b06bfa92db23 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=62393d09e68a96e2764239fe…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Nov 23 15:13:32 2018 +0100 server: Fix pipe server listen queue initialization. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- server/named_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/named_pipe.c b/server/named_pipe.c index fcb33a9..8c32ef8 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -1168,6 +1168,7 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned init_pipe_end( &server->pipe_end, pipe, pipe_flags, pipe->insize ); server->pipe_end.state = FILE_PIPE_LISTENING_STATE; server->pipe_end.server_pid = get_process_id( current->process ); + init_async_queue( &server->listen_q ); list_add_head( &pipe->servers, &server->entry ); if (!(server->pipe_end.fd = alloc_pseudo_fd( &pipe_server_fd_ops, &server->pipe_end.obj, options ))) @@ -1177,7 +1178,6 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned } allow_fd_caching( server->pipe_end.fd ); set_fd_signaled( server->pipe_end.fd, 1 ); - init_async_queue( &server->listen_q ); return server; }
1
0
0
0
Jacek Caban : server: Remove no longer needed pipe_client struct.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: f487d50afde586980238160d763d8770d66b9c66 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=f487d50afde586980238160d…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Nov 23 15:13:24 2018 +0100 server: Remove no longer needed pipe_client struct. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- server/named_pipe.c | 52 ++++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/server/named_pipe.c b/server/named_pipe.c index b17f417..fcb33a9 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -70,18 +70,12 @@ struct pipe_end struct pipe_server { - struct pipe_end pipe_end; /* common header for pipe_client and pipe_server */ + struct pipe_end pipe_end; /* common header for both pipe ends */ struct list entry; /* entry in named pipe servers list */ unsigned int options; /* pipe options */ struct async_queue listen_q; /* listen queue */ }; -struct pipe_client -{ - struct pipe_end pipe_end; /* common header for pipe_client and pipe_server */ - unsigned int flags; /* file flags */ -}; - struct named_pipe { struct object obj; /* object header */ @@ -201,7 +195,7 @@ static int pipe_client_ioctl( struct fd *fd, ioctl_code_t code, struct async *as static const struct object_ops pipe_client_ops = { - sizeof(struct pipe_client), /* size */ + sizeof(struct pipe_end), /* size */ pipe_client_dump, /* dump */ pipe_end_get_type, /* get_type */ add_queue, /* add_queue */ @@ -333,9 +327,9 @@ static void pipe_server_dump( struct object *obj, int verbose ) static void pipe_client_dump( struct object *obj, int verbose ) { - struct pipe_client *client = (struct pipe_client *) obj; + struct pipe_end *client = (struct pipe_end *) obj; assert( obj->ops == &pipe_client_ops ); - fprintf( stderr, "Named pipe client server=%p\n", client->pipe_end.connection ); + fprintf( stderr, "Named pipe client server=%p\n", client->connection ); } static void named_pipe_destroy( struct object *obj) @@ -1135,7 +1129,7 @@ static int pipe_server_ioctl( struct fd *fd, ioctl_code_t code, struct async *as static int pipe_client_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) { - struct pipe_client *client = get_fd_user( fd ); + struct pipe_end *client = get_fd_user( fd ); switch(code) { @@ -1144,7 +1138,7 @@ static int pipe_client_ioctl( struct fd *fd, ioctl_code_t code, struct async *as return 0; default: - return pipe_end_ioctl( &client->pipe_end, code, async ); + return pipe_end_ioctl( client, code, async ); } } @@ -1187,28 +1181,26 @@ static struct pipe_server *create_pipe_server( struct named_pipe *pipe, unsigned return server; } -static struct pipe_client *create_pipe_client( unsigned int flags, struct named_pipe *pipe, - data_size_t buffer_size, unsigned int options ) +static struct pipe_end *create_pipe_client( struct named_pipe *pipe, data_size_t buffer_size, unsigned int options ) { - struct pipe_client *client; + struct pipe_end *client; client = alloc_object( &pipe_client_ops ); if (!client) return NULL; - client->flags = flags; - init_pipe_end( &client->pipe_end, pipe, 0, buffer_size ); - client->pipe_end.state = FILE_PIPE_CONNECTED_STATE; - client->pipe_end.client_pid = get_process_id( current->process ); + init_pipe_end( client, pipe, 0, buffer_size ); + client->state = FILE_PIPE_CONNECTED_STATE; + client->client_pid = get_process_id( current->process ); - client->pipe_end.fd = alloc_pseudo_fd( &pipe_client_fd_ops, &client->pipe_end.obj, options ); - if (!client->pipe_end.fd) + client->fd = alloc_pseudo_fd( &pipe_client_fd_ops, &client->obj, options ); + if (!client->fd) { release_object( client ); return NULL; } - allow_fd_caching( client->pipe_end.fd ); - set_fd_signaled( client->pipe_end.fd, 1 ); + allow_fd_caching( client->fd ); + set_fd_signaled( client->fd, 1 ); return client; } @@ -1253,7 +1245,7 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc { struct named_pipe *pipe = (struct named_pipe *)obj; struct pipe_server *server; - struct pipe_client *client; + struct pipe_end *client; unsigned int pipe_sharing; if (!(server = find_available_server( pipe ))) @@ -1271,17 +1263,17 @@ static struct object *named_pipe_open_file( struct object *obj, unsigned int acc return NULL; } - if ((client = create_pipe_client( options, pipe, pipe->outsize, options ))) + if ((client = create_pipe_client( pipe, pipe->outsize, options ))) { async_wake_up( &server->listen_q, STATUS_SUCCESS ); server->pipe_end.state = FILE_PIPE_CONNECTED_STATE; - server->pipe_end.connection = &client->pipe_end; - client->pipe_end.connection = &server->pipe_end; - server->pipe_end.client_pid = client->pipe_end.client_pid; - client->pipe_end.server_pid = server->pipe_end.server_pid; + server->pipe_end.connection = client; + client->connection = &server->pipe_end; + server->pipe_end.client_pid = client->client_pid; + client->server_pid = server->pipe_end.server_pid; } release_object( server ); - return &client->pipe_end.obj; + return &client->obj; } static int named_pipe_device_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
1
0
0
0
Jacek Caban : server: Store message mode flag only in named_pipe object.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 4841b5dc9f014737249046624e42b5a40e140b2b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4841b5dc9f01473724904662…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Nov 23 15:13:07 2018 +0100 server: Store message mode flag only in named_pipe object. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- server/named_pipe.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/server/named_pipe.c b/server/named_pipe.c index b96af7b..b17f417 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -85,7 +85,7 @@ struct pipe_client struct named_pipe { struct object obj; /* object header */ - unsigned int flags; + int message_mode; unsigned int sharing; unsigned int maxinstances; unsigned int outsize; @@ -661,7 +661,7 @@ static void pipe_end_get_file_info( struct fd *fd, obj_handle_t handle, unsigned } if (!(pipe_info = set_reply_data_size( sizeof(*pipe_info) ))) return; - pipe_info->NamedPipeType = (pipe_end->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE) != 0; + pipe_info->NamedPipeType = pipe->message_mode; switch (pipe->sharing) { case FILE_SHARE_READ: @@ -899,7 +899,7 @@ static int pipe_end_write( struct fd *fd, struct async *async, file_pos_t pos ) return 0; } - if (!(pipe_end->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE) && !get_req_data_size()) return 1; + if (!pipe_end->pipe->message_mode && !get_req_data_size()) return 1; iosb = async_get_iosb( async ); message = queue_message( pipe_end->connection, iosb ); @@ -962,7 +962,7 @@ static int pipe_end_peek( struct pipe_end *pipe_end ) avail += message->iosb->in_size - message->read_pos; reply_size = min( reply_size, avail ); - if (avail && (pipe_end->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE)) + if (avail && pipe_end->pipe->message_mode) { message = LIST_ENTRY( list_head(&pipe_end->message_queue), struct pipe_message, entry ); message_length = message->iosb->in_size - message->read_pos; @@ -1002,8 +1002,7 @@ static int pipe_end_transceive( struct pipe_end *pipe_end, struct async *async ) return 0; } - if ((pipe_end->flags & (NAMED_PIPE_MESSAGE_STREAM_WRITE | NAMED_PIPE_MESSAGE_STREAM_READ)) - != (NAMED_PIPE_MESSAGE_STREAM_WRITE | NAMED_PIPE_MESSAGE_STREAM_READ)) + if (!(pipe_end->flags & NAMED_PIPE_MESSAGE_STREAM_READ)) { set_error( STATUS_INVALID_READ_MODE ); return 0; @@ -1198,7 +1197,7 @@ static struct pipe_client *create_pipe_client( unsigned int flags, struct named_ return NULL; client->flags = flags; - init_pipe_end( &client->pipe_end, pipe, pipe->flags, buffer_size ); + init_pipe_end( &client->pipe_end, pipe, 0, buffer_size ); client->pipe_end.state = FILE_PIPE_CONNECTED_STATE; client->pipe_end.client_pid = get_process_id( current->process ); @@ -1375,7 +1374,7 @@ DECL_HANDLER(create_named_pipe) pipe->outsize = req->outsize; pipe->maxinstances = req->maxinstances; pipe->timeout = req->timeout; - pipe->flags = req->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE; + pipe->message_mode = (req->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE) != 0; pipe->sharing = req->sharing; if (sd) default_set_sd( &pipe->obj, sd, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | @@ -1432,13 +1431,13 @@ DECL_HANDLER(set_named_pipe_info) set_error( STATUS_PIPE_DISCONNECTED ); } else if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) || - ((req->flags & NAMED_PIPE_MESSAGE_STREAM_READ) && !(pipe_end->pipe->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE))) + ((req->flags & NAMED_PIPE_MESSAGE_STREAM_READ) && !pipe_end->pipe->message_mode)) { set_error( STATUS_INVALID_PARAMETER ); } else { - pipe_end->flags = pipe_end->pipe->flags | req->flags; + pipe_end->flags = req->flags; } release_object( pipe_end );
1
0
0
0
Jacek Caban : server: Properly handle disconnected pipe in set_named_pipe_info request.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 29be73765255c4b9386eb5561adf8f5b3434dc7e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=29be73765255c4b9386eb556…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Fri Nov 23 15:12:35 2018 +0100 server: Properly handle disconnected pipe in set_named_pipe_info request. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/tests/pipe.c | 15 ++++++++++++++- server/named_pipe.c | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c index 406d555..8448bab 100644 --- a/dlls/ntdll/tests/pipe.c +++ b/dlls/ntdll/tests/pipe.c @@ -2042,7 +2042,7 @@ static HANDLE connect_pipe_reader(HANDLE server) { HANDLE client; - client = CreateFileW(testpipe, GENERIC_READ, 0, 0, OPEN_EXISTING, + client = CreateFileW(testpipe, GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); ok(client != INVALID_HANDLE_VALUE, "can't open pipe: %u\n", GetLastError()); @@ -2146,6 +2146,19 @@ static void test_pipe_local_info(HANDLE pipe, BOOL is_server, DWORD state) ok(pipe_info.ReadMode == 0, "ReadMode = %u\n", pipe_info.ReadMode); ok(pipe_info.CompletionMode == 0, "CompletionMode = %u\n", pipe_info.CompletionMode); } + + pipe_info.ReadMode = 0; + pipe_info.CompletionMode = 0; + memset(&iosb, 0xcc, sizeof(iosb)); + status = pNtSetInformationFile(pipe, &iosb, &pipe_info, sizeof(pipe_info), FilePipeInformation); + if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE) + ok(status == STATUS_PIPE_DISCONNECTED, + "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %u: %x\n", + is_server ? "server" : "client", state, status); + else + ok(status == STATUS_SUCCESS, + "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %u: %x\n", + is_server ? "server" : "client", state, status); } static void test_file_info(void) diff --git a/server/named_pipe.c b/server/named_pipe.c index 19a5426..b96af7b 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -1427,7 +1427,11 @@ DECL_HANDLER(set_named_pipe_info) if (!pipe_end) return; } - if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) || + if (!pipe_end->pipe) + { + set_error( STATUS_PIPE_DISCONNECTED ); + } + else if ((req->flags & ~(NAMED_PIPE_MESSAGE_STREAM_READ | NAMED_PIPE_NONBLOCKING_MODE)) || ((req->flags & NAMED_PIPE_MESSAGE_STREAM_READ) && !(pipe_end->pipe->flags & NAMED_PIPE_MESSAGE_STREAM_WRITE))) { set_error( STATUS_INVALID_PARAMETER );
1
0
0
0
Zhiyi Zhang : kernelbase: Implement PathCchCanonicalize.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 5c23f3358895207706ca4cd251b0f85006c10191 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5c23f3358895207706ca4cd2…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Fri Nov 23 11:18:30 2018 +0800 kernelbase: Implement PathCchCanonicalize. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-path-l1-1-0.spec | 2 +- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/path.c | 11 +++ dlls/kernelbase/tests/path.c | 105 +++++++++++++++++++++ include/pathcch.h | 1 + 5 files changed, 119 insertions(+), 2 deletions(-) diff --git a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec index c48fe7b..6896e4a 100644 --- a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec +++ b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec @@ -5,7 +5,7 @@ @ stdcall PathCchAddExtension(wstr long wstr) kernelbase.PathCchAddExtension @ stub PathCchAppend @ stub PathCchAppendEx -@ stub PathCchCanonicalize +@ stdcall PathCchCanonicalize(ptr long wstr) kernelbase.PathCchCanonicalize @ stdcall PathCchCanonicalizeEx(ptr long wstr long) kernelbase.PathCchCanonicalizeEx @ stub PathCchCombine @ stub PathCchCombineEx diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index 340f0e2..752d489 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1034,7 +1034,7 @@ @ stdcall PathCchAddExtension(wstr long wstr) # @ stub PathCchAppend # @ stub PathCchAppendEx -# @ stub PathCchCanonicalize +@ stdcall PathCchCanonicalize(ptr long wstr) @ stdcall PathCchCanonicalizeEx(ptr long wstr long) # @ stub PathCchCombine # @ stub PathCchCombineEx diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index f04f30e..cc15d1c 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -389,6 +389,17 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens return S_OK; } +HRESULT WINAPI PathCchCanonicalize(WCHAR *out, SIZE_T size, const WCHAR *in) +{ + TRACE("%p %lu %s\n", out, size, wine_dbgstr_w(in)); + + /* Not X:\ and path > MAX_PATH - 4, return HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE) */ + if (strlenW(in) > MAX_PATH - 4 && !(isalphaW(in[0]) && in[1] == ':' && in[2] == '\\')) + return HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE); + + return PathCchCanonicalizeEx(out, size, in, PATHCCH_NONE); +} + HRESULT WINAPI PathCchCanonicalizeEx(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags) { WCHAR *buffer; diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c index 5d3d723..fd9c81d 100644 --- a/dlls/kernelbase/tests/path.c +++ b/dlls/kernelbase/tests/path.c @@ -34,6 +34,7 @@ HRESULT (WINAPI *pPathAllocCanonicalize)(const WCHAR *path_in, DWORD flags, WCHA HRESULT (WINAPI *pPathCchAddBackslash)(WCHAR *out, SIZE_T size); HRESULT (WINAPI *pPathCchAddBackslashEx)(WCHAR *out, SIZE_T size, WCHAR **endptr, SIZE_T *remaining); HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *extension); +HRESULT (WINAPI *pPathCchCanonicalize)(WCHAR *out, SIZE_T size, const WCHAR *in); HRESULT (WINAPI *pPathCchCanonicalizeEx)(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags); HRESULT (WINAPI *pPathCchCombineEx)(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags); HRESULT (WINAPI *pPathCchFindExtension)(const WCHAR *path, SIZE_T size, const WCHAR **extension); @@ -668,6 +669,108 @@ static void test_PathCchAddExtension(void) } } +static void test_PathCchCanonicalize(void) +{ + WCHAR path_inW[MAX_PATH], path_outW[MAX_PATH]; + CHAR path_outA[MAX_PATH]; + HRESULT hr; + INT i; + + if (!pPathCchCanonicalize) + { + win_skip("PathCchCanonicalize() is not available.\n"); + return; + } + + /* No NULL check for path pointers on Windows */ + if (0) + { + hr = pPathCchCanonicalize(NULL, ARRAY_SIZE(path_outW), path_inW); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + + /* MSDN says NULL path_in result in a backslash added to path_out, but the fact is that it would crash */ + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), NULL); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + } + + hr = pPathCchCanonicalize(path_outW, 0, path_inW); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + + /* Test path length */ + for (i = 0; i < MAX_PATH - 3; i++) path_inW[i] = 'a'; + path_inW[MAX_PATH - 3] = '\0'; + memset(path_outW, 0, sizeof(path_outW)); + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), path_inW); + ok(hr == HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE), "expect hr %#x, got %#x %s\n", + HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE), hr, wine_dbgstr_w(path_outW)); + ok(lstrlenW(path_outW) == 0, "got %d\n", lstrlenW(path_outW)); + + path_inW[0] = 'C'; + path_inW[1] = ':'; + path_inW[2] = '\\'; + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), path_inW); + ok(hr == S_OK, "expect hr %#x, got %#x\n", S_OK, hr); + + path_inW[MAX_PATH - 4] = '\0'; + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), path_inW); + ok(hr == S_OK, "expect hr %#x, got %#x\n", S_OK, hr); + + /* Insufficient buffer size handling */ + hr = pPathCchCanonicalize(path_outW, 1, path_inW); + ok(hr == STRSAFE_E_INSUFFICIENT_BUFFER, "expect hr %#x, got %#x\n", STRSAFE_E_INSUFFICIENT_BUFFER, hr); + + for (i = 0; i < ARRAY_SIZE(alloccanonicalize_tests); i++) + { + const struct alloccanonicalize_test *t = alloccanonicalize_tests + i; + + /* Skip testing X: path input, this case is different compared to PathAllocCanonicalize */ + /* Skip test cases where a flag is used */ + if (!lstrcmpA("C:", t->path_in) || t->flags) continue; + + MultiByteToWideChar(CP_ACP, 0, t->path_in, -1, path_inW, ARRAY_SIZE(path_inW)); + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), path_inW); + ok(hr == t->hr, "path %s expect result %#x, got %#x\n", t->path_in, t->hr, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, path_outW, -1, path_outA, ARRAY_SIZE(path_outA), NULL, NULL); + ok(!lstrcmpA(path_outA, t->path_out), "path \"%s\" expect output path \"%s\", got \"%s\"\n", t->path_in, + t->path_out, path_outA); + } + } + + /* X: path input */ + /* Fill a \ at the end of X: if there is enough space */ + MultiByteToWideChar(CP_ACP, 0, "C:", -1, path_inW, ARRAY_SIZE(path_inW)); + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), path_inW); + ok(hr == S_OK, "path %s expect result %#x, got %#x\n", "C:", S_OK, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, path_outW, -1, path_outA, ARRAY_SIZE(path_outA), NULL, NULL); + ok(!lstrcmpA(path_outA, "C:\\"), "path \"%s\" expect output path \"%s\", got \"%s\"\n", "C:", "C:\\", + path_outA); + } + + /* Don't fill a \ at the end of X: if there isn't enough space */ + MultiByteToWideChar(CP_ACP, 0, "C:", -1, path_inW, ARRAY_SIZE(path_inW)); + hr = pPathCchCanonicalize(path_outW, 3, path_inW); + ok(hr == S_OK, "path %s expect result %#x, got %#x\n", "C:", S_OK, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, path_outW, -1, path_outA, ARRAY_SIZE(path_outA), NULL, NULL); + ok(!lstrcmpA(path_outA, "C:"), "path \"%s\" expect output path \"%s\", got \"%s\"\n", "C:", "C:\\", path_outA); + } + + /* Don't fill a \ at the end of X: if there is character following X: */ + MultiByteToWideChar(CP_ACP, 0, "C:a", -1, path_inW, ARRAY_SIZE(path_inW)); + hr = pPathCchCanonicalize(path_outW, ARRAY_SIZE(path_outW), path_inW); + ok(hr == S_OK, "path %s expect result %#x, got %#x\n", "C:a", S_OK, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, path_outW, -1, path_outA, ARRAY_SIZE(path_outA), NULL, NULL); + ok(!lstrcmpA(path_outA, "C:a"), "path \"%s\" expect output path \"%s\", got \"%s\"\n", "C:a", "C:a", path_outA); + } +} + static void test_PathCchCanonicalizeEx(void) { WCHAR path_inW[PATHCCH_MAX_CCH + 1], path_outW[PATHCCH_MAX_CCH]; @@ -1836,6 +1939,7 @@ START_TEST(path) pPathCchAddBackslash = (void *)GetProcAddress(hmod, "PathCchAddBackslash"); pPathCchAddBackslashEx = (void *)GetProcAddress(hmod, "PathCchAddBackslashEx"); pPathCchAddExtension = (void *)GetProcAddress(hmod, "PathCchAddExtension"); + pPathCchCanonicalize = (void *)GetProcAddress(hmod, "PathCchCanonicalize"); pPathCchCanonicalizeEx = (void *)GetProcAddress(hmod, "PathCchCanonicalizeEx"); pPathCchFindExtension = (void *)GetProcAddress(hmod, "PathCchFindExtension"); pPathCchIsRoot = (void *)GetProcAddress(hmod, "PathCchIsRoot"); @@ -1854,6 +1958,7 @@ START_TEST(path) test_PathCchAddBackslash(); test_PathCchAddBackslashEx(); test_PathCchAddExtension(); + test_PathCchCanonicalize(); test_PathCchCanonicalizeEx(); test_PathCchFindExtension(); test_PathCchIsRoot(); diff --git a/include/pathcch.h b/include/pathcch.h index fb92c3b..708e00e 100644 --- a/include/pathcch.h +++ b/include/pathcch.h @@ -30,6 +30,7 @@ HRESULT WINAPI PathAllocCanonicalize(const WCHAR *path_in, DWORD flags, WCHAR ** HRESULT WINAPI PathCchAddBackslash(WCHAR *path, SIZE_T size); HRESULT WINAPI PathCchAddBackslashEx(WCHAR *path, SIZE_T size, WCHAR **end, SIZE_T *remaining); HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extension); +HRESULT WINAPI PathCchCanonicalize(WCHAR *out, SIZE_T size, const WCHAR *in); HRESULT WINAPI PathCchCanonicalizeEx(WCHAR *out, SIZE_T size, const WCHAR *in, DWORD flags); HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags); HRESULT WINAPI PathCchFindExtension(const WCHAR *path, SIZE_T size, const WCHAR **extension);
1
0
0
0
Zhiyi Zhang : kernelbase: Implement PathCchCanonicalizeEx.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 6c4b9111de0ee77c864ff22c56c2ef431721bc28 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=6c4b9111de0ee77c864ff22c…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Fri Nov 23 11:18:20 2018 +0800 kernelbase: Implement PathCchCanonicalizeEx. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=44999
Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-path-l1-1-0.spec | 2 +- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/path.c | 39 ++++++ dlls/kernelbase/tests/path.c | 143 +++++++++++++++++++++ include/pathcch.h | 1 + 5 files changed, 185 insertions(+), 2 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=6c4b9111de0ee77c864f…
1
0
0
0
Zhiyi Zhang : kernelbase: Implement PathAllocCanonicalize.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 165f777c3819515f25bc55dac0df5ac2809fa585 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=165f777c3819515f25bc55da…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Fri Nov 23 11:18:05 2018 +0800 kernelbase: Implement PathAllocCanonicalize. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-path-l1-1-0.spec | 2 +- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/path.c | 182 ++++++++++++ dlls/kernelbase/tests/path.c | 306 +++++++++++++++++++++ include/pathcch.h | 2 + 5 files changed, 492 insertions(+), 2 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=165f777c3819515f25bc…
1
0
0
0
Zhiyi Zhang : kernelbase: Implement PathCchRemoveFileSpec.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: d381263ae524c78e85b22787db3def64730e4f06 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d381263ae524c78e85b22787…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Fri Nov 23 11:17:53 2018 +0800 kernelbase: Implement PathCchRemoveFileSpec. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-path-l1-1-0.spec | 2 +- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/path.c | 37 ++++++ dlls/kernelbase/tests/path.c | 126 +++++++++++++++++++++ include/pathcch.h | 1 + 5 files changed, 166 insertions(+), 2 deletions(-) diff --git a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec index fcc3d7f..725f164 100644 --- a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec +++ b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec @@ -14,7 +14,7 @@ @ stdcall PathCchRemoveBackslash(wstr long) kernelbase.PathCchRemoveBackslash @ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr) kernelbase.PathCchRemoveBackslashEx @ stdcall PathCchRemoveExtension(wstr long) kernelbase.PathCchRemoveExtension -@ stub PathCchRemoveFileSpec +@ stdcall PathCchRemoveFileSpec(wstr long) kernelbase.PathCchRemoveFileSpec @ stdcall PathCchRenameExtension(wstr long wstr) kernelbase.PathCchRenameExtension @ stdcall PathCchSkipRoot(wstr ptr) kernelbase.PathCchSkipRoot @ stdcall PathCchStripPrefix(wstr long) kernelbase.PathCchStripPrefix diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index 252f47c..e7bb62d 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1043,7 +1043,7 @@ @ stdcall PathCchRemoveBackslash(wstr long) @ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr) @ stdcall PathCchRemoveExtension(wstr long) -# @ stub PathCchRemoveFileSpec +@ stdcall PathCchRemoveFileSpec(wstr long) @ stdcall PathCchRenameExtension(wstr long wstr) @ stdcall PathCchSkipRoot(wstr ptr) @ stdcall PathCchStripPrefix(wstr long) diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index b28abc4..c3fca8b 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -346,6 +346,43 @@ HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size) return next == extension ? S_FALSE : S_OK; } +HRESULT WINAPI PathCchRemoveFileSpec(WCHAR *path, SIZE_T size) +{ + const WCHAR *root_end = NULL; + SIZE_T length; + WCHAR *last; + + TRACE("%s %lu\n", wine_dbgstr_w(path), size); + + if (!path || !size || size > PATHCCH_MAX_CCH) return E_INVALIDARG; + + if (PathCchIsRoot(path)) return S_FALSE; + + PathCchSkipRoot(path, &root_end); + + /* The backslash at the end of UNC and \\* are not considered part of root in this case */ + if (root_end && root_end > path && root_end[-1] == '\\' + && (is_prefixed_unc(path) || (path[0] == '\\' && path[1] == '\\' && path[2] != '?'))) + root_end--; + + length = strlenW(path); + last = path + length - 1; + while (last >= path && (!root_end || last >= root_end)) + { + if (last - path >= size) return E_INVALIDARG; + + if (*last == '\\') + { + *last-- = 0; + break; + } + + *last-- = 0; + } + + return last != path + length - 1 ? S_OK : S_FALSE; +} + HRESULT WINAPI PathCchRenameExtension(WCHAR *path, SIZE_T size, const WCHAR *extension) { HRESULT hr; diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c index 965d9f1..2faf9e9 100644 --- a/dlls/kernelbase/tests/path.c +++ b/dlls/kernelbase/tests/path.c @@ -39,6 +39,7 @@ BOOL (WINAPI *pPathCchIsRoot)(const WCHAR *path); HRESULT (WINAPI *pPathCchRemoveBackslash)(WCHAR *path, SIZE_T path_size); HRESULT (WINAPI *pPathCchRemoveBackslashEx)(WCHAR *path, SIZE_T path_size, WCHAR **path_end, SIZE_T *free_size); HRESULT (WINAPI *pPathCchRemoveExtension)(WCHAR *path, SIZE_T size); +HRESULT (WINAPI *pPathCchRemoveFileSpec)(WCHAR *path, SIZE_T size); HRESULT (WINAPI *pPathCchRenameExtension)(WCHAR *path, SIZE_T size, const WCHAR *extension); HRESULT (WINAPI *pPathCchSkipRoot)(const WCHAR *path, const WCHAR **root_end); HRESULT (WINAPI *pPathCchStripPrefix)(WCHAR *path, SIZE_T size); @@ -787,6 +788,129 @@ static void test_PathCchRemoveExtension(void) } } +struct removefilespec_test +{ + const CHAR *path; + const CHAR *expected; + HRESULT hr; + SIZE_T size; +}; + +static const struct removefilespec_test removefilespec_tests[] = +{ + {"", "", S_FALSE}, + {"a", "", S_OK}, + {"a\\", "a", S_OK}, + {"a\\b", "a", S_OK}, + + {"\\", "\\", S_FALSE}, + {"\\a", "\\", S_OK}, + {"\\a\\", "\\a", S_OK}, + {"\\a\\b", "\\a", S_OK}, + + {"\\\\", "\\\\", S_FALSE}, + {"\\\\a", "\\\\a", S_FALSE}, + {"\\\\a\\", "\\\\a", S_OK}, + {"\\\\a\\b", "\\\\a\\b", S_FALSE}, + {"\\\\a\\b\\", "\\\\a\\b", S_OK}, + {"\\\\a\\b\\c", "\\\\a\\b", S_OK}, + + {"C:", "C:", S_FALSE}, + {"C:a", "C:", S_OK}, + {"C:a\\", "C:a", S_OK}, + {"C:a\\b", "C:a", S_OK}, + + {"C:\\", "C:\\", S_FALSE}, + {"C:\\a", "C:\\", S_OK}, + {"C:\\a\\", "C:\\a", S_OK}, + {"C:\\a\\b", "C:\\a", S_OK}, + + {"\\\\?\\", "\\\\?", S_OK}, + {"\\\\?\\a", "\\\\?", S_OK}, + {"\\\\?\\a\\", "\\\\?\\a", S_OK}, + {"\\\\?\\a\\b", "\\\\?\\a", S_OK}, + + {"\\\\?\\C:", "\\\\?\\C:", S_FALSE}, + {"\\\\?\\C:a", "\\\\?\\C:", S_OK}, + {"\\\\?\\C:a\\", "\\\\?\\C:a", S_OK}, + {"\\\\?\\C:a\\b", "\\\\?\\C:a", S_OK}, + + {"\\\\?\\C:\\", "\\\\?\\C:\\", S_FALSE}, + {"\\\\?\\C:\\a", "\\\\?\\C:\\", S_OK}, + {"\\\\?\\C:\\a\\", "\\\\?\\C:\\a", S_OK}, + {"\\\\?\\C:\\a\\b", "\\\\?\\C:\\a", S_OK}, + + {"\\\\?\\UNC\\", "\\\\?\\UNC\\", S_FALSE}, + {"\\\\?\\UNC\\a", "\\\\?\\UNC\\a", S_FALSE}, + {"\\\\?\\UNC\\a\\", "\\\\?\\UNC\\a", S_OK}, + {"\\\\?\\UNC\\a\\b", "\\\\?\\UNC\\a\\b", S_FALSE}, + {"\\\\?\\UNC\\a\\b\\", "\\\\?\\UNC\\a\\b", S_OK}, + {"\\\\?\\UNC\\a\\b\\c", "\\\\?\\UNC\\a\\b", S_OK}, + + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}", S_FALSE}, + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}", S_OK}, + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a\\", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a", S_OK}, + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a\\b", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}a", S_OK}, + + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\", S_FALSE}, + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\a", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\", S_OK}, + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\a\\", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\a", S_OK}, + {"\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\a\\b", + "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\a", S_OK}, + + /* Size tests */ + {"C:\\a", NULL, E_INVALIDARG, PATHCCH_MAX_CCH + 1}, + {"C:\\a", "C:\\", S_OK, PATHCCH_MAX_CCH}, + /* Size < original path length + 1, read beyond size */ + {"C:\\a", "C:\\", S_OK, ARRAY_SIZE("C:\\a") - 1}, + /* Size < result path length + 1 */ + {"C:\\a", NULL, E_INVALIDARG, ARRAY_SIZE("C:\\") - 1} +}; + +static void test_PathCchRemoveFileSpec(void) +{ + WCHAR pathW[PATHCCH_MAX_CCH] = {0}; + CHAR pathA[PATHCCH_MAX_CCH]; + SIZE_T size; + HRESULT hr; + INT i; + + if (!pPathCchRemoveFileSpec) + { + win_skip("PathCchRemoveFileSpec() is not available.\n"); + return; + } + + /* Null arguments */ + hr = pPathCchRemoveFileSpec(NULL, ARRAY_SIZE(pathW)); + ok(hr == E_INVALIDARG, "expect %#x, got %#x\n", E_INVALIDARG, hr); + + hr = pPathCchRemoveFileSpec(pathW, 0); + ok(hr == E_INVALIDARG, "expect %#x, got %#x\n", E_INVALIDARG, hr); + + for (i = 0; i < ARRAY_SIZE(removefilespec_tests); i++) + { + const struct removefilespec_test *t = removefilespec_tests + i; + + MultiByteToWideChar(CP_ACP, 0, t->path, -1, pathW, ARRAY_SIZE(pathW)); + size = t->size ? t->size : ARRAY_SIZE(pathW); + hr = pPathCchRemoveFileSpec(pathW, size); + ok(hr == t->hr, "path %s expect result %#x, got %#x\n", t->path, t->hr, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, pathW, -1, pathA, ARRAY_SIZE(pathA), NULL, NULL); + ok(!lstrcmpA(pathA, t->expected), "path %s expect stripped path %s, got %s\n", t->path, t->expected, pathA); + } + } +} + struct renameextension_test { const CHAR *path; @@ -1271,6 +1395,7 @@ START_TEST(path) pPathCchRemoveBackslash = (void *)GetProcAddress(hmod, "PathCchRemoveBackslash"); pPathCchRemoveBackslashEx = (void *)GetProcAddress(hmod, "PathCchRemoveBackslashEx"); pPathCchRemoveExtension = (void *)GetProcAddress(hmod, "PathCchRemoveExtension"); + pPathCchRemoveFileSpec = (void *)GetProcAddress(hmod, "PathCchRemoveFileSpec"); pPathCchRenameExtension = (void *)GetProcAddress(hmod, "PathCchRenameExtension"); pPathCchSkipRoot = (void *)GetProcAddress(hmod, "PathCchSkipRoot"); pPathCchStripPrefix = (void *)GetProcAddress(hmod, "PathCchStripPrefix"); @@ -1286,6 +1411,7 @@ START_TEST(path) test_PathCchRemoveBackslash(); test_PathCchRemoveBackslashEx(); test_PathCchRemoveExtension(); + test_PathCchRemoveFileSpec(); test_PathCchRenameExtension(); test_PathCchSkipRoot(); test_PathCchStripPrefix(); diff --git a/include/pathcch.h b/include/pathcch.h index f4c8377..12a6fc5 100644 --- a/include/pathcch.h +++ b/include/pathcch.h @@ -34,6 +34,7 @@ BOOL WINAPI PathCchIsRoot(const WCHAR *path); HRESULT WINAPI PathCchRemoveBackslash(WCHAR *path, SIZE_T path_size); HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T path_size, WCHAR **path_end, SIZE_T *free_size); HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size); +HRESULT WINAPI PathCchRemoveFileSpec(WCHAR *path, SIZE_T size); HRESULT WINAPI PathCchRenameExtension(WCHAR *path, SIZE_T size, const WCHAR *extension); HRESULT WINAPI PathCchSkipRoot(const WCHAR *path, const WCHAR **root_end); HRESULT WINAPI PathCchStripPrefix(WCHAR *path, SIZE_T size);
1
0
0
0
Zhiyi Zhang : kernelbase: Implement PathCchRemoveBackslash.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: 1e36dbb297839cbb30cc574d40e3ffa97efd346e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=1e36dbb297839cbb30cc574d…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Fri Nov 23 11:17:40 2018 +0800 kernelbase: Implement PathCchRemoveBackslash. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-path-l1-1-0.spec | 2 +- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/path.c | 10 +++++ dlls/kernelbase/tests/path.c | 49 ++++++++++++++++++++++ include/pathcch.h | 1 + 5 files changed, 62 insertions(+), 2 deletions(-) diff --git a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec index 3caaf80..fcc3d7f 100644 --- a/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec +++ b/dlls/api-ms-win-core-path-l1-1-0/api-ms-win-core-path-l1-1-0.spec @@ -11,7 +11,7 @@ @ stub PathCchCombineEx @ stdcall PathCchFindExtension(wstr long ptr) kernelbase.PathCchFindExtension @ stdcall PathCchIsRoot(wstr) kernelbase.PathCchIsRoot -@ stub PathCchRemoveBackslash +@ stdcall PathCchRemoveBackslash(wstr long) kernelbase.PathCchRemoveBackslash @ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr) kernelbase.PathCchRemoveBackslashEx @ stdcall PathCchRemoveExtension(wstr long) kernelbase.PathCchRemoveExtension @ stub PathCchRemoveFileSpec diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec index a08fd2c..252f47c 100644 --- a/dlls/kernelbase/kernelbase.spec +++ b/dlls/kernelbase/kernelbase.spec @@ -1040,7 +1040,7 @@ # @ stub PathCchCombineEx @ stdcall PathCchFindExtension(wstr long ptr) @ stdcall PathCchIsRoot(wstr) -# @ stub PathCchRemoveBackslash +@ stdcall PathCchRemoveBackslash(wstr long) @ stdcall PathCchRemoveBackslashEx(wstr long ptr ptr) @ stdcall PathCchRemoveExtension(wstr long) # @ stub PathCchRemoveFileSpec diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 05fcc2b..b28abc4 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -278,6 +278,16 @@ BOOL WINAPI PathCchIsRoot(const WCHAR *path) return FALSE; } +HRESULT WINAPI PathCchRemoveBackslash(WCHAR *path, SIZE_T path_size) +{ + WCHAR *path_end; + SIZE_T free_size; + + TRACE("%s %lu\n", debugstr_w(path), path_size); + + return PathCchRemoveBackslashEx(path, path_size, &path_end, &free_size); +} + HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T path_size, WCHAR **path_end, SIZE_T *free_size) { const WCHAR *root_end; diff --git a/dlls/kernelbase/tests/path.c b/dlls/kernelbase/tests/path.c index 9f9a88c..965d9f1 100644 --- a/dlls/kernelbase/tests/path.c +++ b/dlls/kernelbase/tests/path.c @@ -36,6 +36,7 @@ HRESULT (WINAPI *pPathCchAddExtension)(WCHAR *path, SIZE_T size, const WCHAR *ex HRESULT (WINAPI *pPathCchCombineEx)(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags); HRESULT (WINAPI *pPathCchFindExtension)(const WCHAR *path, SIZE_T size, const WCHAR **extension); BOOL (WINAPI *pPathCchIsRoot)(const WCHAR *path); +HRESULT (WINAPI *pPathCchRemoveBackslash)(WCHAR *path, SIZE_T path_size); HRESULT (WINAPI *pPathCchRemoveBackslashEx)(WCHAR *path, SIZE_T path_size, WCHAR **path_end, SIZE_T *free_size); HRESULT (WINAPI *pPathCchRemoveExtension)(WCHAR *path, SIZE_T size); HRESULT (WINAPI *pPathCchRenameExtension)(WCHAR *path, SIZE_T size, const WCHAR *extension); @@ -593,6 +594,52 @@ static const struct removebackslashex_test removebackslashex_tests [] = "\\\\?\\Volume{e51a1864-6f2d-4019-b73d-f4e60e600c26}\\a", 50, 2, S_OK} }; +static void test_PathCchRemoveBackslash(void) +{ + WCHAR pathW[PATHCCH_MAX_CCH]; + CHAR pathA[PATHCCH_MAX_CCH]; + HRESULT hr; + SIZE_T path_size; + INT i; + + if (!pPathCchRemoveBackslash) + { + win_skip("PathCchRemoveBackslash() is not available.\n"); + return; + } + + /* No NULL check for path on Windows */ + if (0) + { + hr = pPathCchRemoveBackslash(NULL, PATHCCH_MAX_CCH); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + } + + MultiByteToWideChar(CP_ACP, 0, "C:\\a\\", -1, pathW, ARRAY_SIZE(pathW)); + hr = pPathCchRemoveBackslash(pathW, 0); + ok(hr == E_INVALIDARG, "expect hr %#x, got %#x\n", E_INVALIDARG, hr); + + hr = pPathCchRemoveBackslash(pathW, PATHCCH_MAX_CCH + 1); + ok(hr == S_OK, "expect hr %#x, got %#x\n", S_OK, hr); + + hr = pPathCchRemoveBackslash(pathW, PATHCCH_MAX_CCH); + ok(hr == S_FALSE, "expect hr %#x, got %#x\n", S_FALSE, hr); + + for (i = 0; i < ARRAY_SIZE(removebackslashex_tests); i++) + { + const struct removebackslashex_test *t = removebackslashex_tests + i; + path_size = MultiByteToWideChar(CP_ACP, 0, t->path_in, -1, pathW, ARRAY_SIZE(pathW)); + hr = pPathCchRemoveBackslash(pathW, path_size); + ok(hr == t->hr, "path %s expect result %#x, got %#x\n", t->path_in, t->hr, hr); + if (SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, pathW, -1, pathA, ARRAY_SIZE(pathA), NULL, NULL); + ok(!lstrcmpA(pathA, t->path_out), "path %s expect output path %s, got %s\n", t->path_in, t->path_out, + pathA); + } + } +} + static void test_PathCchRemoveBackslashEx(void) { WCHAR pathW[PATHCCH_MAX_CCH]; @@ -1221,6 +1268,7 @@ START_TEST(path) pPathCchAddExtension = (void *)GetProcAddress(hmod, "PathCchAddExtension"); pPathCchFindExtension = (void *)GetProcAddress(hmod, "PathCchFindExtension"); pPathCchIsRoot = (void *)GetProcAddress(hmod, "PathCchIsRoot"); + pPathCchRemoveBackslash = (void *)GetProcAddress(hmod, "PathCchRemoveBackslash"); pPathCchRemoveBackslashEx = (void *)GetProcAddress(hmod, "PathCchRemoveBackslashEx"); pPathCchRemoveExtension = (void *)GetProcAddress(hmod, "PathCchRemoveExtension"); pPathCchRenameExtension = (void *)GetProcAddress(hmod, "PathCchRenameExtension"); @@ -1235,6 +1283,7 @@ START_TEST(path) test_PathCchAddExtension(); test_PathCchFindExtension(); test_PathCchIsRoot(); + test_PathCchRemoveBackslash(); test_PathCchRemoveBackslashEx(); test_PathCchRemoveExtension(); test_PathCchRenameExtension(); diff --git a/include/pathcch.h b/include/pathcch.h index f7de815..f4c8377 100644 --- a/include/pathcch.h +++ b/include/pathcch.h @@ -31,6 +31,7 @@ HRESULT WINAPI PathCchAddExtension(WCHAR *path, SIZE_T size, const WCHAR *extens HRESULT WINAPI PathCchCombineEx(WCHAR *out, SIZE_T size, const WCHAR *path1, const WCHAR *path2, DWORD flags); HRESULT WINAPI PathCchFindExtension(const WCHAR *path, SIZE_T size, const WCHAR **extension); BOOL WINAPI PathCchIsRoot(const WCHAR *path); +HRESULT WINAPI PathCchRemoveBackslash(WCHAR *path, SIZE_T path_size); HRESULT WINAPI PathCchRemoveBackslashEx(WCHAR *path, SIZE_T path_size, WCHAR **path_end, SIZE_T *free_size); HRESULT WINAPI PathCchRemoveExtension(WCHAR *path, SIZE_T size); HRESULT WINAPI PathCchRenameExtension(WCHAR *path, SIZE_T size, const WCHAR *extension);
1
0
0
0
Zhiyi Zhang : kernelbase: Implement PathCchRemoveBackslashEx.
by Alexandre Julliard
23 Nov '18
23 Nov '18
Module: wine Branch: master Commit: ceb5d598162814c5f0e01fac87b4cd93716e7c1a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ceb5d598162814c5f0e01fac…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Fri Nov 23 11:17:29 2018 +0800 kernelbase: Implement PathCchRemoveBackslashEx. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- .../api-ms-win-core-path-l1-1-0.spec | 2 +- dlls/kernelbase/kernelbase.spec | 2 +- dlls/kernelbase/path.c | 39 +++++++ dlls/kernelbase/tests/path.c | 116 +++++++++++++++++++++ include/pathcch.h | 1 + 5 files changed, 158 insertions(+), 2 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=ceb5d598162814c5f0e0…
1
0
0
0
← Newer
1
...
39
40
41
42
43
44
45
...
96
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Results per page:
10
25
50
100
200