unix: change uv_cwd not to return a trailing slash

This aligns the behavior with the Windows implementation.

PR-URL: https://github.com/libuv/libuv/pull/63
Reviewed-By: Bert Belder <bertbelder@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Saúl Ibarra Corretgé 2014-12-15 17:55:11 +01:00
parent eb986397c1
commit d4d1f32858
2 changed files with 9 additions and 0 deletions

View File

@ -207,6 +207,10 @@ API
Gets the current working directory.
.. versionchanged:: 1.1.0
On Unix the path no longer ends in a slash.
.. c:function:: int uv_chdir(const char* dir)
Changes the current working directory.

View File

@ -635,6 +635,11 @@ int uv_cwd(char* buffer, size_t* size) {
return -errno;
*size = strlen(buffer);
if (*size > 1 && buffer[*size - 1] == '/') {
buffer[*size-1] = '\0';
(*size)--;
}
return 0;
}