• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

AFP, NTFS and SFM

porter

Well-known member
I'm updating my binhex and unbinhex tools to work on windows with Services For Macintosh AFP shares.

Resource forks are held as a stream called "AFP_Resource" and the various other information including the finder info is in "AFP_AfpInfo".

Doing the binhex is not problem because when I read the AFP_AfpInfo my safe guess is the type and creator are at offsets 16 and 20.

But to do the unbinxhex all I know is

(a) it has to be 60 bytes long

( B) it starts with "AFP"

© it has the type and creator at offsets 16 and 20

Other than that I don't know anything else about the contents of AFP_AfpInfo, can any one else shed any light?

 

Charlieman

Well-known member
I'm puzzled, mate -- are you talking about a Windows binhex tool, because AppleShare client/server should handle it for you on a Mac. Are you trying to work with binhex files between NTFS and FAT in Windows?

 

porter

Well-known member
I have a windows 2000 box with an SFM AFP share.

I wanted to do the unbinhex on the windows 2000 box, eg with no macs involved. Eg it's "unbinhex.exe".

So I have access to the NTFS share, and can read and write the AFP_Resource and AFP_AfpInfo but I can't get the AFP_ApfInfo contents correct. The macs complain about the resources even though the resource stream itself is correct.

 

porter

Well-known member
Okay this seems to solve it....

Code for Windows to create a file with Macintosh Type and Creator....

Code:
OSErr FSpCreate(FSSpec *f,long c,long t,long s)
{
char name[256];
char info[256];
BYTE data[60];
HANDLE h;
DWORD dw=60;
DWORD err=0;

memcpy(name,f->name+1,f->name[0]);
name[f->name[0]]=0;

h=CreateFile(name,GENERIC_WRITE,0,NULL,
		CREATE_NEW,0,INVALID_HANDLE_VALUE);

if (h==INVALID_HANDLE_VALUE) return GetLastError();

CloseHandle(h);

strcpy(info,name);
strcat(info,":AFP_AfpInfo");

h=CreateFile(info,GENERIC_WRITE,0,NULL,
		CREATE_ALWAYS,0,INVALID_HANDLE_VALUE);

if (h==INVALID_HANDLE_VALUE) 
{
	dw=GetLastError();

	DeleteFile(name);

	return dw;
}

memset(data,0,sizeof(data));
memcpy(data,"AFP",3);
memcpy(data+0x10,&t,4);
memcpy(data+0x14,&c,4);

data[6]=1;
data[7]=0;
data[0xF]=0x80;
data[0x18]=1;

if (!WriteFile(h,data,sizeof(data),&dw,NULL))
{
	err=GetLastError();
}

CloseHandle(h);

if (err)
{
	DeleteFile(name);
}

return err;
}
 
Top