def HomeResFile(res): """Return a path to the file in which resource 'res' lives.""" return GetFileLocation(res.HomeResFile()) def GetFileLocation(refNum): """Return a path to the open file identified with refNum.""" pb = ParamBlock(refNum) return pb.getPath() # # Internal cruft, adapted from MoreFiles # _InterfaceLib = calldll.getlibrary("InterfaceLib") GetVRefNum = calldll.newcall(_InterfaceLib.GetVRefNum, "None", "InShort", "OutShort") _getInfo = calldll.newcall(_InterfaceLib.PBGetFCBInfoSync, "Short", "InLong") _FCBPBFormat = """ qLink: l qType: h ioTrap: h ioCmdAddr: l ioCompletion: l ioResult: h ioNamePtr: l ioVRefNum: h ioRefNum: h filler: h ioFCBIndx: h
import calldll import macfs import sys import MacOS from Carbon import Res fss, ok = macfs.PromptGetFile("Show me calldll.ppc.slb") lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb') cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte', 'InByte', 'InByte', 'InByte', 'InByte', 'InByte', 'InByte') cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort', 'InShort', 'InShort', 'InShort', 'InShort', 'InShort', 'InShort') cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong', 'InLong', 'InLong', 'InLong', 'InLong', 'InLong', 'InLong') cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString') cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong') cdll_N_pp = calldll.newcall(lib.cdll_N_pp, 'None', 'InPstring', 'OutPstring') cdll_N_bb = calldll.newcall(lib.cdll_N_bb, 'None', 'InByte', 'OutByte') cdll_N_hh = calldll.newcall(lib.cdll_N_hh, 'None', 'InShort', 'OutShort') cdll_N_ll = calldll.newcall(lib.cdll_N_ll, 'None', 'InLong', 'OutLong') cdll_N_sH = calldll.newcall(lib.cdll_N_sH, 'None', 'InString', 'InHandle') print 'Test cdll_b_bbbbbbbb' rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: print 'ok.'
import calldll import macfs import sys import MacOS from Carbon import Res fss, ok = macfs.PromptGetFile("Show me calldll.ppc.slb") lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb') cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte', 'InByte', 'InByte','InByte', 'InByte','InByte', 'InByte') cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort', 'InShort', 'InShort','InShort', 'InShort','InShort', 'InShort') cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong', 'InLong', 'InLong','InLong', 'InLong','InLong', 'InLong') cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString') cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong') cdll_N_pp = calldll.newcall(lib.cdll_N_pp, 'None', 'InPstring', 'OutPstring') cdll_N_bb = calldll.newcall(lib.cdll_N_bb, 'None', 'InByte', 'OutByte') cdll_N_hh = calldll.newcall(lib.cdll_N_hh, 'None', 'InShort', 'OutShort') cdll_N_ll = calldll.newcall(lib.cdll_N_ll, 'None', 'InLong', 'OutLong') cdll_N_sH = calldll.newcall(lib.cdll_N_sH, 'None', 'InString', 'InHandle') print 'Test cdll_b_bbbbbbbb' rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8)
import calldll import macfs import sys import MacOS from Carbon import Res fss, ok = macfs.PromptGetFile("Show me calldll.ppc.slb") lib = calldll.getdiskfragment(fss, 'calldll.ppc.slb') cdll_b_bbbbbbbb = calldll.newcall(lib.cdll_b_bbbbbbbb, 'Byte', 'InByte', 'InByte', 'InByte', 'InByte','InByte', 'InByte','InByte', 'InByte') cdll_h_hhhhhhhh = calldll.newcall(lib.cdll_h_hhhhhhhh, 'Short', 'InShort', 'InShort', 'InShort', 'InShort','InShort', 'InShort','InShort', 'InShort') cdll_l_llllllll = calldll.newcall(lib.cdll_l_llllllll, 'Long', 'InLong', 'InLong', 'InLong', 'InLong','InLong', 'InLong','InLong', 'InLong') cdll_N_ssssssss = calldll.newcall(lib.cdll_N_ssssssss, 'None', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString', 'InString') cdll_o_l = calldll.newcall(lib.cdll_o_l, 'OSErr', 'InLong') cdll_N_pp = calldll.newcall(lib.cdll_N_pp, 'None', 'InPstring', 'OutPstring') cdll_N_bb = calldll.newcall(lib.cdll_N_bb, 'None', 'InByte', 'OutByte') cdll_N_hh = calldll.newcall(lib.cdll_N_hh, 'None', 'InShort', 'OutShort') cdll_N_ll = calldll.newcall(lib.cdll_N_ll, 'None', 'InLong', 'OutLong') cdll_N_sH = calldll.newcall(lib.cdll_N_sH, 'None', 'InString', 'InHandle') print 'Test cdll_b_bbbbbbbb' rv = cdll_b_bbbbbbbb(1, 2, 3, 4, 5, 6, 7, 8) if rv == 36: print 'ok.' else: print 'Failed, returned', rv
# # Test calldll. Tell the user how often menus flash, and let her change it. # import calldll import sys # Obtain a reference to the library with the toolbox calls interfacelib = calldll.getlibrary('InterfaceLib') # Get the routines we need (see LowMem.h for details) LMGetMenuFlash = calldll.newcall(interfacelib.LMGetMenuFlash, 'Short') LMSetMenuFlash = calldll.newcall(interfacelib.LMSetMenuFlash, 'None', 'InShort') print "Menus currently flash",LMGetMenuFlash(),"times." print "How often would you like them to flash?", # Note: we use input(), so you can try passing non-integer objects newflash = input() LMSetMenuFlash(newflash) print "Okay, menus now flash", LMGetMenuFlash(),"times." sys.exit(1) # So the window stays on-screen
# # Test calldll. Tell the user how often menus flash, and let her change it. # import calldll import sys # Obtain a reference to the library with the toolbox calls interfacelib = calldll.getlibrary('InterfaceLib') # Get the routines we need (see LowMem.h for details) LMGetMenuFlash = calldll.newcall(interfacelib.LMGetMenuFlash, 'Short') LMSetMenuFlash = calldll.newcall(interfacelib.LMSetMenuFlash, 'None', 'InShort') print "Menus currently flash", LMGetMenuFlash(), "times." print "How often would you like them to flash?", # Note: we use input(), so you can try passing non-integer objects newflash = input() LMSetMenuFlash(newflash) print "Okay, menus now flash", LMGetMenuFlash(), "times." sys.exit(1) # So the window stays on-screen