mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +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
99feb31a2d
commit
49c945c487
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>
|
||||
|
||||
* Source/NSDictionary.m: Don't use stack as temporary storage for
|
||||
|
|
|
@ -555,7 +555,19 @@ static NSFileManager* defaultManager = nil;
|
|||
NSEnumerator *paths = [[path pathComponents] objectEnumerator];
|
||||
NSString *subPath;
|
||||
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]))
|
||||
{
|
||||
BOOL isDir = NO;
|
||||
|
@ -583,12 +595,7 @@ static NSFileManager* defaultManager = nil;
|
|||
}
|
||||
|
||||
#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
|
||||
* root, then we assume we need to change ownership to correct user.
|
||||
|
@ -701,12 +708,21 @@ static NSFileManager* defaultManager = nil;
|
|||
attributes: (NSDictionary*)attributes
|
||||
{
|
||||
const char *cpath = [self fileSystemRepresentationWithPath: path];
|
||||
|
||||
#if defined(__MINGW__)
|
||||
HANDLE fh;
|
||||
DWORD written = 0;
|
||||
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,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (fh == INVALID_HANDLE_VALUE)
|
||||
|
@ -728,9 +744,6 @@ static NSFileManager* defaultManager = nil;
|
|||
return YES;
|
||||
}
|
||||
#else
|
||||
int fd;
|
||||
int len;
|
||||
int written;
|
||||
|
||||
fd = open(cpath, GSBINIO|O_WRONLY|O_TRUNC|O_CREAT, 0644);
|
||||
if (fd < 0)
|
||||
|
|
|
@ -151,7 +151,9 @@ NSUserName(void)
|
|||
format: @"Unable to determine current user name"];
|
||||
}
|
||||
#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
|
||||
int uid = geteuid();
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue