Modify getprefsd() to take a Pascal string as 'name'

This commit is contained in:
Brendan Shanks 2017-08-18 00:09:02 -07:00
parent d59263d9df
commit 28dacfe5d5
3 changed files with 7 additions and 11 deletions

View File

@ -53,7 +53,7 @@
#include <sys/stat.h> #include <sys/stat.h>
extern void ssh2_init(); extern void ssh2_init();
extern char *getprefsd(char *name, char * buf, size_t size, short *vRefNum, long *parID); extern char *getprefsd(ConstStringPtr name, char * buf, size_t size, short *vRefNum, long *parID);
/*--------------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------------*/
@ -325,7 +325,7 @@ void DoTheGlobalInits(void)
{ {
long junk = 0; long junk = 0;
ParamBlockRec pb; ParamBlockRec pb;
char folderString[256]; Str255 folderString;
int err; int err;
char *buf; char *buf;
@ -371,10 +371,7 @@ void DoTheGlobalInits(void)
TelInfo->SysFolder.name[0]=0; TelInfo->SysFolder.name[0]=0;
/* NONO */ /* NONO */
GetIndString((unsigned char *)folderString,MISC_STRINGS,PREFS_FOLDER_NAME); GetIndString(folderString,MISC_STRINGS,PREFS_FOLDER_NAME);
junk = folderString[0];
BlockMoveData(folderString + 1, folderString, junk);
folderString[junk] = 0;
// WARNING: this initializes GUSI which in turn calls our event handler... // WARNING: this initializes GUSI which in turn calls our event handler...
buf = getprefsd(folderString, NULL, 0, &TelInfo->PrefFolder.vRefNum, &TelInfo->PrefFolder.parID); buf = getprefsd(folderString, NULL, 0, &TelInfo->PrefFolder.vRefNum, &TelInfo->PrefFolder.parID);
if ( !buf ) { if ( !buf ) {

View File

@ -60,7 +60,7 @@ extern "C" {
void ssh2_init(); void ssh2_init();
void ssh2_sched(); void ssh2_sched();
char *getprefsd(char *name, char *buf, size_t size, short *vRefNum, long *parID); char *getprefsd(ConstStringPtr name, char *buf, size_t size, short *vRefNum, long *parID);
int open(const char * path, int mode, ...); int open(const char * path, int mode, ...);
int dup(int s); int dup(int s);
@ -116,7 +116,7 @@ void ssh2_sched()
* getprefsd return the full path of prefs directory * getprefsd return the full path of prefs directory
*/ */
char *getprefsd(char *name, char *buf, size_t size, short *vRefNum, long *dirID) char *getprefsd(ConstStringPtr name, char *buf, size_t size, short *vRefNum, long *dirID)
{ {
OSErr err; OSErr err;
FSSpec fileSpec; FSSpec fileSpec;
@ -130,8 +130,7 @@ char *getprefsd(char *name, char *buf, size_t size, short *vRefNum, long *dirID)
if (err) { if (err) {
return NULL; return NULL;
} }
fileSpec.name[0] = strlen(name); PLstrcpy(fileSpec.name, name);
BlockMoveData(name, fileSpec.name + 1, fileSpec.name[0]);
err = ResolveAliasFile(&fileSpec, true, &isFolder, &wasAlias); err = ResolveAliasFile(&fileSpec, true, &isFolder, &wasAlias);
err = FSpGetDirectoryID(&fileSpec, dirID, &isDirectory); err = FSpGetDirectoryID(&fileSpec, dirID, &isDirectory);
if (err == fnfErr) { if (err == fnfErr) {

View File

@ -82,7 +82,7 @@ extern RSdata *RSlocal;
extern void ssh2_init(); extern void ssh2_init();
extern void ssh2_sched(); extern void ssh2_sched();
extern char *getprefsd(char *name, char *buf, size_t size, short *vRefNum, long *parID); extern char *getprefsd(ConstStringPtr name, char *buf, size_t size, short *vRefNum, long *parID);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/