|
Last change
on this file since 1326 was 1326, checked in by bird, 22 years ago |
|
#991: Rewrite input paths.
#992: Logging.
|
-
Property cvs2svn:cvs-rev
set to
1.4
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | /* sys/chdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
|
|---|
| 2 | -- Copyright (c) 2003-2004 by knut st. osmundsen */
|
|---|
| 3 |
|
|---|
| 4 | #include "libc-alias.h"
|
|---|
| 5 | #define INCL_FSMACROS
|
|---|
| 6 | #include <os2emx.h>
|
|---|
| 7 | #include <stdlib.h>
|
|---|
| 8 | #include <errno.h>
|
|---|
| 9 | #include <emx/syscalls.h>
|
|---|
| 10 | #include "syscalls.h"
|
|---|
| 11 | #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
|
|---|
| 12 | #include <InnoTekLIBC/logstrict.h>
|
|---|
| 13 | #include <InnoTekLIBC/pathrewrite.h>
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | int __chdir (const char *pszPath)
|
|---|
| 17 | {
|
|---|
| 18 | LIBCLOG_ENTER("pszPath=%s\n", pszPath);
|
|---|
| 19 | ULONG rc;
|
|---|
| 20 | int cch;
|
|---|
| 21 | FS_VAR();
|
|---|
| 22 |
|
|---|
| 23 | /*
|
|---|
| 24 | * Rewrite the specified file path.
|
|---|
| 25 | */
|
|---|
| 26 | cch = __libc_PathRewrite(pszPath, NULL, 0);
|
|---|
| 27 | if (cch > 0)
|
|---|
| 28 | {
|
|---|
| 29 | char *pszRewritten = alloca(cch);
|
|---|
| 30 | if (!pszRewritten)
|
|---|
| 31 | {
|
|---|
| 32 | errno = ENOMEM;
|
|---|
| 33 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 34 | }
|
|---|
| 35 | cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
|
|---|
| 36 | if (cch > 0)
|
|---|
| 37 | pszPath = pszRewritten;
|
|---|
| 38 | /* else happens when someone changes the rules between the two calls. */
|
|---|
| 39 | else if (cch < 0)
|
|---|
| 40 | {
|
|---|
| 41 | errno = EAGAIN; /* non-standard, I'm sure. */
|
|---|
| 42 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | /*
|
|---|
| 47 | * Change the current directory.
|
|---|
| 48 | */
|
|---|
| 49 | FS_SAVE_LOAD();
|
|---|
| 50 | rc = DosSetCurrentDir((PCSZ)pszPath);
|
|---|
| 51 | FS_RESTORE();
|
|---|
| 52 | if (rc != 0)
|
|---|
| 53 | {
|
|---|
| 54 | _sys_set_errno(rc);
|
|---|
| 55 | LIBCLOG_RETURN_INT(-1);
|
|---|
| 56 |
|
|---|
| 57 | }
|
|---|
| 58 | LIBCLOG_RETURN_INT(0);
|
|---|
| 59 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.