home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
online
/
source
/
c
/
compilers
/
Tickle-4.0.sit.hqx
/
Tickle-4.0
/
src
/
Fullpath.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-18
|
6KB
|
287 lines
/*
** This source code was written by Tim Endres
** Email: time@ice.com.
** USMail: 8840 Main Street, Whitmore Lake, MI 48189
**
** Some portions of this application utilize sources
** that are copyrighted by ICE Engineering, Inc., and
** ICE Engineering retains all rights to those sources.
**
** Neither ICE Engineering, Inc., nor Tim Endres,
** warrants this source code for any reason, and neither
** party assumes any responsbility for the use of these
** sources, libraries, or applications. The user of these
** sources and binaries assumes all responsbilities for
** any resulting consequences.
*/
#include <types.h>
#include <files.h>
#ifndef TRUE
# define TRUE ((Boolean) 1)
# define FALSE ((Boolean) 0)
#endif
#define TSigWord 0x4244
unsigned char *prepstr( unsigned char *s1, unsigned char *s2 );
char *
fullname(name, vrefnum, filename)
unsigned char *name;
int vrefnum;
char *filename;
{
Str32 volname;
HVolumeParam pb;
strcpy(name, filename);
pb.ioVRefNum = vrefnum;
pb.ioNamePtr = volname; volname[0] = '\0';
pb.ioVolIndex = 0;
PBHGetVInfo((HParmBlkPtr)&pb, FALSE); /* Works with 64K ROMs as well. */
p2cstr(volname);
if (pb.ioVSigWord == 0x4244)
_prep_hfs_name(name, vrefnum);
else
prepstr(name, volname);
return (char *)name;
}
char *
pathname(pathname, vrefnum)
unsigned char *pathname;
int vrefnum;
{
Str32 volname;
HVolumeParam pb;
pathname[0] = '\0';
pb.ioVRefNum = vrefnum;
pb.ioNamePtr = volname; volname[0] = '\0';
pb.ioVolIndex = 0;
PBHGetVInfo((HParmBlkPtr)&pb, FALSE); /* Works with 64K ROMs as well. */
p2cstr(volname);
if (pb.ioVSigWord == 0x4244)
_prep_hfs_name(pathname, vrefnum);
else
prepstr(pathname, volname);
return (char *)pathname;
}
_prep_hfs_name(fullname, vrefnum)
unsigned char *fullname;
int vrefnum;
{
CInfoPBRec cpb;
WDPBRec wpb;
Str255 myname;
wpb.ioNamePtr = myname; myname[0] = '\0';
wpb.ioVRefNum = vrefnum;
wpb.ioWDIndex = 0;
wpb.ioWDProcID = (long) 0;
PBGetWDInfo(&wpb, FALSE);
cpb.dirInfo.ioVRefNum = vrefnum;
cpb.dirInfo.ioNamePtr = myname; myname[0] = '\0';
cpb.dirInfo.ioDrDirID = wpb.ioWDDirID;
cpb.dirInfo.ioFDirIndex = -1;
PBGetCatInfo(&cpb, FALSE);
p2cstr(myname);
prepstr(fullname, myname);
while (cpb.dirInfo.ioDrDirID != 2)
{
cpb.dirInfo.ioDrDirID = cpb.dirInfo.ioDrParID;
cpb.dirInfo.ioNamePtr = myname; myname[0] = '\0';
cpb.dirInfo.ioFDirIndex = -1;
PBGetCatInfo(&cpb, FALSE);
p2cstr(myname);
prepstr(fullname, myname);
}
}
char *
dirpathname(pathname, vrefnum, dirid)
unsigned char *pathname;
int vrefnum;
long dirid;
{
Str32 volname;
HVolumeParam pb;
pathname[0] = '\0';
pb.ioVRefNum = vrefnum;
pb.ioNamePtr = volname; volname[0] = '\0';
pb.ioVolIndex = 0;
PBHGetVInfo((HParmBlkPtr)&pb, FALSE);
p2cstr(volname);
if (pb.ioVSigWord == 0x4244)
_dir_prep_hfs_name(pathname, vrefnum, dirid);
else
prepstr(pathname, volname);
return (char *)pathname;
}
_dir_prep_hfs_name(fullname, vrefnum, dirid)
unsigned char *fullname;
int vrefnum;
long dirid;
{
CInfoPBRec cpb;
Str255 myname;
cpb.dirInfo.ioVRefNum = vrefnum;
cpb.dirInfo.ioNamePtr = myname; myname[0] = '\0';
cpb.dirInfo.ioDrDirID = dirid;
cpb.dirInfo.ioFDirIndex = -1;
PBGetCatInfo(&cpb, FALSE);
p2cstr(myname);
prepstr(fullname, myname);
while (cpb.dirInfo.ioDrDirID != 2) {
cpb.dirInfo.ioDrDirID = cpb.dirInfo.ioDrParID;
cpb.dirInfo.ioNamePtr = myname; myname[0] = '\0';
cpb.dirInfo.ioFDirIndex = -1;
PBGetCatInfo(&cpb, FALSE);
p2cstr(myname);
prepstr(fullname, myname);
}
}
unsigned char *
prepstr( unsigned char *s1, unsigned char *s2 )
{
unsigned char *ptr1, *ptr2;
unsigned char tempstr[256];
ptr1 = tempstr;
ptr2 = s2;
while (*ptr1++ = *ptr2++) ;
ptr1--; *ptr1++ = ':';
ptr2 = s1;
while (*ptr1++ = *ptr2++) ;
ptr1 = tempstr; ptr2 = s1;
while (*ptr2++ = *ptr1++) ;
return s1;
}
#ifdef STAND_ALONE_TOOL
#include <quickdraw.h>
#include <packages.h>
#include <stdio.h>
static char myfullname[1024];
main(argc, argv)
int argc;
char *argv[];
{
short vRefNum;
SFReply myreply;
Point mypoint;
char volname[32];
SFTypeList mytypes;
InitGraf(&qd.thePort);
InitCursor();
if ( argc > 1 )
{
if ( strcmp(argv[1], "-curdir") == 0 )
{
GetVol(volname, &vRefNum);
pathname(myfullname, vRefNum);
printf("PathName: '%s'\n", myfullname);
}
}
else
{
mypoint.h = mypoint.v = 75;
SFGetFile(mypoint, "", NULL, -1, mytypes, NULL, &myreply);
if (myreply.good)
{
myreply.fName[myreply.fName[0]+1] = '\0';
fullname(myfullname, myreply.vRefNum, &myreply.fName[1]);
printf("FullName: '%s'\n", myfullname);
pathname(myfullname, myreply.vRefNum);
printf("PathName: '%s'\n", myfullname);
}
}
}
#ifdef NEVER_DEFINED
cd {src}lib
C -mbg full -d STAND_ALONE_TOOL {active}
Link -t "MPST" -c "MPS " ∂
-o fullpath ∂
{active}.o ∂
{libraries}RunTime.o ∂
{libraries}Interface.o ∂
{Clibraries}StdCLib.o
fullpath -curdir
PathName: 'Fire:MPW:src:lib:'
FullName: 'Fire:MPW:src:lib:chdir.c'
PathName: 'Fire:MPW:src:lib:'
FullName: 'Blue:MPW:Sources:basic:src:bas1.c.o'
PathName: 'Blue:MPW:Sources:basic:src:'
#endif
#endif STAND_ALONE_TOOL
#ifdef NEVER_DEFINED
char *
dirpathname(pathname, vrefnum, dirid)
char *pathname;
int vrefnum;
long dirid;
{
char volname[32];
HVolumeParam pb;
CInfoPBRec cpb;
WDPBRec wpb;
Str255 myname[256];
pathname[0] = '\0';
wpb.ioNamePtr = myname; myname[0] = '\0';
wpb.ioVRefNum = vrefnum;
wpb.ioWDIndex = 0;
wpb.ioWDProcID = (long) 0;
PBGetWDInfo(&wpb, FALSE);
cpb.dirInfo.ioVRefNum = vrefnum;
cpb.dirInfo.ioNamePtr = myname; myname[0] = '\0';
cpb.dirInfo.ioDrDirID = dirid;
cpb.dirInfo.ioFDirIndex = -1;
PBGetCatInfo(&cpb, FALSE);
p2cstr(myname);
prepstr(pathname, myname);
while (cpb.dirInfo.ioDrDirID != 2) {
cpb.dirInfo.ioDrDirID = cpb.dirInfo.ioDrParID;
cpb.dirInfo.ioNamePtr = myname; myname[0] = '\0';
cpb.dirInfo.ioFDirIndex = -1;
PBGetCatInfo(&cpb, FALSE);
p2cstr(myname);
prepstr(pathname, myname);
}
}
#endif