mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Mingw compile fixes (NSFileManager)
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7493 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2034711e24
commit
eb642b39e2
6 changed files with 462 additions and 480 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2000-09-12 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* configure.in: Check for symlin, readlink.
|
||||
|
||||
* Source/GNUmakefile: Don't compile UnixFileHandle.m on mingw.
|
||||
(Will create WindowsFileHandle later...).
|
||||
|
||||
* Source/NSFileManager.m (-createDirectoryAtPath:attributes:]):
|
||||
Create subpaths on mingw.
|
||||
(isDeletableFileAtPath:): Implement for mingw.
|
||||
(createSymbolicLinkAtPath): Implement only if HAVE_SYMLINK
|
||||
(pathContentOfSymbolicLinkAtPath): Implement only if HAVE_READLINK
|
||||
|
||||
2000-09-13 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/gnustep/base/Unicode.h:
|
||||
|
|
|
@ -84,6 +84,9 @@
|
|||
/* Define if you have the objc_condition_timedwait function. */
|
||||
#undef HAVE_OBJC_CONDITION_TIMEDWAIT
|
||||
|
||||
/* Define if you have the readlink function. */
|
||||
#undef HAVE_READLINK
|
||||
|
||||
/* Define if you have the realpath function. */
|
||||
#undef HAVE_REALPATH
|
||||
|
||||
|
@ -102,6 +105,9 @@
|
|||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define if you have the symlink function. */
|
||||
#undef HAVE_SYMLINK
|
||||
|
||||
/* Define if you have the syslog function. */
|
||||
#undef HAVE_SYSLOG
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ FILE_AUTHORS = \
|
|||
GNU_MFILES = \
|
||||
GetDefEncoding.m \
|
||||
Unicode.m \
|
||||
UnixFileHandle.m \
|
||||
behavior.m \
|
||||
o_array.m \
|
||||
o_array_bas.m \
|
||||
|
@ -95,6 +94,12 @@ preface.m \
|
|||
mframe.m \
|
||||
objc-gnu2next.m
|
||||
|
||||
ifeq ($(GNUSTEP_TARGET_OS), mingw32)
|
||||
#GNU_MFILES +=
|
||||
else
|
||||
GNU_MFILES += UnixFileHandle.m
|
||||
endif
|
||||
|
||||
GNU_CFILES = \
|
||||
md5.c \
|
||||
numbers.c \
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#if HAVE_WINDOWS_H
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_POSIX_VERSION)
|
||||
# if defined(NeXT)
|
||||
|
@ -68,16 +71,17 @@
|
|||
|
||||
/* determine filesystem max path length */
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#if defined(_POSIX_VERSION) || defined(__WIN32__)
|
||||
# include <limits.h> /* for PATH_MAX */
|
||||
# include <utime.h>
|
||||
# if defined(__MINGW32__)
|
||||
# include <sys/utime.h>
|
||||
# else
|
||||
# include <utime.h>
|
||||
# endif
|
||||
#else
|
||||
#ifdef __MINGW__
|
||||
# include <limits.h>
|
||||
# include <sys/utime.h>
|
||||
#else
|
||||
# include <sys/param.h> /* for MAXPATHLEN */
|
||||
#endif
|
||||
# if HAVE_SYS_PARAM_H
|
||||
# include <sys/param.h> /* for MAXPATHLEN */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
|
@ -218,12 +222,36 @@ static NSFileManager* defaultManager = nil;
|
|||
attributes: (NSDictionary*)attributes
|
||||
{
|
||||
#if defined(__MINGW__)
|
||||
BOOL ok;
|
||||
NSEnumerator *paths = [[path pathComponents] objectEnumerator];
|
||||
NSString *subPath;
|
||||
|
||||
while ((subPath = [paths nextObject]))
|
||||
{
|
||||
BOOL isDir = NO;
|
||||
if (completePath == nil)
|
||||
completePath = subPath;
|
||||
else
|
||||
completePath = [completePath stringByAppendingPathComponent:subPath];
|
||||
|
||||
if ([self fileExistsAtPath:completePath isDirectory:&isDir])
|
||||
{
|
||||
if (!isDir)
|
||||
NSLog(@"WARNING: during creation of directory %@:"
|
||||
" sub path %@ exists, but is not a directory !",
|
||||
path, completePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *cpath;
|
||||
cpath = [self fileSystemRepresentationWithPath: completePath];
|
||||
if (CreateDirectory(cpath, NULL) == FALSE)
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// change attributes of last directory
|
||||
return [self changeFileAttributes:a ttributes atPath: path];
|
||||
|
||||
ok = CreateDirectory([self fileSystemRepresentationWithPath: path], NULL);
|
||||
if (ok == NO)
|
||||
ASSIGN(_lastError, @"Could not create directory");
|
||||
return ok;
|
||||
#else
|
||||
const char *cpath;
|
||||
char dirpath[PATH_MAX+1];
|
||||
|
@ -852,23 +880,25 @@ static NSFileManager* defaultManager = nil;
|
|||
|
||||
- (BOOL) isDeletableFileAtPath: (NSString*)path
|
||||
{
|
||||
if (path == nil)
|
||||
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
||||
|
||||
if (cpath == 0 || *cpath == '\0')
|
||||
return NO;
|
||||
else
|
||||
{
|
||||
const char *cpath;
|
||||
// TODO - handle directories
|
||||
|
||||
cpath = [self fileSystemRepresentationWithPath:
|
||||
[path stringByDeletingLastPathComponent]];
|
||||
|
||||
if (access(cpath, X_OK || W_OK) != 0)
|
||||
return NO;
|
||||
#if defined(__MINGW__)
|
||||
DWORD res= GetFileAttributes(cpath);
|
||||
|
||||
if (res == WIN32ERR)
|
||||
return NO;
|
||||
return (res & FILE_ATTRIBUTE_READONLY) ? NO : YES;
|
||||
#else
|
||||
cpath = [self fileSystemRepresentationWithPath:
|
||||
[path stringByDeletingLastPathComponent]];
|
||||
|
||||
return (access(cpath, X_OK || W_OK) != 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1160,18 +1190,19 @@ static NSFileManager* defaultManager = nil;
|
|||
- (BOOL) createSymbolicLinkAtPath: (NSString*)path
|
||||
pathContent: (NSString*)otherPath
|
||||
{
|
||||
#if HAVE_SYMLINK
|
||||
const char* lpath = [self fileSystemRepresentationWithPath: path];
|
||||
const char* npath = [self fileSystemRepresentationWithPath: otherPath];
|
||||
|
||||
#ifdef __MINGW__
|
||||
return NO;
|
||||
#else
|
||||
return (symlink(lpath, npath) == 0);
|
||||
#else
|
||||
return NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString*) pathContentOfSymbolicLinkAtPath: (NSString*)path
|
||||
{
|
||||
#if HAVE_READLINK
|
||||
char lpath[PATH_MAX];
|
||||
const char* cpath = [self fileSystemRepresentationWithPath: path];
|
||||
int llen = readlink(cpath, lpath, PATH_MAX-1);
|
||||
|
@ -1180,6 +1211,9 @@ static NSFileManager* defaultManager = nil;
|
|||
return [self stringWithFileSystemRepresentation: lpath length: llen];
|
||||
else
|
||||
return nil;
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Converting file-system representations
|
||||
|
|
|
@ -541,7 +541,7 @@ AC_CHECK_HEADERS(values.h)
|
|||
#--------------------------------------------------------------------
|
||||
AC_CHECK_HEADERS(sys/stat.h sys/vfs.h sys/statfs.h sys/statvfs.h pwd.h grp.h)
|
||||
AC_CHECK_HEADERS(sys/mount.h sys/types.h)
|
||||
AC_CHECK_FUNCS(statvfs)
|
||||
AC_CHECK_FUNCS(statvfs symlink readlink)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# These two headers (functions) needed by Time.m
|
||||
|
|
Loading…
Reference in a new issue