Changeset 1946


Ignore:
Timestamp:
May 2, 2005, 4:56:25 AM (20 years ago)
Author:
bird
Message:

Changed chdir() to unix style, added _chdir_os2() as a backwards compatible api. _chdir2() and chdir() are operating identically now.

Location:
trunk/src/emx
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/include/InnoTekLIBC/backend.h

    • Property cvs2svn:cvs-rev changed from 1.20 to 1.21
    r1945 r1946  
    229229 * @returns Negative error code (errno.h) on failure.
    230230 * @param   pszPath     Path to the new current directory of the process.
    231  */
    232 int __libc_Back_fsDirCurrentSet(const char *pszPath);
     231 * @param   fDrive      Force a change of the current drive too.
     232 */
     233int __libc_Back_fsDirCurrentSet(const char *pszPath, int fDrive);
    233234
    234235/**
  • trunk/src/emx/include/stdlib.h

    • Property cvs2svn:cvs-rev changed from 1.31 to 1.32
    r1945 r1946  
    292292#ifdef __BSD_VISIBLE
    293293char    *_getcwdux(char *, size_t);
    294 /** @todo: int     _chdirux(char *); */
    295294char    *_realrealpath(const char *, char *, size_t);
    296295#endif
     
    421420long double _atofl (__const__ char *);
    422421int _chdir2 (__const__ char *);
     422int _chdir_os2 (const char *);
    423423int _chdrive (int);
    424424int _core (int);
  • trunk/src/emx/src/lib/misc/chdir.c

    • Property cvs2svn:cvs-rev changed from 1.6 to 1.7
    r1945 r1946  
    22/** @file
    33 *
    4  * chdir.
     4 * LIBC - chdir.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird@innotek.de>
     6 * Copyright (c) 2004-2005 knut st. osmundsen <bird@innotek.de>
    77 *
    88 *
     
    3636#include <InnoTekLIBC/logstrict.h>
    3737
     38
    3839/**
    39  * Changes the current directory.
     40 * Changes the current directory and drive.
     41 *
     42 * Use _chdir_os2 for a VAC/MSC compatible chdir.
    4043 *
    4144 * @returns 0 on success.
     
    4649{
    4750    LIBCLOG_ENTER("path=%p:{%s}\n", (void *)path, path);
    48     int rc = __libc_Back_fsDirCurrentSet(path);
     51    int rc = __libc_Back_fsDirCurrentSet(path, 1);
    4952    if (!rc)
    5053        LIBCLOG_RETURN_INT(0);
     
    5255    LIBCLOG_RETURN_INT(-1);
    5356}
     57
  • trunk/src/emx/src/lib/misc/chdir2.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1945 r1946  
    33#include "libc-alias.h"
    44#include <stdlib.h>
    5 #include <string.h>
    6 #include <emx/io.h>
    7 #include <emx/syscalls.h>
    8 #include <InnoTekLIBC/backend.h>
    95
    106int _chdir2 (const char *name)
    117{
    12   char old_drive, new_drive;
    13 
    14   old_drive = _getdrive ();
    15   new_drive = _fngetdrive (name);
    16   if (new_drive != 0)
    17     {
    18       if (_chdrive (new_drive) != 0)
    19         return -1;
    20       if (name[2] == 0)         /* Change drive only */
    21         return 0;
    22     }
    23   int rc = __libc_Back_fsDirCurrentSet (name);
    24   if (rc == 0)
    25     return 0;
    26   else
    27     {
    28       _chdrive (old_drive);
    29       errno = -rc;
    30       return -1;
    31     }
     8    return chdir(name);
    329}
  • trunk/src/emx/src/lib/sys/b_fsDirCurrentSet.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1945 r1946  
    4444 * @returns Negative error code (errno.h) on failure.
    4545 * @param   pszPath     Path to the new current directory of the process.
     46 * @param   fDrive      Force a change of the current drive too.
    4647 */
    47 int __libc_Back_fsDirCurrentSet(const char *pszPath)
     48int __libc_Back_fsDirCurrentSet(const char *pszPath, int fDrive)
    4849{
    49     LIBCLOG_ENTER("pszPath=%p:{%s}\n", (void *)pszPath, pszPath);
     50    LIBCLOG_ENTER("pszPath=%p:{%s} fDrive=%d\n", (void *)pszPath, pszPath, fDrive);
    5051    FS_VAR();
    5152
     
    6970         *
    7071         * If we change into or out of the unix root, we must make sure the
    71          * default disk is changed too. This means that we keep the OS/2
    72          * semantics of chdir() when not in the unix comparement, with the
    73          * obvious exception of root relative paths.
     72         * default disk is changed too. We'll only do unix chdir behaviour
     73         * when in the unix compartement or when fDrive is set.
    7474         */
    7575        FS_SAVE_LOAD();
     
    7878        if (!rc)
    7979        {
    80             if (__libc_gcchUnixRoot)
     80            if (fDrive || __libc_gcchUnixRoot)
    8181            {
    82                 if (fInUnixTree != __libc_gfInUnixTree)
     82                if (fDrive || fInUnixTree != __libc_gfInUnixTree)
    8383                {
    8484                    ULONG ulDrive = szNativePath[0] - (szNativePath[0] >= 'A' && szNativePath[0] <= 'Z' ? 'A' - 1 : 'a' -1);
     
    8686                    LIBC_ASSERTM(!rc, "DosSetDefaultDisk(%ld) -> %d. unix drive is %c\n", ulDrive, rc, szNativePath[0]);
    8787                    rc = 0;             /* ignore this kind of errors. */
     88                    __libc_gfInUnixTree = fInUnixTree;
    8889                }
    89                 __libc_gfInUnixTree = fInUnixTree;
    9090            }
    9191        }
Note: See TracChangeset for help on using the changeset viewer.