Attempt to improve portability of determining mounted devices.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21289 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-06-06 19:40:48 +00:00
parent 9e7fcbfbfc
commit d91f6493fd
5 changed files with 994 additions and 146 deletions

View file

@ -2,6 +2,9 @@
* Source/NSWorkspace.m: ([-mountedLocalVovumePaths]) implemented
for mingw as a listing of all device names.
Implement for unix using getmntent.
* configure.ac: add checks for getmntent variations.
Tested on debian, may need tweaks for others.
2005-06-06 Adrian Robert <arobert@cogsci.ucsd.edu>

View file

@ -12,6 +12,9 @@
/* Define to 1 if you have the <cups/cups.h> header file. */
#undef HAVE_CUPS_CUPS_H
/* Define to 1 if you have the `getmntent' function. */
#undef HAVE_GETMNTENT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@ -48,6 +51,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <mntent.h> header file. */
#undef HAVE_MNTENT_H
/* Define to 1 if you have the <portaudio.h> header file. */
#undef HAVE_PORTAUDIO_H
@ -69,6 +75,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/mntent.h> header file. */
#undef HAVE_SYS_MNTENT_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@ -78,6 +87,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* mntent structure member name */
#undef MNT_MEMB
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

View file

@ -30,6 +30,17 @@
*/
#include "config.h"
#if defined(HAVE_GETMNTENT) && defined (MNT_MEMB)
#if defined(HAVE_MNTENT_H)
#include <mntent.h>
#elif defined(HAVE_SYS_MNTENT_H)
#include <sys/mntent.h>
#else
#undef HAVE_GETMNTENT
#endif
#endif
#include <Foundation/NSBundle.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSHost.h>
@ -1258,6 +1269,7 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
unichar *end;
unsigned len;
names = [NSMutableArray arrayWithCapacity: 8];
len = GetLogicalDriveStringsW(max-1, base);
while (len >= max)
{
@ -1283,12 +1295,24 @@ inFileViewerRootedAtPath: (NSString*)rootFullpath
NSZoneFree(NSDefaultMallocZone(), base);
}
#elif defined(HAVE_GETMNTENT) && defined (MNT_MEMB)
FILE *fptr = fopen("/etc/mtab", "r");
struct mntent *m;
names = [NSMutableArray arrayWithCapacity: 8];
while ((m = getmntent(fptr)) != 0)
{
NSString *path;
path = [mgr stringWithFileSystemRepresentation: m->MNT_MEMB
length: strlen(m->MNT_MEMB)];
[names addObject: path];
}
#else
// FIXME This is system specific
NSString *mtab = [NSString stringWithContentsOfFile: @"/etc/mtab"];
NSArray *mounts = [mtab componentsSeparatedByString: @"\n"];
NSMutableArray *names;
unsigned int i;
names = [NSMutableArray arrayWithCapacity: [mounts count]];

1089
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -84,6 +84,16 @@ AC_PROG_CPP
AC_CHECK_LIB(m, main)
AC_CHECK_FUNCS(rint rintf)
#--------------------------------------------------------------------
# Support for determining mountpoints
#--------------------------------------------------------------------
AC_CHECK_HEADERS(mntent.h)
AC_CHECK_HEADERS(sys/mntent.h)
AC_CHECK_MEMBER(struct mntent.mnt_dir,[AC_DEFINE(MNT_MEMB,mnt_dir,mntent structure member name)],,[#include <mntent.h>])
AC_CHECK_MEMBER(struct mntent.mnt_mountp,[AC_DEFINE(MNT_MEMB,mnt_mountp,mntent structure member name)],,[#include <sys/mntent.h>])
AC_FUNC_GETMNTENT
#--------------------------------------------------------------------
# Simple way to add a bunch of paths to the flags
#--------------------------------------------------------------------