mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-18 18:23:25 +03:00
Reduce unecessary use of directory entry headers
The config header was causing many source files to unecessarily include the dirent headers causing extra dependancies. This has been fixed by providing a utility dirent header that provides a common API across all platforms while removing the unecessary dirent header usage.
This commit is contained in:
parent
4f38963337
commit
1bc010665e
@ -19,7 +19,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
@ -29,6 +28,7 @@
|
||||
#include <cflib.h>
|
||||
#include <gem.h>
|
||||
|
||||
#include "utils/dirent.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/log.h"
|
||||
#include "desktop/plot_style.h"
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -46,6 +45,7 @@
|
||||
#include "testament.h"
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/dirent.h"
|
||||
#include "content/fetch.h"
|
||||
#include "content/fetchers.h"
|
||||
#include "content/fetchers/about.h"
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -46,6 +45,7 @@
|
||||
|
||||
#include <libwapcaplet/libwapcaplet.h>
|
||||
|
||||
#include "utils/dirent.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/errors.h"
|
||||
|
@ -33,13 +33,12 @@
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <libwapcaplet/libwapcaplet.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/dirent.h"
|
||||
#include "utils/errors.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/nsoption.h"
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include <strings.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
#define _NETSURF_UTILS_CONFIG_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <dirent.h>
|
||||
|
||||
/* Try to detect which features the target OS supports */
|
||||
|
||||
@ -107,10 +106,6 @@ char *realpath(const char *path, char *resolved_path);
|
||||
#define HAVE_SCANDIR
|
||||
#if (defined(_WIN32))
|
||||
#undef HAVE_SCANDIR
|
||||
int alphasort(const struct dirent **d1, const struct dirent **d2);
|
||||
int scandir(const char *dir, struct dirent ***namelist,
|
||||
int (*sel)(const struct dirent *),
|
||||
int (*compar)(const struct dirent **, const struct dirent **));
|
||||
#endif
|
||||
|
||||
/* This section toggles build options on and off.
|
||||
|
45
utils/dirent.h
Normal file
45
utils/dirent.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file directory traversal and entry
|
||||
*
|
||||
* This allows the obtaining of standard directory entry routines
|
||||
* functions in a uniform way despite any oddities in headers and
|
||||
* supported API between OS.
|
||||
*
|
||||
* \note This functionality was previously provided as a side effect of the
|
||||
* utils config header include.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_UTILS_DIRENT_H_
|
||||
#define _NETSURF_UTILS_DIRENT_H_
|
||||
|
||||
#include "utils/config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#ifndef HAVE_SCANDIR
|
||||
|
||||
int alphasort(const struct dirent **d1, const struct dirent **d2);
|
||||
int scandir(const char *dir, struct dirent ***namelist,
|
||||
int (*sel)(const struct dirent *),
|
||||
int (*compar)(const struct dirent **, const struct dirent **));
|
||||
#endif
|
||||
|
||||
#endif
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@ -33,7 +32,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "utils/config.h"
|
||||
#include "utils/dirent.h"
|
||||
#include "utils/filename.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
|
@ -38,7 +38,9 @@
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "utils/time.h"
|
||||
#include "utils/sys_time.h"
|
||||
#include "utils/inet.h"
|
||||
#include "utils/dirent.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/* exported interface documented in utils/utils.h */
|
||||
@ -399,11 +401,14 @@ int dir_sort_alpha(const struct dirent **d1, const struct dirent **d2)
|
||||
|
||||
|
||||
#ifndef HAVE_SCANDIR
|
||||
|
||||
/* exported function documented in utils/dirent.h */
|
||||
int alphasort(const struct dirent **d1, const struct dirent **d2)
|
||||
{
|
||||
return strcasecmp((*d1)->d_name, (*d2)->d_name);
|
||||
}
|
||||
|
||||
/* exported function documented in utils/dirent.h */
|
||||
int scandir(const char *dir, struct dirent ***namelist,
|
||||
int (*sel)(const struct dirent *),
|
||||
int (*compar)(const struct dirent **, const struct dirent **))
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "utils/log.h"
|
||||
|
Loading…
Reference in New Issue
Block a user