2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 POSIX function opendir().
12 #ifndef ExNext_IS_WORKING_WITHOUT_ASSIGN
24 #include <aros/debug.h>
26 /*****************************************************************************
40 pathname - Path and filename of the directory you want to open.
43 NULL for error or a directory stream
52 open(), readdir(), closedir(), rewinddir(), seekdir(),
57 ******************************************************************************/
64 #ifndef ExNext_IS_WORKING_WITHOUT_ASSIGN
74 dir
= malloc(sizeof(DIR));
81 dir
->priv
= AllocDosObject(DOS_FIB
, NULL
);
88 /* Lock is used instead of open to allow opening "" */
89 aname
= __path_u2a(name
);
90 lock
= Lock(aname
, SHARED_LOCK
);
93 errno
= IoErr2errno(IoErr());
97 #ifndef ExNext_IS_WORKING_WITHOUT_ASSIGN
98 sprintf(assign
, "READDIR%x", (unsigned)dir
);
100 if (!AssignLock(assign
, DupLock(lock
)))
102 D(bug("!AssignLock err=%d\n", IoErr()));
106 lock
= Lock(aname
, SHARED_LOCK
);
108 AssignLock(assign
, NULL
);
111 if (!Examine(lock
, dir
->priv
))
113 errno
= IoErr2errno(IoErr());
117 if (((struct FileInfoBlock
*)dir
->priv
)->fib_DirEntryType
<=0)
123 desc
= malloc(sizeof(fdesc
));
125 desc
->flags
= O_RDONLY
;
128 fd
= __getfdslot(__getfirstfd(3));
129 __setfdesc(fd
, desc
);
133 dir
->ent
.d_name
[NAME_MAX
] = '\0';
135 D(bug("opendir(%s) fd=%d\n", name
, fd
));
141 FreeDosObject(DOS_FIB
, dir
->priv
);
145 D(bug("opendir(%s) errno=%d\n", name
, errno
));