Split libc/dirent/fddir-sortix.cpp into multiple files.
This commit is contained in:
parent
ddce6045e0
commit
5dd70aa4ff
|
@ -228,7 +228,8 @@ $(CPUDIR)/fork.o \
|
||||||
$(CPUDIR)/setjmp.o \
|
$(CPUDIR)/setjmp.o \
|
||||||
$(CPUDIR)/signal.o \
|
$(CPUDIR)/signal.o \
|
||||||
$(CPUDIR)/syscall.o \
|
$(CPUDIR)/syscall.o \
|
||||||
dirent/fddir-sortix.o \
|
dirent/fdopendir.o \
|
||||||
|
dirent/opendir.o \
|
||||||
dirent/scandir.o \
|
dirent/scandir.o \
|
||||||
dlfcn/dlfcn.o \
|
dlfcn/dlfcn.o \
|
||||||
error/gnu_error.o \
|
error/gnu_error.o \
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011.
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2014.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
dirent/fddir-sortix.cpp
|
dirent/fdopendir.cpp
|
||||||
Handles the file descriptor backend for the DIR* API on Sortix.
|
Handles the file descriptor backend for the DIR* API on Sortix.
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
@ -126,7 +126,8 @@ extern "C" DIR* fdopendir(int fd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
DIR* dir = dnewdir();
|
DIR* dir = dnewdir();
|
||||||
if ( !dir ) { free(info); return NULL; }
|
if ( !dir )
|
||||||
|
return free(info), (DIR*) NULL;
|
||||||
|
|
||||||
int old_dflags = fcntl(fd, F_GETFD);
|
int old_dflags = fcntl(fd, F_GETFD);
|
||||||
if ( 0 <= old_dflags )
|
if ( 0 <= old_dflags )
|
||||||
|
@ -142,12 +143,3 @@ extern "C" DIR* fdopendir(int fd)
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" DIR* opendir(const char* path)
|
|
||||||
{
|
|
||||||
int fd = open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
|
||||||
if ( fd < 0 ) { return NULL; }
|
|
||||||
DIR* dir = fdopendir(fd);
|
|
||||||
if ( !dir ) { close(fd); return NULL; }
|
|
||||||
return dir;
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
|
||||||
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2014.
|
||||||
|
|
||||||
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||||
|
License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
dirent/opendir.cpp
|
||||||
|
Opens a stream for the directory specified by the path.
|
||||||
|
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
extern "C" DIR* opendir(const char* path)
|
||||||
|
{
|
||||||
|
int fd = open(path, O_RDONLY | O_DIRECTORY | O_CLOEXEC);
|
||||||
|
if ( fd < 0 )
|
||||||
|
return NULL;
|
||||||
|
DIR* dir = fdopendir(fd);
|
||||||
|
if ( !dir )
|
||||||
|
return close(fd), (DIR*) NULL;
|
||||||
|
return dir;
|
||||||
|
}
|
Loading…
Reference in New Issue