4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-21 00:07:36 +08:00

* external.cc (sync_wincwd): New function.

(cygwin_internal): Rename CW_SETCWD to CW_SYNC_WINCWD.  Call
	sync_wincwd from here.
	* include/sys/cygwin.h (cygwin_getinfo_types): Rename CW_SETCWD to
	CW_SYNC_WINCWD.
This commit is contained in:
Corinna Vinschen 2010-08-19 10:14:31 +00:00
parent 1087b2462f
commit e652eb9230
3 changed files with 35 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2010-08-19 Corinna Vinschen <corinna@vinschen.de>
* external.cc (sync_wincwd): New function.
(cygwin_internal): Rename CW_SETCWD to CW_SYNC_WINCWD. Call
sync_wincwd from here.
* include/sys/cygwin.h (cygwin_getinfo_types): Rename CW_SETCWD to
CW_SYNC_WINCWD.
2010-08-18 Christopher Faylor <me+cygwin@cgf.cx>
* external.cc (CW_SETCWD): New option.

View File

@ -162,6 +162,29 @@ sync_winenv ()
free (envblock);
}
/* Synchronize Win32 CWD with Cygwin CWD. Return -1 and set errno if
setting the Win32 CWD fails. */
static unsigned long
sync_wincwd ()
{
unsigned long ret = (unsigned long) -1;
/* Lock cwd. We're accessing it directly here. */
cygheap->cwd.cwd_lock.acquire ();
/* First check if the path can work at all. Fortunately we already have
an error code in the cwd, which was stored there for the sake of
spawn_guts. */
if (cygheap->cwd.get_error ())
set_errno (cygheap->cwd.get_error ());
/* Of course, SetCurrentDirectoryW still can fail, for instance, if the
CWD has been removed or renamed in the meantime. */
else if (!SetCurrentDirectoryW (cygheap->cwd.win32.Buffer))
__seterrno ();
else
ret = 0;
cygheap->cwd.cwd_lock.release ();
return ret;
}
/*
* Cygwin-specific wrapper for win32 ExitProcess and TerminateProcess.
* It ensures that the correct exit code, derived from the specified
@ -514,13 +537,10 @@ cygwin_internal (cygwin_getinfo_types t, ...)
res = (uintptr_t) strerror (err);
}
break;
case CW_SYNC_WINCWD:
res = sync_wincwd ();
break;
case CW_SETCWD:
{
cygheap->cwd.cwd_lock.acquire ();
PWCHAR cwd = cygheap->cwd.win32.Buffer;
res = !SetCurrentDirectoryW (cwd);
}
default:
set_errno (ENOSYS);
}

View File

@ -150,7 +150,7 @@ typedef enum
CW_CVT_MNT_OPTS,
CW_LST_MNT_OPTS,
CW_STRERROR,
CW_SETCWD
CW_SYNC_WINCWD
} cygwin_getinfo_types;
/* Token type for CW_SET_EXTERNAL_TOKEN */