|
From: <set...@us...> - 2009-05-23 20:21:53
|
Revision: 1793
http://frontierkernel.svn.sourceforge.net/frontierkernel/?rev=1793&view=rev
Author: sethdill
Date: 2009-05-23 20:21:44 +0000 (Sat, 23 May 2009)
Log Message:
-----------
Attempting to bring Conversant branch closer to sync with trunk.
Modified Paths:
--------------
Frontier/branches/Conversant/Common/source/FrontierWinMain.c
Frontier/branches/Conversant/Common/source/about.c
Frontier/branches/Conversant/Common/source/appletglue.c
Frontier/branches/Conversant/Common/source/cancoon.c
Frontier/branches/Conversant/Common/source/claycallbacks.c
Frontier/branches/Conversant/Common/source/command.c
Frontier/branches/Conversant/Common/source/dbverbs.c
Frontier/branches/Conversant/Common/source/error.c
Frontier/branches/Conversant/Common/source/file.c
Frontier/branches/Conversant/Common/source/filealias.c
Frontier/branches/Conversant/Common/source/filedialog.c
Frontier/branches/Conversant/Common/source/fileloop.c
Frontier/branches/Conversant/Common/source/filemp3.c
Frontier/branches/Conversant/Common/source/fileops.c
Frontier/branches/Conversant/Common/source/filepath.c
Frontier/branches/Conversant/Common/source/fileverbs.c
Frontier/branches/Conversant/Common/source/findinfile.c
Frontier/branches/Conversant/Common/source/frontierconfig.c
Frontier/branches/Conversant/Common/source/icon.c
Frontier/branches/Conversant/Common/source/langdll.c
Frontier/branches/Conversant/Common/source/langevaluate.c
Frontier/branches/Conversant/Common/source/langexternal.c
Frontier/branches/Conversant/Common/source/langhtml.c
Frontier/branches/Conversant/Common/source/langipc.c
Frontier/branches/Conversant/Common/source/langpack.c
Frontier/branches/Conversant/Common/source/langstartup.c
Frontier/branches/Conversant/Common/source/langsystypes.c
Frontier/branches/Conversant/Common/source/langvalue.c
Frontier/branches/Conversant/Common/source/langverbs.c
Frontier/branches/Conversant/Common/source/launch.c
Frontier/branches/Conversant/Common/source/menuverbs.c
Frontier/branches/Conversant/Common/source/miniwindow.c
Frontier/branches/Conversant/Common/source/mouse.c
Frontier/branches/Conversant/Common/source/ops.c
Frontier/branches/Conversant/Common/source/opverbs.c
Frontier/branches/Conversant/Common/source/pict.c
Frontier/branches/Conversant/Common/source/player.c
Frontier/branches/Conversant/Common/source/resources.c
Frontier/branches/Conversant/Common/source/scripts.c
Frontier/branches/Conversant/Common/source/search.c
Frontier/branches/Conversant/Common/source/shell.c
Frontier/branches/Conversant/Common/source/shellfile.c
Frontier/branches/Conversant/Common/source/shellmenu.c
Frontier/branches/Conversant/Common/source/shellsysverbs.c
Frontier/branches/Conversant/Common/source/shellverbs.c
Frontier/branches/Conversant/Common/source/shellwindow.c
Frontier/branches/Conversant/Common/source/shellwindowverbs.c
Frontier/branches/Conversant/Common/source/tableexternal.c
Frontier/branches/Conversant/Common/source/wpverbs.c
Added Paths:
-----------
Frontier/branches/Conversant/Common/source/langmysql.c
Frontier/branches/Conversant/Common/source/langsqlite.c
Modified: Frontier/branches/Conversant/Common/source/FrontierWinMain.c
===================================================================
--- Frontier/branches/Conversant/Common/source/FrontierWinMain.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/FrontierWinMain.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -3108,7 +3108,7 @@
//#endif
- #if (FRONTIERCOM == 1)
+#if (FRONTIERCOM == 1)
gcomServerInfo.hInstance = hInstance;
gcomServerInfo.hPrevInstance = hPrevInstance;
gcomServerInfo.lpCmdLine = lpCmdLine;
@@ -3174,7 +3174,7 @@
hInst = hInstance;
shellinstance = hInstance;
- /* If this is the first instance of the app. register window classes */
+ /* If this is the first instance of the app. register window classes */
if (!hPrevInstance) {
if (!InitializeApplication ())
return 0;
Modified: Frontier/branches/Conversant/Common/source/about.c
===================================================================
--- Frontier/branches/Conversant/Common/source/about.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/about.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -68,22 +68,24 @@
#include "processinternal.h"
#include "launch.h"
-#ifdef WIN95VERSION
- #include "Winland.h"
- #define idfrontiericon IDB_FRONTIER_BITMAP
-#endif
#ifdef MACVERSION
+ #include "MoreFilesX.h"
#define idfrontiericon 128
#endif
+#ifdef WIN95VERSION
+ #include "Winland.h"
+ #define idfrontiericon IDB_FRONTIER_BITMAP
+#endif
+
static long aboutopenticks; /*so we can tell how long it's been up*/
typedef struct tyaboutrecord {
-
+
Rect messagearea;
Rect aboutarea;
@@ -93,8 +95,9 @@
boolean flbigwindow;
boolean flextrastats;
-
+
long refcon;
+
} tyaboutrecord, *ptraboutrecord, **hdlaboutrecord;
@@ -185,16 +188,17 @@
#ifdef WIN95VERSION
BIGSTRING ("\x14" "Handles Allocated: "),
#endif
-
+
BIGSTRING (""),
-
+
BIGSTRING ("\x10" "Visible Agent: "),
BIGSTRING ("\x0f" "Current Time: "),
bs_APP_NAME, /* 2006-02-06 aradke: see versions.h */
- BIGSTRING ("\x02" "^0"),
+ BIGSTRING ("\x02" "^0")
+
};
@@ -266,31 +270,43 @@
static void ccdrawfrontiericon (Rect rcicn, boolean flpressed) {
-
- #if TARGET_API_MAC_CARBON == 1 /*PBS 7.0b53: draw an OS X style icon*/
-
+
+ //
+ // 2006-07-12 creedon: FSRef-ized
+ //
+ // 7.0b53 PBS: draw an OS X style icon
+ //
+
+ #ifdef MACVERSION
+
IconRef iconref;
tyfilespec programfspec;
short label;
- OSErr ec;
+ OSErr err;
Rect r = rcicn;
+ FSSpec fs;
getapplicationfilespec (nil, &programfspec);
+
+ ( void ) extendfilespec ( &programfspec, &programfspec );
+
+ err = FSRefMakeFSSpec ( &programfspec.fsref, &fs );
- if (GetIconRefFromFile (&programfspec, &iconref, &label) == noErr) {
+ if (GetIconRefFromFile (&fs, &iconref, &label) == noErr) {
- ec = PlotIconRef (&r, kAlignAbsoluteCenter, flpressed? kTransformSelected : 0, kIconServicesNormalUsageFlag, iconref);
+ err = PlotIconRef (&r, kAlignAbsoluteCenter, flpressed? kTransformSelected : 0, kIconServicesNormalUsageFlag, iconref);
ReleaseIconRef (iconref);
- if (ec == noErr)
+ if (err == noErr)
return;
- } /*if*/
- #endif
+ } // if
+
+ #endif // MACVERSION
- ploticonresource (&rcicn, kAlignAbsoluteCenter, flpressed? kTransformSelected : 0, idfrontiericon);
+ ploticonresource ( &rcicn, kAlignAbsoluteCenter, flpressed ? kTransformSelected : 0, idfrontiericon );
- } /*ccdrawfrontiericon*/
+ } // ccdrawfrontiericon
static boolean ccgettextitemrect (short item, Rect *r) {
Modified: Frontier/branches/Conversant/Common/source/appletglue.c
===================================================================
--- Frontier/branches/Conversant/Common/source/appletglue.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/appletglue.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -188,18 +188,20 @@
boolean assureappisrunning (OSType serverid, boolean flbringtofront) {
- /*
- if the application whose creator id is serverid is running, return true.
+ //
+ // 2006-06-23 creedon: replaced FSSpec with tyfilespec
+ //
+ // if the application whose creator id is serverid is running, return true.
+ //
+ // if not, we look for the application and try to launch it. we wait until it's actually running and ready to receive Apple
+ // Events.
+ //
- if not, we look for the application and try to launch it. we wait until it's
- actually running and ready to receive Apple Events.
- */
-
bigstring appname;
typrocessid psn;
- FSSpec fs;
+ tyfilespec fs;
- if (findrunningapplication (&serverid, appname, &psn)) /*already running, nothing to do*/
+ if (findrunningapplication (&serverid, appname, &psn)) // already running, nothing to do
return (true);
if (!findapplication (serverid, &fs))
@@ -209,9 +211,10 @@
return (false);
return (true);
- } /*assureappisrunning*/
+ } // assureappisrunning
+
boolean pushhandleonhandle (Handle hsource, Handle hdest) {
return (pushhandle (hsource, hdest));
Modified: Frontier/branches/Conversant/Common/source/cancoon.c
===================================================================
--- Frontier/branches/Conversant/Common/source/cancoon.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/cancoon.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -857,15 +857,15 @@
boolean ccloadspecialfile (ptrfilespec fspec, OSType filetype) {
#pragma unused (filetype)
- /*
- 7/28/92 dmb: use new finder2frontscript to set the Frontier.findertofront
- global, instead of having Frontier.finder2click always set it to true. also,
- handle updates now.
+ //
+ // 2006-06-23 creedon: replace fsname macro with getfsfile function;
+ //
+ // 2.1b3 dmb: only set finder2front to true if the sender of the 'odoc' event was the Finder
+ //
+ // 1992-07-28 dmb: use new finder2frontscript to set the Frontier.findertofront global, instead of having
+ // Frontier.finder2click always set it to true. also, handle updates now.
+ //
- 2.1b3 dmb: only set finder2front to true if the sender of the 'odoc' event
- was the Finder
- */
-
bigstring bspath;
bigstring bs;
ptrbyte pbool;
@@ -883,15 +883,19 @@
}
if (!filespectopath (fspec, bspath)) {
+
+ bigstring bs;
- filenotfounderror ((ptrstring) fsname (fspec));
+ getfsfile ( fspec, bs );
+ filenotfounderror ( bs );
+
return (false);
}
- langdeparsestring (bspath, chclosecurlyquote); /*add needed escape sequences*/
+ langdeparsestring (bspath, chclosecurlyquote); // add needed escape sequences
- if (getsystemtablescript (idfinder2frontscript, bs)) { /*frontier.findertofront=^0*/
+ if (getsystemtablescript (idfinder2frontscript, bs)) { // frontier.findertofront=^0
#ifdef MACVERSION
if ((shellevent.what == kHighLevelEvent) && ((**landgetglobals ()).maceventsender == 'MACS'))
@@ -905,15 +909,15 @@
langrunstringnoerror (bs, bs);
}
- if (!getsystemtablescript (idfinder2clickscript, bs)) /*frontier.finder2click ("^0")*/
+ if (!getsystemtablescript (idfinder2clickscript, bs)) // frontier.finder2click ("^0")
return (false);
parsedialogstring (bs, bspath, nil, nil, nil, bs);
- shellpartialeventloop (updateMask); /*handle updates first*/
+ shellpartialeventloop (updateMask); // handle updates first
return (processrunstring (bs));
- } /*ccloadspecialfile*/
+ } // ccloadspecialfile
boolean ccsavespecialfile (ptrfilespec fs, hdlfilenum fnum, short rnum, boolean flsaveas, boolean flrunnable) {
Modified: Frontier/branches/Conversant/Common/source/claycallbacks.c
===================================================================
--- Frontier/branches/Conversant/Common/source/claycallbacks.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/claycallbacks.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -282,8 +282,12 @@
#if filebrowser
boolean claygetdirid (const tybrowserspec * fsfolder, tybrowserdir *dirid) {
+
+ //
+ // 2006-06-23 creedon: FSRef-ized
+ //
- CInfoPBRec pb;
+ FSRefParam pb;
if (!getmacfileinfo (fsfolder, &pb))
return (false);
@@ -291,7 +295,7 @@
*dirid = pb.dirInfo.ioDrDirID;
return (true);
- } /*claygetdirid*/
+ } // claygetdirid
#endif
@@ -745,21 +749,26 @@
boolean claygetfilename (const tybrowserspec *pfs, bigstring name) {
-
-#if filebrowser
-
- return (filegetfilename (pfs, name));
-
-#endif
-#if odbbrowser
+ //
+ // 2006-06-23 creedon: FSRef-ized
+ //
- copystring ((*pfs).name, name);
+ #if filebrowser
+
+ return (getfsfile (pfs, name));
+
+ #endif
- return (true);
+ #if odbbrowser
+
+ copystring ((*pfs).name, name);
+
+ return (true);
+
+ #endif
-#endif
- } /*claygetfilename*/
+ } // claygetfilename
boolean clayrenamefile (tybrowserspec *fs, hdlheadrecord headnode) {
Modified: Frontier/branches/Conversant/Common/source/command.c
===================================================================
--- Frontier/branches/Conversant/Common/source/command.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/command.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -43,53 +43,59 @@
#include "command.h"
-
#define cmdtextitem 1
-
static hdlprocessrecord quickscriptprocess = nil;
+static boolean cmdsavestring ( short stringnumber, Handle htext ) {
-static boolean cmdsavestring (short stringnumber, Handle htext) {
-#pragma unused(stringnumber)
-
- /*
- the cmd dialog only has one string, so we ignore the stringnumber param.
+ #pragma unused(stringnumber)
- set the script string in the cancoondata record, for saving -- so we have
- a permanent copy of the last script he wrote across invocations of the
- program.
+ //
+ // the cmd dialog only has one string, so we ignore the stringnumber param.
+ //
+ // set the script string in the cancoondata record, for saving -- so we
+ // have a permanent copy of the last script he wrote across invocations of
+ // the program.
+ //
+ // 2004-12-03 creedon, aradke: bug fix for hscriptstring being NULL
+ //
+ // 5.0d14 dmb: hscriptstring is now a text handle, not a hdlstring.
+ //
+ // 1993-01-21 dmb: don't set superglobals manually anymore
+ //
- 1/21/93 dmb: don't set superglobals manually anymore
+ register hdlcancoonrecord hc;
- 5.0d14 dmb: hscriptstring is now a text handle, not a hdlstring.
- */
+ Handle h;
- Handle h; /* 2004-12-03 creedon - temporary handle */
- register hdlcancoonrecord hc;
+ assert ( cancoonglobals != nil );
- assert (cancoonglobals != nil);
+ hc = cancoonglobals; // copy into register
- hc = cancoonglobals; /*copy into register*/
+ if ( ! equalhandles ( htext, ( **hc ).hscriptstring ) ) {
- if (!equalhandles (htext, (**hc).hscriptstring)) {
-
- if ((**hc).hscriptstring == nil) { /* 2004-12-03 creedon, aradke */
- copyhandle (htext, &h);
- (**hc).hscriptstring = h;
+ if ( ( **hc ).hscriptstring == NULL ) {
+
+ copyhandle ( htext, &h );
+
+ ( **hc ).hscriptstring = h;
+
}
else
- copyhandlecontents (htext, (**hc).hscriptstring);
+ copyhandlecontents ( htext, ( **hc ).hscriptstring );
+
+ ( **hc ).fldirty = true;
- (**hc).fldirty = true;
}
- return (true);
- } /*cmdsavestring*/
+ return ( true );
-
+ } // cmdsavestring
+
+
static boolean cmdloadstring (short stringnumber, Handle *h) {
#pragma unused(stringnumber)
@@ -424,5 +430,18 @@
} /*cmdstart*/
+boolean cmdsetstring ( Handle h ) {
+ //
+ // 2007-07-25 creedon: created
+ //
+
+ if ( ! cmdsavestring ( NULL, h ) )
+ return ( false );
+
+ minireloadstrings ( idcommandconfig );
+
+ return ( true );
+
+ }
Modified: Frontier/branches/Conversant/Common/source/dbverbs.c
===================================================================
--- Frontier/branches/Conversant/Common/source/dbverbs.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/dbverbs.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -404,6 +404,7 @@
boolean flreadonly;
odbref odb;
+
} tyodbrecord, *ptrodbrecord, **hdlodbrecord;
@@ -463,33 +464,47 @@
static boolean getodbparam (hdltreenode hparam1, short pnum, hdlodbrecord *hodbrecord) {
+ //
+ // 2006-06-23 creedon: for Mac, FSRef-zed
+ //
+
+ bigstring bs;
hdlodbrecord hodb;
tyfilespec fs;
- tyfilespec * ptrfs;
+ ptrfilespec ptrfs;
ptrfs = &fs;
if (!getfilespecvalue (hparam1, pnum, ptrfs))
return (false);
+ ( void ) extendfilespec ( ptrfs, ptrfs );
+
for (hodb = hodblist; hodb != nil; hodb = (**hodb).hnext) {
-
- if (equalfilespecs (&(**hodb).fs, ptrfs)) {
+
+ if ( equalfilespecs ( &( **hodb ).fs, ptrfs ) ) {
*hodbrecord = hodb;
return (true);
}
}
+
+ getfsfile ( ptrfs, bs );
- lang2paramerror (dbnotopenederror, bsfunctionname, fsname(ptrfs));
+ lang2paramerror (dbnotopenederror, bsfunctionname, bs );
return (false);
- } /*getodbparam*/
+
+ } // getodbparam
static boolean getodbvalue (hdltreenode hparam1, short pnum, tyodbrecord *odb, boolean flreadonly) {
+ //
+ // 2006-06-23 creedon: for Mac, FSRef-ized
+ //
+
hdlodbrecord hodb;
if (!getodbparam (hparam1, pnum, &hodb))
@@ -498,14 +513,19 @@
*odb = **hodb;
if ((*odb).flreadonly && !flreadonly) {
+
+ bigstring bs;
+
+ getfsfile ( &( *odb ).fs, bs );
- lang2paramerror (dbopenedreadonlyerror, bsfunctionname, fsname(&(*odb).fs));
+ lang2paramerror (dbopenedreadonlyerror, bsfunctionname, bs );
return (false);
}
return (true);
- } /*getodbvalue*/
+
+ } // getodbvalue
static boolean dbclosefile (hdlodbrecord hodb) {
@@ -562,22 +582,24 @@
static boolean dbnewverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
- /*
- 4.1b5 dmb: new verb
- */
+ //
+ // 2006-06-20 creedon: for Mac, extend filespec
+ //
+ // 4.1b5 dmb: new verb
+ //
tyodbrecord odbrec;
boolean fl;
flnextparamislast = true;
- if (!getfilespecvalue (hparam1, 1, &odbrec.fs))
+ if ( ! getfilespecvalue ( hparam1, 1, &odbrec.fs ) )
return (false);
+
+ shellpushdefaultglobals (); // so that config is correct
- shellpushdefaultglobals (); /*so that config is correct*/
+ fl = opennewfile ( &odbrec.fs, config.filecreator, config.filetype, &odbrec.fref );
- fl = opennewfile (&odbrec.fs, config.filecreator, config.filetype, &odbrec.fref);
-
shellpopglobals ();
if (!fl)
@@ -589,28 +611,30 @@
if (odberror (fl)) {
- deletefile (&odbrec.fs);
+ deletefile ( &odbrec.fs );
return (false);
}
return (setbooleanvalue (true, vreturned));
- } /*dbnewverb*/
+ } // dbnewverb
static boolean dbopenverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
- /*
- 4.1b5 dmb: added ability to access already-open root in Frontier
- */
+ //
+ // 2006-06-20 creedon: for Mac, extend filespec
+ //
+ // 4.1b5 dmb: added ability to access already-open root in Frontier
+ //
tyodbrecord odbrec;
hdlodbrecord hodb;
WindowPtr w;
-
+
odbrec.fref = 0;
- if (!getfilespecvalue (hparam1, 1, &odbrec.fs))
+ if ( ! getfilespecvalue ( hparam1, 1, &odbrec.fs ) )
return (false);
flnextparamislast = true;
@@ -618,18 +642,20 @@
if (!getbooleanvalue (hparam1, 2, &odbrec.flreadonly))
return (false);
- w = shellfindfilewindow (&odbrec.fs);
+ ( void ) extendfilespec ( &odbrec.fs, &odbrec.fs );
+
+ w = shellfindfilewindow ( &odbrec.fs );
if (w != nil) {
if (odberror (odbaccesswindow (w, &odbrec.odb)))
return (false);
- /*fref remains zero, so unwanted closefiles aren't a problem*/
+ // fref remains zero, so unwanted closefiles aren't a problem
}
else {
- if (!openfile (&odbrec.fs, &odbrec.fref, odbrec.flreadonly))
+ if ( ! openfile ( &odbrec.fs, &odbrec.fref, odbrec.flreadonly))
return (false);
if (odberror (odbopenfile (odbrec.fref, &odbrec.odb, odbrec.flreadonly))) {
@@ -652,7 +678,8 @@
listlink ((hdllinkedlist) hodblist, (hdllinkedlist) hodb);
return (setbooleanvalue (true, vreturned));
- } /*dbopenverb*/
+
+ } // dbopenverb
static boolean dbsaveverb (hdltreenode hparam1, tyvaluerecord *vreturned) {
@@ -1002,6 +1029,3 @@
return (true);
} /*dbinitverbs*/
-
-
-
Modified: Frontier/branches/Conversant/Common/source/error.c
===================================================================
--- Frontier/branches/Conversant/Common/source/error.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/error.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -489,6 +489,3 @@
return (getsafetycushion ());
} /*initerror*/
-
-
-
Modified: Frontier/branches/Conversant/Common/source/file.c
===================================================================
--- Frontier/branches/Conversant/Common/source/file.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/file.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -29,11 +29,10 @@
#include "standard.h"
#ifdef MACVERSION
- #if TARGET_API_MAC_CARBON
- #include "MoreFilesX.h"
- #else
- #include "MoreFilesExtras.h"
- #endif
+
+ #include "MoreFilesX.h"
+ #include <sys/param.h>
+
#endif
#include "filealias.h"
@@ -53,41 +52,46 @@
#include "langinternal.h" /*for langbackgroundtask*/
-#ifdef MACVERSION
-#ifdef flcomponent
-
- #include "SetUpA5.h"
-
-#endif
-#endif
-
-
-
-boolean equalfilespecs (const tyfilespec *fs1, const tyfilespec *fs2) {
+boolean equalfilespecs ( const ptrfilespec fs1, const ptrfilespec fs2 ) {
- /*
- 5.0a25 dmb: until we set the volumeID to zero for all Win fsspecs,
- we must not compare them here
- */
+ //
+ // 2006-06-18 creedon: for Mac, FSRef-ized
+ //
+ // 5.0a25 dmb: until we set the volumeID to zero for all Win fsspecs, we must not compare them here
+ //
#ifdef MACVERSION
- if ((*fs1).vRefNum != (*fs2).vRefNum)
- return (false);
+
+ if ( FSCompareFSRefs ( &( *fs1 ).fsref, &( *fs2 ).fsref ) != noErr )
+ return ( false );
+
+ // seems like the checking could be improved for paths, what if one is NULL and the other is not?
+
+ if ( ( ( *fs1 ).path != NULL ) && ( ( *fs2 ).path != NULL ) )
+ if ( CFStringCompare ( ( *fs1 ).path, ( *fs2 ).path, 0 ) != kCFCompareEqualTo )
+ return ( false );
+
+ bigstring bs1, bs2;
- if ((*fs1).parID != (*fs2).parID)
- return (false);
+ getfsfile ( fs1, bs1 );
+ getfsfile ( fs2, bs2 );
- return (equalstrings ((ptrstring) fsname (fs1), (ptrstring) fsname (fs2)));
+ return ( equalstrings ( bs1, bs2 ) );
+
#endif
+
#ifdef WIN95VERSION
- //if ((*fs1).volumeID != (*fs2).volumeID)
+
+ // if ((*fs1).volumeID != (*fs2).volumeID)
// return (false);
- return (lstrcmp(fsname (fs1), fsname (fs2)) == 0);
-#endif
- } /*equalfilespecs*/
+ return ( comparestrings ( fsname ( fs1 ), fsname ( fs2 ) ) == 0 );
+
+ #endif
+ } // equalfilespecs
+
boolean filesetposition (hdlfilenum fnum, long position) {
/*
@@ -461,31 +465,42 @@
#endif //MACVERSION
-boolean flushvolumechanges (const tyfilespec *fs, hdlfilenum fnum) {
-#ifdef MACVERSION
-# pragma unused(fnum)
+boolean flushvolumechanges (const ptrfilespec fs, hdlfilenum fnum) {
- /*
- 4.1b7 dmb: was -- FlushVol (nil, (*fs).vRefNum);
+ #ifdef MACVERSION
- now use PB call to do asynch flush
- */
+ # pragma unused(fnum)
+
+ /*
+ 4.1b7 dmb: was -- FlushVol (nil, (*fs).vRefNum);
+
+ now use PB call to do asynch flush
+ */
+
+ ParamBlockRec *pb;
+
+ pb = (ParamBlockRec *) NewPtrClear (sizeof (ParamBlockRec));
+
+ FSCatalogInfo catalogInfo;
+ OSErr err;
+
+ err = FSGetCatalogInfo ( &( *fs ).fsref, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL );
+
+ (*pb).volumeParam.ioVRefNum = catalogInfo.volume;
+
+ (*pb).volumeParam.ioCompletion = iocompletionUPP;
+
+ PBFlushVolAsync (pb);
+
+ #endif
+
+ #ifdef WIN95VERSION
- ParamBlockRec *pb;
+ if (fnum != NULL)
+ FlushFileBuffers (fnum);
+
+ #endif
- pb = (ParamBlockRec *) NewPtrClear (sizeof (ParamBlockRec));
-
- (*pb).volumeParam.ioVRefNum = (*fs).vRefNum;
-
- (*pb).volumeParam.ioCompletion = iocompletionUPP;
-
- PBFlushVolAsync (pb);
-#endif
-
-#ifdef WIN95VERSION
- if (fnum != NULL)
- FlushFileBuffers (fnum);
-#endif
return (true);
} /*flushvolumechanges*/
@@ -508,287 +523,269 @@
} /*fileshutdown*/
-static boolean filecreateandopen (const tyfilespec *fs, OSType creator, OSType filetype, hdlfilenum *fnum) {
-#ifdef MACVERSION
- OSStatus err = noErr;
-// char s[256];
-
- setfserrorparam (fs);
+static boolean filecreateandopen ( ptrfilespec fs, OSType creator, OSType filetype, hdlfilenum *fnum) {
+
+ //
+ // 2006-09-15 creedon: for Mac, FSRef-ized
+ //
- if (oserror (FSpCreate (fs, creator, filetype, smSystemScript))) /*failed to open the file for writing*/
- return (false);
-
- if (oserror (FSpOpenDF (fs, fsRdWrPerm, fnum))) {
+ #ifdef MACVERSION
- FSClose (*fnum);
+ HFSUniStr255 name;
+ OSErr err;
- deletefile (fs);
+ setfserrorparam ( fs );
- return (false); /*failed to open the file for writing*/
- }
-
- #if TARGET_API_MAC_CARBON
- {
- FSRef myRef;
- err = FSpMakeFSRef (fs,&myRef);
- if (!err)
- FSSetNameLocked(&myRef);
- }
- #endif
+ CFStringRefToHFSUniStr255 ( ( *fs ).path, &name );
- return (true);
-#endif
+ err = FSCreateFileUnicode ( &( *fs ).fsref, name.length, name.unicode, kFSCatInfoNone, NULL, &( *fs ).fsref, NULL );
+
+ if ( oserror ( err ) )
+ return (false);
+
+ CFRelease ( ( *fs ).path );
+
+ ( *fs ).path = NULL; // clear out path
+
+ HFSUniStr255 dataforkname;
+
+ err = FSGetDataForkName ( &dataforkname );
+
+ if ( oserror ( err ) )
+ return ( false );
+
+ err = FSOpenFork ( &( *fs ).fsref, dataforkname.length, dataforkname.unicode, fsRdWrPerm, fnum );
-#ifdef WIN95VERSION
- HANDLE fref;
-
- fref = (Handle) CreateFile (stringbaseaddress (fsname (fs)), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
- NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- *fnum = 0;
-
- if (fref == INVALID_HANDLE_VALUE) {
+ if ( oserror ( err ) ) {
+
+ FSClose (*fnum);
+
+ deletefile (fs);
+
+ return (false); // failed to open the file for writing
+
+ }
- winfileerror (fs);
+ FSSetNameLocked ( &( *fs ).fsref );
+
+ return (true);
+
+ #endif
- return (false);
- }
-
- *fnum = (hdlfilenum) fref;
- return (true);
-#endif
- } /*filecreateandopen*/
-
-
-boolean fileopenorcreate (const tyfilespec *fs, OSType creator, OSType filetype, hdlfilenum *fnum) {
-#ifdef MACVERSION
- /*
- open or create a file indicated by fs. return with fnum set to the Mac
- filesystem's file number for the file.
+ #ifdef WIN95VERSION
- if we open a file, we takes what we get in the creator and filetype department.
- however, if we create a file it's of the indicated filetype and creator.
- */
-
- if (FSpOpenDF (fs, fsRdWrPerm, fnum) == noErr) {
- /*file exists and is open*/
- #if TARGET_API_MAC_CARBON
- FSRef myRef;
- if (FSpMakeFSRef (fs,&myRef))
- FSSetNameLocked(&myRef);
- #else
- FSpSetNameLocked(&fs);
- #endif
- return (true);
- }
- return (filecreateandopen (fs, creator, filetype, fnum));
-#endif
+ HANDLE fref;
-#ifdef WIN95VERSION
- HANDLE fref;
- DWORD dAccess;
- char fn[300];
+ fref = (Handle) CreateFile (stringbaseaddress (fsname (fs)), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
+ NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ *fnum = 0;
- dAccess = GENERIC_READ | GENERIC_WRITE;
+ if (fref == INVALID_HANDLE_VALUE) {
+
+ winfileerror (fs);
- copystring (fsname (fs), fn);
-
- nullterminate (fn);
+ return (false);
+ }
- fref = (Handle) CreateFile (stringbaseaddress(fn), dAccess, FILE_SHARE_READ,
- NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- *fnum = 0;
-
- if (fref == INVALID_HANDLE_VALUE) {
+ *fnum = (hdlfilenum) fref;
- winfileerror (fs);
+ return (true);
+
+ #endif
+
+ } // filecreateandopen
- return (false);
- }
- *fnum = (hdlfilenum) fref;
- return (true);
-#endif
- } /*fileopenorcreate*/
+boolean opennewfile ( ptrfilespec fs, OSType creator, OSType filetype, hdlfilenum *fnum ) {
-
-boolean opennewfile (const tyfilespec *fs, OSType creator, OSType filetype, hdlfilenum *fnum) {
+ //
+ // 2006-09-13 creedon: for Mac, FSRef-ized
+ //
boolean flfolder;
+ tyfilespec fst;
- if (fileexists (fs, &flfolder)) { /*file exists, delete it*/
+ ( void ) extendfilespec ( fs, &fst );
+
+ if ( fileexists ( &fst, &flfolder ) ) { // file exists, delete it
+
//WriteToConsole("We're deleting a file that already exists. No idea why.");
- if (!deletefile (fs))
- return (false);
+
+ if ( ! deletefile ( &fst ) )
+ return ( false );
}
- return (filecreateandopen (fs, creator, filetype, fnum));
- } /*opennewfile*/
+ return ( filecreateandopen ( fs, creator, filetype, fnum ) );
+
+ } // opennewfile
-boolean openfile (const tyfilespec *fs, hdlfilenum *fnum, boolean flreadonly) {
+boolean openfile ( const ptrfilespec fs, hdlfilenum *fnum, boolean flreadonly ) {
-#ifdef MACVERSION
- /*
- 5/23/91 dmb: make sure we clear fnum on error; if file is already open,
- FSOpen will set fnum to the existing channel
-
- 4.1b4 dmb: added flreadonly paramater
- */
-
- OSErr errcode;
- OSErr err = noErr;
- short perm;
-
- setfserrorparam (fs); /*in case error message takes a filename parameter*/
-
- if (flreadonly)
- perm = fsRdPerm;
- else
- perm = fsRdWrPerm;
+ //
+ // 2006-06-26 creedon: for Mac, FSRef-ized
+ //
+ // 4.1b4 dmb: on Mac added flreadonly paramater
+ //
+ // 1991-05-23 dmb: on Mac make sure we clear fnum on error; if file is already open,
+ // FSOpen will set fnum to the existing channel
+ //
+
+ #ifdef MACVERSION
+
+ OSErr err;
+ short perm;
+
+ setfserrorparam ( fs ); // in case error message takes a filename parameter
+
+ if (flreadonly)
+ perm = fsRdPerm;
+ else
+ perm = fsRdWrPerm;
- errcode = FSpOpenDF (fs, perm, fnum);
-
- if (oserror (errcode)) {
+ HFSUniStr255 dataforkname;
- *fnum = 0;
+ err = FSGetDataForkName ( &dataforkname );
- return (false);
- }
- #if TARGET_API_MAC_CARBON
- {
- FSRef myRef;
- err = FSpMakeFSRef (fs,&myRef);
- if (!err)
- err = FSSetNameLocked(&myRef);
- }
- #else
- err = FSpSetNameLocked(fs);
+ if ( oserror ( err ) )
+ return ( false );
+
+ err = FSOpenFork ( &( *fs ).fsref, dataforkname.length, dataforkname.unicode, perm, fnum );
+
+ if ( oserror ( err ) ) {
+
+ *fnum = 0;
+
+ return (false);
+ }
+
+ FSSetNameLocked ( &( *fs ).fsref );
+
+ return (true);
+
#endif
+
+ #ifdef WIN95VERSION
- if (err!=noErr){
- //sprintf(s,"error locking file name: %d",err);
- //WriteToConsole(s);
- }
-
- return (true);
-#endif
+ HANDLE fref;
+ DWORD dAccess;
+ char fn[300];
-#ifdef WIN95VERSION
- HANDLE fref;
- DWORD dAccess;
- char fn[300];
+ if (flreadonly)
+ dAccess = GENERIC_READ;
+ else
+ dAccess = GENERIC_READ | GENERIC_WRITE;
- if (flreadonly)
- dAccess = GENERIC_READ;
- else
- dAccess = GENERIC_READ | GENERIC_WRITE;
+ copystring (fsname (fs), fn);
- copystring (fsname (fs), fn);
+ nullterminate (fn);
- nullterminate (fn);
+ fref = (Handle) CreateFile (stringbaseaddress(fn), dAccess, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ *fnum = 0;
- fref = (Handle) CreateFile (stringbaseaddress(fn), dAccess, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- *fnum = 0;
+ if (fref == INVALID_HANDLE_VALUE) {
+
+ winfileerror (fs);
- if (fref == INVALID_HANDLE_VALUE) {
+ return (false);
+ }
+
+ *fnum = (hdlfilenum) fref;
+ return (true);
- winfileerror (fs);
-
- return (false);
- }
-
- *fnum = (hdlfilenum) fref;
- return (true);
-#endif
- } /*openfile*/
+ #endif
-/*******
+ } // openfile
-From MoreFilesExtras.
-I'm going to use this to yank the fsspec back out from a refnum,
-so that I can clear the finder name lock from the file prior to closing it.
-*******/
-
-
boolean closefile (hdlfilenum fnum) {
-#ifdef MACVERSION
- OSStatus err = noErr;
-// char s[256];
+
+ //
+ // 2006-06-22 creedon: for Mac FSRef-ized
+ //
+ // 1990-08-20 dmb: on Mac check for 0.
+ //
+ // From MoreFilesExtras. I'm going to use this to yank the fsspec back out from a refnum, so that I can clear the finder
+ // name lock from the file prior to closing it.
+ //
- /*
- dmb 8/20/90: check for 0.
- */
+ #ifdef MACVERSION
- if (fnum != 0) {
- #if TARGET_API_MAC_CARBON
- FSRef myRef;
- err = FileRefNumGetFSRef (fnum, &myRef);
- if (err == noErr) {
- FSClearNameLocked (&myRef);
+ OSStatus err = noErr;
+
+ if ( fnum != 0 ) {
+
+ FSRef fsr;
+
+ err = FileRefNumGetFSRef ( fnum, &fsr );
+
+ if ( err == noErr ) {
+ FSClearNameLocked ( &fsr );
}
- #else
- FSSpec fs;
- err = FSpGetFileLocation (fnum,&fs);
- if (err==noErr) {
- FSpClearNameLocked (&fs);
- }
- #endif
else {
//sprintf(s,"Error is %d",err);
//WriteToConsole(s);
}
-
- return (!oserror (FSClose (fnum)));
- }
+
+ err = FSCloseFork ( fnum );
+
+ return ( ! oserror ( err ) );
+
+ }
+
+ return ( true );
+
+ #endif
+
+ #ifdef WIN95VERSION
- return (true);
-#endif
-
-#ifdef WIN95VERSION
- if (fnum != 0) {
-
- if (!CloseHandle (fnum)) {
+ if (fnum != 0) {
- winerror ();
+ if (!CloseHandle (fnum)) {
+
+ winerror ();
- return (false);
+ return (false);
+ }
}
- }
+
+ return (true);
+ #endif
- return (true);
-#endif
- } /*closefile*/
+ } // closefile
-boolean deletefile (const tyfilespec *fs) {
+boolean deletefile ( const ptrfilespec fs ) {
- /*
- 2.1b2 dmb: new filespec-based version
-
- 5.0.1 dmb: always setsferror param
- */
+ //
+ // 2006-06-26 creedon: for Mac, FSRef-ized
+ //
+ // 5.0.1 dmb: always setfserror param
+ //
+ // 2.1b2 dmb: on Mac new filespec-based version
+ //
#ifdef MACVERSION
- setfserrorparam (fs); /*in case error message takes a filename parameter*/
- #if TARGET_API_MAC_CARBON
- {
- FSRef myRef;
- if (FSpMakeFSRef (fs,&myRef))
- FSClearNameLocked(&myRef);
- }
- #else
- FSpClearNameLocked(fs);
- #endif
- return (!oserror (FSpDelete (fs)));
+
+ OSErr err;
+
+ setfserrorparam ( fs ); // in case error message takes a filename parameter
+
+ FSClearNameLocked ( &( *fs ).fsref );
+
+ err = FSDeleteObject ( &( *fs ).fsref );
+
+ return ( ! oserror ( err ) );
+
#endif
#ifdef WIN95VERSION
+
char fn[300];
boolean fldeletefolder;
- setfserrorparam (fs); /*in case error message takes a filename parameter*/
+ setfserrorparam (fs); // in case error message takes a filename parameter
copystring (fsname (fs), fn);
@@ -815,102 +812,304 @@
return (false);
#endif
- } /*deletefile*/
+ } // deletefile
+
-boolean fileexists (const tyfilespec *fs, boolean *flfolder) {
-#ifdef MACVERSION
- /*
- we figure if we can get info on it, it must exist.
+boolean fileexists ( const ptrfilespec fs, boolean *flfolder ) {
+
+ //
+ // we figure if we can get info on it, it must exist.
+ //
+ // can't call filegetinfo because it has an error message if the file isn't found.
+ //
+ // 2006-06-19 creedon: Mac OS X bundles/packages are not considered folders
+ //
+ // for Mac, FSRef-ized
+ //
+ // 5.0.2b15 rab: on Mac return false to non-existent volume specs.
+ //
+ // 2.1b2 dmb: on Mac filespec implementation
+ //
+ // 7/1/91 dmb: on Mac special case empty string so we don't try to get info about the default volume and return true.
+ //
- can't call filegetinfo because it has an error message if the file
- isn't found.
+ #ifdef MACVERSION
- 7/1/91 dmb: special case empty string so we don't try to get info about
- the default volume and return true.
+ FSCatalogInfo catalogInfo;
- 2.1b2 dmb: filespec implementation
+ *flfolder = false;
+
+ if ( ( *fs ).path != NULL )
+ return ( false );
+
+ if ( FSGetCatalogInfo ( &( *fs ).fsref, kFSCatInfoNodeFlags, &catalogInfo, NULL, NULL, NULL ) != noErr )
+ return ( false );
+
+ *flfolder = ( ( catalogInfo.nodeFlags & kFSNodeIsDirectoryMask ) != 0 );
+
+ /* Mac OS X bundles/packages are not considered folders */ {
- 5.0.2b15 rab: return false to non-existent volume specs.
- */
+ boolean flisapplication, flisbundle;
+
+ LSIsApplication ( &( *fs ).fsref, &flisapplication, &flisbundle );
+
+ if ( flisapplication || flisbundle )
+ *flfolder = false;
+ }
+
+ return (true);
+
+ #endif
- CInfoPBRec pb;
+ #ifdef WIN95VERSION
- *flfolder = false;
+ HANDLE ff;
+ WIN32_FIND_DATA ffd;
+ char fn[300];
+
+ *flfolder = false;
+
+ copystring (fsname (fs), fn);
+
+ /*if ends with \ get rid of it... and handle the root*/
+
+ cleanendoffilename (fn);
+
+ nullterminate (fn);
+
+ if (stringlength(fn) == 2) {
+ if (isalpha(fn[1]) && fn[2] == ':') {
+ *flfolder = true;
+ return (fileisvolume(fs));
+ }
+ }
+
+ ff = FindFirstFile (stringbaseaddress(fn), &ffd);
+
+ if (ff == INVALID_HANDLE_VALUE)
+ return (false);
+
+ *flfolder = ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY?true:false;
+
+ FindClose (ff);
+
+ return (true);
+
+ #endif
- if (isemptystring (fsname (fs)))
- return (false);
+ } // fileexists
+
+
+#ifdef MACVERSION
+
+ static OSErr FSRefGetName ( const FSRef *fsr, CFStringRef *name ) {
- clearbytes (&pb, sizeof (pb));
+ //
+ // 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 ( fsr, kFSCatInfoNone, NULL, &hname,
+ NULL, NULL );
+
+ if ( err == noErr )
+ *name = CFStringCreateWithCharacters ( kCFAllocatorDefault,
+ hname.unicode, hname.length );
+
+ return ( err );
+
+ } // FSRefGetName
- pb.hFileInfo.ioNamePtr = (StringPtr) fsname (fs);
- pb.hFileInfo.ioVRefNum = (*fs).vRefNum;
+ boolean CFStringRefToStr255 ( CFStringRef input, StringPtr output ) {
- pb.hFileInfo.ioDirID = (*fs).parID;
-
- if (PBGetCatInfoSync (&pb) != noErr)
- return (false);
-
- *flfolder = foldertest (&pb);
-
- return (true);
-#endif
-#ifdef WIN95VERSION
- HANDLE ff;
- WIN32_FIND_DATA ffd;
- char fn[300];
+ //
+ // 2006-08-08 creedon: created, cribbed from < http://developer.apple.com/carbon/tipsandtricks.html#CFStringFromUnicode >
+ //
+
+ CFIndex usedBufLen;
+
+ CFStringGetBytes ( input, CFRangeMake ( 0, MIN ( CFStringGetLength ( input ), 255 ) ),
+ kCFStringEncodingMacRoman, '^', false, &( output [ 1 ] ), 255, &usedBufLen );
+
+ output [ 0 ] = usedBufLen;
+
+ if ( output [ 0 ] == 0 )
+ return ( false );
+
+ return ( true );
+
+ } // CFStringRefToStr255
- *flfolder = false;
- copystring (fsname (fs), fn);
+ boolean HFSUniStr255ToStr255 ( ConstHFSUniStr255Param input, StringPtr output ) {
+
+ //
+ // 2006-07-06 creedon; created
+ //
- /*if ends with \ get ride of it... and handle the root*/
+ CFStringRef csr;
+
+ csr = CFStringCreateWithCharacters ( kCFAllocatorDefault, input -> unicode, input -> length );
+
+ CFStringRefToStr255 ( csr, output );
- cleanendoffilename (fn);
+ CFRelease ( csr );
+
+ return ( true );
- nullterminate (fn);
+ } // HFSUniStr255ToStr255
+
+
+ boolean FSRefGetNameStr255 ( const FSRef *fsRef, Str255 bsname ) {
+
+ //
+ // 2006-07-06 creedon; created
+ //
+
+ CFStringRef csr;
+ OSErr err = FSRefGetName ( fsRef, &csr );
+
+ if ( err != noErr )
+ return ( false );
+
+ if ( csr == NULL )
+ return ( false );
+
+ if ( ! CFStringGetPascalString ( csr, bsname, 256, kCFStringEncodingMacRoman ) )
+ return ( false );
+
+ CFRelease ( csr );
+
+ return ( true );
+
+ } // FSRefGetNameStr255
+
+
+ boolean bigstringToHFSUniStr255 ( const bigstring bs, HFSUniStr255 *output ) {
+
+ //
+ // 2006-07-06 creedon; created
+ //
+
+ CFStringRef csr = CFStringCreateWithPascalString ( kCFAllocatorDefault, bs, kCFStringEncodingMacRoman );
+
+ ( *output ).length = CFStringGetLength ( csr );
+
+ CFStringGetCharacters ( csr, CFRangeMake ( 0, ( *output ).length ), ( *output ).unicode );
+
+ CFRelease ( csr );
+
+ return ( true );
+
+ } // bigstringToHFSUniStr255
- if (stringlength(fn) == 2) {
- if (isalpha(fn[1]) && fn[2] == ':') {
- *flfolder = true;
- return (fileisvolume(fs));
- }
- }
- ff = FindFirstFile (stringbaseaddress(fn), &ffd);
+ boolean CFStringRefToHFSUniStr255 ( CFStringRef input, HFSUniStr255 *output ) {
+
+ //
+ // 2006-08-11 creedon: created, cribbed from < http://developer.apple.com/carbon/tipsandtricks.html#CFStringFromUnicode >
+ //
+
+ ( *output ).length = CFStringGetBytes ( input, CFRangeMake ( 0, MIN ( CFStringGetLength ( input ), 255 ) ),
+ kCFStringEncodingUnicode, 0, false, ( UInt8 * ) ( *output ).unicode, 255, NULL );
- if (ff == INVALID_HANDLE_VALUE)
- return (false);
+ if ( ( *output ).length == 0 )
+ return ( false );
+
+ return ( true );
+
+ } // CFStringRefToHFSUniStr255
- *flfolder = ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY?true:false;
- FindClose (ff);
- return (true);
-#endif
- } /*fileexists*/
+/* 2006-08-11 creedon: cribbed from MoreFilesX.c and modded to work with Str255 */
+/* macro for casting away const when you really have to */
+#define CONST_CAST(type, const_var) (*(type*)((void *)&(const_var)))
-boolean filegetfilename (const tyfilespec *pfs, bigstring name) {
-
-#ifdef MACVERSION
- /*
- filespecs for volumes have their strings set to the empty string.
- */
+OSErr
+HFSNameGetUnicodeName255 (
+ ConstStr255Param hfsName,
+ TextEncoding textEncodingHint,
+ HFSUniStr255 *unicodeName)
+{
+ ByteCount unicodeByteLength;
+ OSStatus result;
+ UnicodeMapping uMapping;
+ TextToUnicodeInfo tuInfo;
+ ByteCount pascalCharsRead;
- copystring (fsname (pfs), name);
+ /* check parameters */
+ require_action(NULL != unicodeName, BadParameter, result = paramErr);
- if (stringlength (name) > 0)
- return (true);
+ /* make sure output is valid in case we get errors or there's nothing to convert */
+ unicodeName->length = 0;
+
+ if ( 0 == StrLength(CONST_CAST(StringPtr, hfsName)) )
+ {
+ result = noErr;
+ }
+ else
+ {
+ /* if textEncodingHint is kTextEncodingUnknown, get a "default" textEncodingHint */
+ if ( kTextEncodingUnknown == textEncodingHint )
+ {
+ ScriptCode script;
+ RegionCode region;
+
+ script = GetScriptManagerVariable(smSysScript);
+ region = GetScriptManagerVariable(smRegionCode);
+ result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, region,
+ NULL, &textEncodingHint);
+ if ( paramErr == result )
+ {
+ /* ok, ignore the region and try again */
+ result = UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare,
+ kTextRegionDontCare, NULL, &textEncodingHint);
+ }
+ if ( noErr != result )
+ {
+ /* ok... try something */
+ textEncodingHint = kTextEncodingMacRoman;
+ }
+ }
- return (filegetvolumename ((*pfs).vRefNum, name));
-#endif
+ uMapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault,
+ kUnicodeCanonicalDecompVariant, kUnicode16BitFormat);
+ uMapping.otherEncoding = GetTextEncodingBase(textEncodingHint);
+ uMapping.mappingVersion = kUnicodeUseHFSPlusMapping;
+
+ result = CreateTextToUnicodeInfo(&uMapping, &tuInfo);
+ require_noerr(result, CreateTextToUnicodeInfo);
+
+ result = ConvertFromTextToUnicode(tuInfo, hfsName[0], &hfsName[1],
+ 0, /* no control flag bits */
+ 0, NULL, 0, NULL, /* offsetCounts & offsetArrays */
+ sizeof(unicodeName->unicode), /* output buffer size in bytes */
+ &pascalCharsRead, &unicodeByteLength, unicodeName->unicode);
+ require_noerr(result, ConvertFromTextToUnicode);
+
+ /* convert from byte count to char count */
+ unicodeName->length = unicodeByteLength / sizeof(UniChar);
-#ifdef WIN95VERSION
- lastword ((ptrstring) fsname (pfs), '\\', name);
+ConvertFromTextToUnicode:
- return (true);
-#endif
- } /*filegetfilename*/
+ /* verify the result in debug builds -- there's really not anything you can do if it fails */
+ verify_noerr(DisposeTextToUnicodeInfo(&tuInfo));
+ }
+
+CreateTextToUnicodeInfo:
+BadParameter:
+ return ( result );
+}
+
+ #endif
+
Modified: Frontier/branches/Conversant/Common/source/filealias.c
===================================================================
--- Frontier/branches/Conversant/Common/source/filealias.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/filealias.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -61,7 +61,6 @@
#include "error.h"
#include "resources.h"
#include "file.h"
-#include "filesystem7.h"
typedef struct {
Modified: Frontier/branches/Conversant/Common/source/filedialog.c
===================================================================
--- Frontier/branches/Conversant/Common/source/filedialog.c 2009-05-23 17:17:25 UTC (rev 1792)
+++ Frontier/branches/Conversant/Common/source/filedialog.c 2009-05-23 20:21:44 UTC (rev 1793)
@@ -29,7 +29,10 @@
#include "standard.h"
#ifdef MACVERSION
-# include "mac.h"
+
+ # include "mac.h"
+ # include "MoreFilesX.h"
+
#endif
#include "filealias.h"
@@ -53,1188 +56,1170 @@
#ifdef MACVERSION
-#include "SetUpA5.h"
+ #include "SetUpA5.h"
-#define sfgetfileid 5000
-#define sfputfileid 5001
-#define sfgetfolderid 5002
-#define sfgetdiskid 5003
+ #define sfgetfileid 5000
+ #define sfputfileid 5001
+ #define sfgetfolderid 5002
+ #define sfgetdiskid 5003
-#define sfgetfolderbutton 11
-#define sfgetpromptitem 10
+ #define sfgetfolderbutton 11
+ #define sfgetpromptitem 10
-typedef struct tysfdata { /*data passed to hook routines*/
-
- StandardFileReply sfreply;
-
- bigstring sfprompt;
-
- Str63 sfname;
-
- ptrsftypelist sftypes;
- } tysfdata, *ptrsfdata;
+ typedef struct tysfdata { /*data passed to hook routines*/
+
+ StandardFileReply sfreply;
+
+ bigstring sfprompt;
+
+ Str63 sfname;
+
+ ptrsftypelist sftypes;
+ } tysfdata, *ptrsfdata;
-#if !TARGET_API_MAC_CARBON
+ #if ! TARGET_API_MAC_CARBON
-static pascal short sfputfilehook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 6/11/93 dmb: added for System 7 Standard File
- */
-#ifdef flcomponent
- long curA5;
-#endif
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
-#ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
-#endif
-
- if (item == sfHookFirstCall) {
-
- if ((*pdata).sfreply.sfFile.vRefNum != 0)
- item = sfHookChangeSelection;
- }
-
-#ifdef flcomponent
-
- RestoreA5 (curA5);
-
-#endif
-
- return (item);
- } /*sfputfilehook*/
+ static pascal short sfputfilehook (short item, DialogPtr pdialog, tysfdata *pdata) {
+
+ /*
+ 6/11/93 dmb: added for System 7 Standard File
+ */
+
+ #ifdef flcomponent
+ long curA5;
+ #endif
+ if (GetWRefCon (pdialog) != sfMainDialogRefCon)
+ return (item);
+
+ #ifdef flcomponent
+
+ curA5 = SetUpAppA5 ();
+
+ #endif
+
+ if (item == sfHookFirstCall) {
+
+ if ((*pdata).sfreply.sfFile.vRefNum != 0)
+ item = sfHookChangeSelection;
+ }
+
+ #ifdef flcomponent
+
+ RestoreA5 (curA5);
+
+ #endif
+
+ return (item);
+ } /*sfputfilehook*/
-static pascal short sfprompthook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 6/11/93 dmb: recoded to System 7 Standard File
- */
-#ifdef flcomponent
- long curA5;
-#endif
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
-#ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
-#endif
-
- if (item == sfHookFirstCall) {
- Rect ritem, rdialog;
- CGrafPtr dialogPort;
- dialoggetobjectrect (pdialog, sfgetpromptitem, &ritem);
-
- //Code change by Timothy Paustian Sunday, April 30, 2000 9:20:45 PM
- //Changed to Opaque call for Carbon
-#if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
- dialogPort = GetDialogPort(pdialog);
- GetPortBounds(dialogPort, &rdialog);
-#else
- //old code
-#pragma unused(dialogPort)
- rdialog = (*pdialog).portRect;
-#endif
- if (isemptystring ((*pdata).sfprompt)) {
+ static pascal short sfprompthook (short item, DialogPtr pdialog, tysfdata *pdata) {
- rdialog.bottom = ritem.top;
-
/*
- hidedialogitem (pdialog, sfgetpromptitem);
+ 6/11/93 dmb: recoded to System 7 Standard File
*/
- }
- else {
- rdialog.bottom = ritem.bottom + 4;
+ #ifdef flcomponent
+ long curA5;
+ #endif
+
+ if (GetWRefCon (pdialog) != sfMainDialogRefCon)
+ return (item);
- setdialogtext (pdialog, sfgetpromptitem, (*pdata).sfprompt);
- }
-
- sizewindow (pdialog, rdialog.right - rdialog.left, rdialog.bottom - rdialog.top);
-
- if ((*pdata).sfreply.sfFile.vRefNum != 0)
- item = sfHookChangeSelection;
- }
-
-#ifdef flcomponent
-
- RestoreA5 (curA5);
-
-#endif
-
- return (item);
- } /*sfprompthook*/
+ #ifdef flcomponent
+
+ curA5 = SetUpAppA5 ();
+
+ #endif
+
+ if (item == sfHookFirstCall) {
+ Rect ritem, rdialog;
+ CGrafPtr dialogPort;
+ dialoggetobjectrect (pdialog, sfgetpromptitem, &ritem);
+
+ //Code change by Timothy Paustian Sunday, April 30, 2000 9:20:45 PM
+ //Changed to Opaque call for Carbon
+
+ #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
+ dialogPort = GetDialogPort(pdialog);
+ GetPortBounds(dialogPort, &rdialog);
+ #else
+ //old code
+ #pragma unused(dialogPort)
+ rdialog = (*pdialog).portRect;
+ #endif
+
+ if (isemptystring ((*pdata).sfprompt)) {
+
+ rdialog.bottom = ritem.top;
+
+ /*
+ hidedialogitem (pdialog, sfgetpromptitem);
+ */
+ }
+ else {
+
+ rdialog.bottom = ritem.bottom + 4;
+
+ setdialogtext (pdialog, sfgetpromptitem, (*pdata).sfprompt);
+ }
+
+ sizewindow (pdialog, rdialog.right - rdialog.left, rdialog.bottom - rdialog.top);
+
+ if ((*pdata).sfreply.sfFile.vRefNum != 0)
+ item = sfHookChangeSelection;
+ }
+
+ #ifdef flcomponent
+
+ RestoreA5 (curA5);
+
+ #endif
+
+ return (item);
+ } /*sfprompthook*/
-static pascal short sffolderhook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 12/5/91 dmb: if a folder is selected, use it instead of the current folder
-
- 1/30/92 dmb: added code to handle folder aliases, which are files
-
- 9/15/92 dmb: save path in sfstring (255 chars) instead of reply.fName (63 chars)
-
- 6/11/93 dmb: recoded to System 7 Standard File
-
- 2.1b9 dmb: push dialog port when ellipsizing button title
- */
-
- bigstring bs;
-#ifdef flcomponent
- long curA5;
-#endif
-
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
-#ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
-#endif
-
- item = sfprompthook (item, pdialog, pdata);
-
- switch (item) {
-
- case sfgetfolderbutton: {
-
- if ((*pdata).sfreply.sfFlags & kIsAlias) { /*must be the alias of a folder*/
- Boolean flfolder, flwasalias;
- OSErr errcode;
+ static pascal short sffolderhook (short item, DialogPtr pdialog, tysfdata *pdata) {
+
+ /*
+ 12/5/91 dmb: if a folder is selected, use it instead of the current folder
+
+ 1/30/92 dmb: added code to handle folder aliases, which are files
+
+ 9/15/92 dmb: save path in sfstring (255 chars) instead of reply.fName (63 chars)
+
+ 6/11/93 dmb: recoded to System 7 Standard File
+
+ 2.1b9 dmb: push dialog port when ellipsizing button title
+ */
+
+ bigstring bs;
+
+ #ifdef flcomponent
+ long curA5;
+ #endif
+
+ if (GetWRefCon (pdialog) != sfMainDialogRefCon)
+ return (item);
+
+ #ifdef flcomponent
- errcode = ResolveAliasFile (&(*pdata).sfreply.sfFile, true, &flfolder, &flwasalias);
+ curA5 = SetUpAppA5 ();
- switch (errcode) {
+ #endif
+
+ item = sfprompthook (item, pdialog, pdata);
+
+ switch (item) {
+
+ case sfgetfolderbutton: {
+
+ if ((*pdata).sfreply.sfFlags & kIsAlias) { /*must be the alias of a folder*/
+ Boolean flfolder, flwasalias;
+ OSErr errcode;
+
+ errcode = ResolveAliasFile (&(*pdata).sfreply.sfFile, true, &flfolder, &flwasalias);
+
+ switch (errcode) {
+
+ case noErr:
+ break;
+
+ case userCanceledErr:
+ item = sfHookNullEvent;
+
+ goto exit;
+
+ default:
+ getsystemerrorstring (errcode, bs);
+
+ parsedialogstring (bs, (*pdata).sfreply.sfFile.name, nil, nil, nil, bs);
+
+ customalert (sferrordialogid, bs);
+
+ item = sfHookNullEvent;
+
+ goto exit;
+ }
+ }
- case noErr:
- break;
+ (*pdata).sfreply.sfGood = true;
- case userCanceledErr:
- item = sfHookNullEvent;
-
- goto exit;
+ item = sfItemCancelButton; /*force exit*/
- default:
- getsystemerrorstring (errcode, bs);
+ break;
+ };
+
+ case sfHookNullEvent:
+ if (!equalstrings ((*pdata).sfname, (*pdata).sfreply.sfFile.name)) { /*selection changed*/
+ FSSpec fs;
- parsedialogstring (bs, (*pdata).sfreply.sfFile.name, nil, nil, nil, bs);
+ fs = (*pdata).sfreply.sfFile;
- customalert (sferrordialogid, bs);
+ copystring (fs.name, (*pdata).sfname); /*remember for next time before changing*/
- item = sfHookNullEvent;
+ if (isemptystring (fs.name)) /*nothing selected*/
+ FSMakeFSSpec (fs.vRefNum, fs.parID, nil, &fs);
- goto exit;
- }
+ copystring (fs.name, bs);
+ //Code change by Timothy Paustian Monday, August 21, 2000 4:20:21 PM
+ //pushport must have a CGrafPtr on OS X
+ {
+ CGrafPtr thePort;
+ #if TARGET_API_MAC_CARBON == 1
+ thePort = GetDialogPort(pdialog);
+ #else
+ thePort = (CGrafPtr)pdialog;
+ #endif
+
+ pushport (thePort);
+ }
+ ellipsize (bs, 72);
+
+ popport ();
+
+ setdialogbutton (pdialog, sfgetfolderbutton, bs);
+ }
+
+ break;
}
- (*pdata).sfreply.sfGood = true;
+ exit:
- item = sfItemCancelButton; /*force exit*/
+ #ifdef flcomponent
- break;
- };
-
- case sfHookNullEvent:
- if (!equalstrings ((*pdata).sfname, (*pdata).sfreply.sfFile.name)) { /*selection changed*/
- FSSpec fs;
+ RestoreA5 (curA5);
+
+ #endif
+
+ return (item);
+ } /*sffolderhook*/
+
+
+ static pascal short sfdiskhook (short item, DialogPtr pdialog, tysfdata *pdata) {
+
+ /*
+ 6/11/93 dmb: recoded to System 7 Standard File; back to using Drive
+ button like Frontier 1.0.
+ */
+
+ #ifdef flcomponent
+ long curA5;
+ #endif
+
+ if (GetWRefCon (pdialog) != sfMainDialogRefCon)
+ return (item);
+
+ #ifdef flcomponent
- fs = (*pdata).sfreply.sfFile;
+ curA5 = SetUpAppA5 ();
- copystring (fs.name, (*pdata).sfname); /*remember for next time before changing*/
+ #endif
+
+ item = sfprompthook (item, pdialog, pdata);
+
+ switch (item) {
- if (isemptystring (fs.name)) /*nothing selected*/
- FSMakeFSSpec (fs.vRefNum, fs.parID, nil, &fs);
+ case sfItemOpenButton:
+ case sfHookOpenFolder:
+ #if 0
+
+ (*pdata).sfreply.vRefNum = -SFSaveDisk; /*IM IV-72*/
+
+ setemptystring ((*pdata).sfreply.fName); /*we just want the volume*/
+
+ #endif
+
+ FSMakeFSSpec ((*pdata).sfreply.sfFile.vRefNum, 0, 0, &(*pdata).sfreply.sfFile);
+
+ (*pdata).sfreply.sfGood = true;
+
+ item = sfItemCancelButton; /*force exit*/
+
+ break;
- copystring (fs.name, bs);
- //Code change by Timothy Paustian Monday, August 21, 2000 4:20:21 PM
- //pushport must have a CGrafPtr on OS X
- {
- CGrafPtr thePort;
- #if TARGET_API_MAC_CARBON == 1
- thePort = GetDialogPort(pdialog);
- #else
- thePort = (CGrafPtr)pdialog;
- #endif
-
- pushport (thePort);
- }
- ellipsize (bs, 72);
+ case sfHookGoToDesktop:
+ item = sfHookGoToNextDrive;
+
+ break;
- popport ();
+ case sfHookNullEvent:
+ if ((*pdata).sfreply.sfIsVolume) /*need to open volume to enable Drive button*/
+ item = sfHookOpenFolder;
+ else {
+ if (isemptystring ((*pdata).sfreply.sfFile.name)) /*no selection*/
+ item = sfHookGoToParent;
+ }
+
+ break;
- setdialogbutton (pdialog, sfgetfolderbutton, bs);
+ case sfHookGoToParent:
+ item = sfHookNullEvent;
+
+ break;
+
+ default:
+ if (item >= sfHookCharOffset) /*typing -- ignore*/
+ item = sfHookNullEvent;
}
- break;
- }
-
- exit:
-
- #ifdef flcomponent
-
- RestoreA5 (curA5);
-
- #endif
-
- return (item);
- } /*sffolderhook*/
+ #ifdef flcomponent
+
+ RestoreA5 (curA5);
+
+ #endif
+
+ return (item);
+ } /*sfdiskhook*/
-static pascal short sfdiskhook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 6/11/93 dmb: recoded to System 7 Standard File; back to using Drive
- button like Frontier 1.0.
- */
-#ifdef flcomponent
- long curA5;
-#endif
-
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
-#ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
-#endif
-
- item = sfprompthook (item, pdialog, pdata);
-
- switch (item) {
-
- case sfItemOpenButton:
- case sfHookOpenFolder:
- #if 0
+ static pascal Boolean onlyfoldersfilter (ParmBlkPtr pb, tysfdata *pdata) {
+ #pragma unused (pdata)
- (*pdata).sfreply.vRefNum = -SFSaveDisk; /*IM IV-72*/
+ /*
+ if (foldertest (pb))
+ */
- setemptystring ((*pdata).sfreply.fName); /*we just want the volume*/
+ if (pb->fileParam.ioFlAttrib & ioDirMask)
+ return (0);
- #endif
+ return (-1); /*...don't show files*/
+ } /*onlyfoldersfilter*/
+
+
+ static pascal Boolean knowntypesfilter (ParmBlkPtr pb, tysfdata *pdata) {
- FSMakeFSSpec ((*pdata).sfreply.sfFile.vRefNum, 0, 0, &(*pdata).sfreply.sfFile);
+ short i;
- (*pdata).sfreply.sfGood = true;
+ if (pb->fileParam.ioFlAttrib & ioDirMask)
+ return (0);
- item = sfItemCancelButton; /*force exit*/
+ if (pdata->sftypes == nil) // show all files
+ return (0);
- break;
-
- case sfHookGoToDesktop:
- item = sfHookGoToNextDrive;
-
- break;
-
- case sfHookNullEvent:
- if ((*pdata).sfreply.sfIsVolume) /*need to open volume to enable Drive button*/
- item = sfHookOpenFolder;
- else {
- if (isemptystring ((*pdata).sfreply.sfFile.name)) /*no selection*/
- item = sfHookGoToParent;
+ for (i = 0; i < pdata->sftypes->cttypes; ++i) {
+
+ OSType type = pdata->sftypes->types [i];
+ byte bstype [6];
+ bigstring bssuffix;
+
+ ostypetostring (type, bstype);
+
+ lastword (pb->fileParam.ioNamePtr, '.', bssuffix);
+
+ if (stringlength (bssuffix) == 3) //handle 8.3 names
+ setstringlength (bstype, 3);
+
+ if (equalidentifiers (bssuffix, bstype))
+ return (0);
+
+ if (pb->fileParam.ioFlFndrInfo.fdType == type)
+ return (0);
}
- break;
-
- case sfHookGoToParent:
- item = sfHookNullEvent;
+ return (-1); // didn't find it in our list
+ } /*knowntypesfilter*/
+
+
+ #if !TARGET_RT_MAC_CFM
- break;
-
- default:
- if (item >= sfHookCharOffset) /*typing -- ignore*/
- item = sfHookNullEvent;
- }
-
-#ifdef flcomponent
-
- RestoreA5 (curA5);
-
-#endif
-
- return (item);
- } /*sfdiskhook*/
+ #define onlyfoldersfilterUPP ((FileFilterYDUPP) &onlyfoldersfilter)
+ #define knowntypesfilterUPP ((FileFilterYDUPP) &knowntypesfilter)
+ #define sfputfilehookUPP (&sfputfilehook)
+ #define sfprompthookUPP (&sfprompthook)
+ #define sffolderhookUPP (&sffolderhook)
+ #define sfdiskhookUPP (&sfdiskhook)
+ #else
-static pascal Boolean onlyfoldersfilter (ParmBlkPtr pb, tysfdata *pdata) {
-#pragma unused (pdata)
-
- /*
- if (foldertest (pb))
- */
-
- if (pb->fileParam.ioFlAttrib & ioDirMask)
- return (0);
-
- return (-1); /*...don't show files*/
- } /*onlyfoldersfilter*/
+ #if !TARGET_API_MAC_CARBON
+ static RoutineDescriptor onlyfoldersfilterDesc = BUILD_ROUTINE_DESCRIPTOR (uppFileFilterYDProcInfo, onlyfoldersfilter);
+ static RoutineDescriptor knowntypesfilterDesc = BUILD_ROUTINE_DESCRIPTOR (uppFileFilterYDProcInfo, knowntypesfilter);
+ static RoutineDescriptor sfputfilehookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sfputfilehook);
+ static RoutineDescriptor sfprompthookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sfprompthook);
+ static RoutineDescriptor sffolderhookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sffolderhook);
+ static RoutineDescriptor sfdiskhookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sfdiskhook);
+
+ #define onlyfoldersfilterUPP (&onlyfoldersfilterDesc)
+ #define knowntypesfilterUPP (&knowntypesfilterDesc)
+ #define sfputfilehookUPP (&sfputfilehookDesc)
+ #define sfprompthookUPP (&sfprompthookDesc)
+ #define sffolderhookUPP (&sffolderhookDesc)
+ #define sfdiskhookUPP (&sfdiskhookDesc)
+
+ #endif
-static pascal Boolean knowntypesfilter (ParmBlkPtr pb, tysfd...
[truncated message content] |