mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-06 06:30:46 +00:00
Fix nil path handling
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18858 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6e4c4de818
commit
bd19ee1a68
3 changed files with 35 additions and 11 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2004-03-19 Adam Fedor <fedor@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSFileManager.m (-createDirectoryAtPath:attributes:):
|
||||||
|
Return NO if path is nil.
|
||||||
|
(-createFileAtPath:contents:attributes:): Idem.
|
||||||
|
|
||||||
|
* Source/NSUser.m (NSUserName): Set initial olduid to an invalid
|
||||||
|
uid.
|
||||||
|
|
||||||
2004-03-16 Richard Frith-Macdonald <rfm@gnu.org>
|
2004-03-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSDictionary.m: Don't use stack as temporary storage for
|
* Source/NSDictionary.m: Don't use stack as temporary storage for
|
||||||
|
|
|
@ -555,7 +555,19 @@ static NSFileManager* defaultManager = nil;
|
||||||
NSEnumerator *paths = [[path pathComponents] objectEnumerator];
|
NSEnumerator *paths = [[path pathComponents] objectEnumerator];
|
||||||
NSString *subPath;
|
NSString *subPath;
|
||||||
NSString *completePath = nil;
|
NSString *completePath = nil;
|
||||||
|
#else
|
||||||
|
const char *cpath;
|
||||||
|
char dirpath[PATH_MAX+1];
|
||||||
|
struct stat statbuf;
|
||||||
|
int len, cur;
|
||||||
|
NSDictionary *needChown = nil;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is consitent with MacOSX - just return NO for an invalid path. */
|
||||||
|
if (path == nil)
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
#if defined(__MINGW__)
|
||||||
while ((subPath = [paths nextObject]))
|
while ((subPath = [paths nextObject]))
|
||||||
{
|
{
|
||||||
BOOL isDir = NO;
|
BOOL isDir = NO;
|
||||||
|
@ -583,12 +595,7 @@ static NSFileManager* defaultManager = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
const char *cpath;
|
|
||||||
char dirpath[PATH_MAX+1];
|
|
||||||
struct stat statbuf;
|
|
||||||
int len, cur;
|
|
||||||
NSDictionary *needChown = nil;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is no file owner specified, and we are running setuid to
|
* If there is no file owner specified, and we are running setuid to
|
||||||
* root, then we assume we need to change ownership to correct user.
|
* root, then we assume we need to change ownership to correct user.
|
||||||
|
@ -701,12 +708,21 @@ static NSFileManager* defaultManager = nil;
|
||||||
attributes: (NSDictionary*)attributes
|
attributes: (NSDictionary*)attributes
|
||||||
{
|
{
|
||||||
const char *cpath = [self fileSystemRepresentationWithPath: path];
|
const char *cpath = [self fileSystemRepresentationWithPath: path];
|
||||||
|
|
||||||
#if defined(__MINGW__)
|
#if defined(__MINGW__)
|
||||||
HANDLE fh;
|
HANDLE fh;
|
||||||
DWORD written = 0;
|
DWORD written = 0;
|
||||||
DWORD len = [contents length];
|
DWORD len = [contents length];
|
||||||
|
#else
|
||||||
|
int fd;
|
||||||
|
int len;
|
||||||
|
int written;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* This is consitent with MacOSX - just return NO for an invalid path. */
|
||||||
|
if (path == nil)
|
||||||
|
return NO;
|
||||||
|
|
||||||
|
#if defined(__MINGW__)
|
||||||
fh = CreateFile(cpath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS,
|
fh = CreateFile(cpath, GENERIC_WRITE, 0, 0, CREATE_ALWAYS,
|
||||||
FILE_ATTRIBUTE_NORMAL, 0);
|
FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
if (fh == INVALID_HANDLE_VALUE)
|
if (fh == INVALID_HANDLE_VALUE)
|
||||||
|
@ -728,9 +744,6 @@ static NSFileManager* defaultManager = nil;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int fd;
|
|
||||||
int len;
|
|
||||||
int written;
|
|
||||||
|
|
||||||
fd = open(cpath, GSBINIO|O_WRONLY|O_TRUNC|O_CREAT, 0644);
|
fd = open(cpath, GSBINIO|O_WRONLY|O_TRUNC|O_CREAT, 0644);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
|
|
@ -151,7 +151,9 @@ NSUserName(void)
|
||||||
format: @"Unable to determine current user name"];
|
format: @"Unable to determine current user name"];
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static int olduid = 0;
|
/* Set olduid to some invalid uid that we could never start off running
|
||||||
|
as. */
|
||||||
|
static int olduid = -1;
|
||||||
#ifdef HAVE_GETEUID
|
#ifdef HAVE_GETEUID
|
||||||
int uid = geteuid();
|
int uid = geteuid();
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue