|
From: <cre...@us...> - 2007-08-02 17:15:12
|
Revision: 1726
http://frontierkernel.svn.sourceforge.net/frontierkernel/?rev=1726&view=rev
Author: creecode
Date: 2007-08-02 10:15:12 -0700 (Thu, 02 Aug 2007)
Log Message:
-----------
fix for crash in file.putFileDialog verb when path is empty
fix for crash in file.new verb when path is empty
Modified Paths:
--------------
Frontier/trunk/Common/source/file.c
Frontier/trunk/Common/source/fileops.c
Frontier/trunk/Common/source/filepath.c
Modified: Frontier/trunk/Common/source/file.c
===================================================================
--- Frontier/trunk/Common/source/file.c 2007-07-29 19:18:51 UTC (rev 1725)
+++ Frontier/trunk/Common/source/file.c 2007-08-02 17:15:12 UTC (rev 1726)
@@ -904,24 +904,30 @@
#ifdef MACVERSION
- static OSErr FSRefGetName ( const FSRef *fsRef, CFStringRef *name ) {
+ static OSErr FSRefGetName ( const FSRef *fsr, CFStringRef *name ) {
//
// the caller must dispose of the CFString
//
+ // 2007-08-01 creedon: changed variable fsRef to fsr to reduce
+ // confusion with FSRef definition
+ //
// 2006-07-06 creedon: created
//
-
+
HFSUniStr255 hname;
- OSErr err = FSGetCatalogInfo ( fsRef, kFSCatInfoNone, NULL, &hname, NULL, NULL );
-
- *name = CFStringCreateWithCharacters ( kCFAllocatorDefault, hname.unicode, hname.length );
-
+ OSErr err = FSGetCatalogInfo ( fsr, kFSCatInfoNone, NULL, &hname,
+ NULL, NULL );
+
+ if ( err == noErr )
+ *name = CFStringCreateWithCharacters ( kCFAllocatorDefault,
+ hname.unicode, hname.length );
+
return ( err );
} // FSRefGetName
-
-
+
+
boolean CFStringRefToStr255 ( CFStringRef input, StringPtr output ) {
//
@@ -960,14 +966,14 @@
return ( true );
} // HFSUniStr255ToStr255
-
-
+
+
boolean FSRefGetNameStr255 ( const FSRef *fsRef, Str255 bsname ) {
-
+
//
// 2006-07-06 creedon; created
//
-
+
CFStringRef csr;
OSErr err = FSRefGetName ( fsRef, &csr );
@@ -976,12 +982,12 @@
if ( csr == NULL )
return ( false );
-
+
if ( ! CFStringGetPascalString ( csr, bsname, 256, kCFStringEncodingMacRoman ) )
return ( false );
-
+
CFRelease ( csr );
-
+
return ( true );
} // FSRefGetNameStr255
Modified: Frontier/trunk/Common/source/fileops.c
===================================================================
--- Frontier/trunk/Common/source/fileops.c 2007-07-29 19:18:51 UTC (rev 1725)
+++ Frontier/trunk/Common/source/fileops.c 2007-08-02 17:15:12 UTC (rev 1726)
@@ -148,7 +148,7 @@
setoserrorparam ( bs );
- #endif
+ #endif // MACVERSION
#ifdef WIN95VERSION
@@ -3458,44 +3458,54 @@
boolean newfile ( const ptrfilespec fs, OSType creator, OSType filetype ) {
//
+ // 2007-08-01 creedon: if path is NULL oserror
+ //
+ // set err to bdNamErr by default
+ //
// 2006-06-18 creedon: for Mac, FSRef-ized
//
-
+
#ifdef MACVERSION
HFSUniStr255 name;
- OSErr err;
+ OSErr err = bdNamErr;
setfserrorparam ( fs );
- CFStringRefToHFSUniStr255 ( ( *fs ).path, &name );
+ if ( ( *fs ).path != NULL ) {
- err = FSCreateFileUnicode ( &( *fs ).fsref, name.length, name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref, NULL );
-
+ CFStringRefToHFSUniStr255 ( ( *fs ).path, &name );
+
+ err = FSCreateFileUnicode ( &( *fs ).fsref, name.length,
+ name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref, NULL );
+ }
+
return ( ! oserror ( err ) );
#endif
-
+
#ifdef WIN95VERSION
HANDLE f;
char fn[300];
-
+
copystring (fsname (fs), fn);
nullterminate (fn);
- f = CreateFile (stringbaseaddress(fn), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, NULL);
-
+ f = CreateFile (stringbaseaddress(fn), GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+
if (f == INVALID_HANDLE_VALUE) {
+
+ winfileerror (fs);
- winfileerror (fs);
-
return (false);
+
}
-
+
verify (CloseHandle (f));
+
return (true);
#endif
Modified: Frontier/trunk/Common/source/filepath.c
===================================================================
--- Frontier/trunk/Common/source/filepath.c 2007-07-29 19:18:51 UTC (rev 1725)
+++ Frontier/trunk/Common/source/filepath.c 2007-08-02 17:15:12 UTC (rev 1726)
@@ -590,34 +590,38 @@
} // setfsfile
-boolean getfsfile (const ptrfilespec fs, bigstring bsfile) {
+boolean getfsfile ( const ptrfilespec fs, bigstring bsfile ) {
//
+ // 2007-08-01 creedon: check FSRefGetNameStr255 return false if not true
+ //
// 2006-06-18 creedon: for Mac, FSRef-ized
//
-
+
#ifdef MACVERSION
if ( ( *fs ).path != NULL ) {
-
+
if ( CFStringRefToStr255 ( ( *fs ).path, bsfile ) )
return ( true );
}
else {
- FSRefGetNameStr255 ( &( *fs ).fsref, bsfile );
+
+ if ( ! FSRefGetNameStr255 ( &( *fs ).fsref, bsfile ) )
+ return ( false );
}
-
- if (stringlength ( bsfile ) > 0)
- return (true);
+
+ if ( stringlength ( bsfile ) > 0 )
+ return ( true );
long vnum;
getfsvolume ( fs, &vnum );
-
+
return ( filegetvolumename ( vnum, bsfile ) );
#endif
-
+
#ifdef WIN95VERSION
lastword ((ptrstring) fs -> fullSpecifier, '\\', bsfile);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|