2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 ANSI C function chdir().
8 #include "__arosc_privdata.h"
10 #include <exec/types.h>
12 #include <proto/dos.h>
13 #include <aros/symbolsets.h>
18 /*****************************************************************************
29 Change the current working directory to the one specified by path.
32 path - Path of the directory to change to.
35 If the current directory was changed successfully, zero is returned.
36 Otherwise, -1 is returned and errno set apropriately.
39 At program exit, the current working directory will be changed back
40 to the one that was current when the program first started. If you
41 do not desire this behaviour, use dos.library/CurrentDir() instead.
42 The path given to chdir can be translated so that getcwd gives back
43 a string that is not the same but points to th same directory. For
44 example, assigns are replaced by the path where the assign points to
45 and device names (like DH0:) are replaced with the volume name
56 ******************************************************************************/
61 path
= __path_u2a(path
);
66 newlock
= Lock( path
, SHARED_LOCK
);
70 errno
= IoErr2errno( IoErr() );
74 oldlock
= CurrentDir( newlock
);
76 if( __startup_cd_changed
)
82 __startup_cd_changed
= TRUE
;
83 __startup_cd_lock
= oldlock
;
89 if( newlock
!= NULL
) UnLock( newlock
);
94 int __init_chdir(void)
96 __startup_cd_changed
= FALSE
;
101 void __exit_chdir(void)
103 if( __startup_cd_changed
)
105 BPTR lock
= CurrentDir( __startup_cd_lock
);
111 ADD2INIT(__init_chdir
, 110);
112 ADD2EXIT(__exit_chdir
, 110);