| top | |
static int pathcommand(ClientData clientData,Intr intr,int N,Tcl_Obj *const P[]) {
Tcl_Obj *wyrmPathcommand(int hfs,Tcl_Obj *path);
bool hfs;
switch (N) {
case 2:
hfs = true;
break;
case 3:
switch (Tcl_GetString(P[1])[0]) {
case 'h': hfs = true; break;
case 'p': hfs = false; break;
default: goto usage;
}
break;
default: usage:
Tcl_WrongNumArgs(intr,1,P,"[hfs|posix] path");
return TCL_ERROR;
}
Tcl_SetObjResult(intr,wyrmPathcommand(hfs,P[N-1]));
return TCL_OK;
}
| ^ | | | | | | section top | |
Tcl_Obj *wyrmPathcommand(int hfs,Tcl_Obj *tclpath) {
CFStringRef path = cfobj(tclpath);
CFURLRef url = CFURLCreateWithFileSystemPath(NULL,path,
hfs?kCFURLPOSIXPathStyle:kCFURLHFSPathStyle,0);
CFStringRef altpath = CFURLCopyFileSystemPath(url,
hfs?kCFURLHFSPathStyle:kCFURLPOSIXPathStyle);
Tcl_Obj *r = objcf(altpath);
CFRelease(path);
CFRelease(url);
CFRelease(altpath);
return r;
}
| ^ | | | | | | section top | |
Tcl_CreateObjCommand(intr,"::wyrm::macosx::path",pathcommand,0,0);
| ^ | | | | | | section top | | | ^ | | | | | | section top | |
static int aliascommand(ClientData clientData,Intr intr,int N,Tcl_Obj *const P[]) {
Tcl_Obj *wyrmAliascommand(Tcl_Obj *path);
switch (N) {
case 2: {
/*
Adapted and taken from Apple Cocoa File Manager documentation.
*/
Tcl_SetObjResult(intr,wyrmAliascommand(P[1]));
return TCL_OK;
}
case 3: {
Obj E[3];
E[0] = Tcl_NewStringObj("::wyrm::wif::macosx-alias",-1);
E[1] = P[1];
E[2] = P[2];
Obj cmd = incr(Tcl_NewListObj(3,E));
int rc = Tcl_EvalObjEx(intr,cmd,0);
decr(cmd);
return rc;
}
default:
Tcl_WrongNumArgs(intr,1,P,"aliasfile [originalfile]");
return TCL_ERROR;
}
}
static int isaliascommand(ClientData clientData,Intr intr,int N,Tcl_Obj *const P[]) {
int wyrmIsaliascommand(Tcl_Obj *path);
switch (N) {
case 2: {
bool aliassed = false;
Tcl_SetObjResult(intr,Tcl_NewBooleanObj(wyrmIsaliascommand(P[1])));
return TCL_OK;
}
default:
Tcl_WrongNumArgs(intr,1,P,"file");
return TCL_ERROR;
}
}
| ^ | | | | | | section top | |
Tcl_Obj *wyrmAliascommand(Tcl_Obj *tclpath) {
CFStringRef path = cfobj(tclpath);
CFStringRef resolvedPath = 0;
CFURLRef url = CFURLCreateWithFileSystemPath(NULL,path,kCFURLPOSIXPathStyle,0);
if (url) {
FSRef fsRef;
if (CFURLGetFSRef(url,&fsRef)) {
Boolean targetIsFolder,wasAliased;
if (!FSResolveAliasFile(&fsRef,true,&targetIsFolder,&wasAliased) && wasAliased) {
CFURLRef resolvedUrl = CFURLCreateFromFSRef(NULL, &fsRef);
if (resolvedUrl) {
resolvedPath = CFURLCopyFileSystemPath(resolvedUrl,kCFURLPOSIXPathStyle);
CFRelease(resolvedUrl);
}
}
}
CFRelease(url);
}
Tcl_Obj *r = objcf(resolvedPath?resolvedPath:path);
if (resolvedPath) CFRelease(resolvedPath);
CFRelease(path);
return r;
}
int wyrmIsaliascommand(Tcl_Obj *tclpath) {
CFStringRef path = cfobj(tclpath); int aliassed = 0;
CFURLRef url = CFURLCreateWithFileSystemPath(NULL,path,kCFURLPOSIXPathStyle,0);
if (url) {
FSRef fsRef;
if (CFURLGetFSRef(url,&fsRef)) {
Boolean isAlias,isFolder;
aliassed = FSIsAliasFile(&fsRef,&isAlias,&isFolder)==noErr && isAlias;
}
CFRelease(url);
}
CFRelease(path);
return aliassed;
}
| ^ | Definition continued at: 14, 19, 23, 27. | | | | | section top | |
Tcl_CreateObjCommand(intr,"::wyrm::macosx::alias",aliascommand,0,0);
Tcl_CreateObjCommand(intr,"::wyrm::macosx::isalias",isaliascommand,0,0);
| ^ | Definition continued at: 15, 18, 24, 28. | | | | | section top | |
proc ::wyrm::wif::macosx-alias {alias original} {
set alias [file normalize $alias]
set original [file normalize $original]
file delete -force $alias
if {[file isdirectory $original]} {
set original "folder \"[wyrm::macosx::path hfs $original]\""
} else {
set original "file \"[wyrm::macosx::path hfs $original]\""
}
set container "\"[wyrm::macosx::path hfs [file dir $alias]]\""
set name "\"[file tail $alias]\""
set script "
tell application \"Finder\"
set _X to $original
set _Y to $container
set _Z to make alias at _Y to _X
set name of _Z to $name
end tell
"
exec osascript << $script
}
| ^ | Definition continued at: 20, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65. | | | | | section top | | | ^ | | | | | | section top | |
Tcl_Obj *wyrmFoldercommand(int domainindex,int folderindex,long *dom,long *fol);
static char *domainstring[] = {"user","local","network","system","classic",0};
static int foldercommand(ClientData clientData,Intr intr,int N,Tcl_Obj *const P[]) {
int domainindex;
int folderindex;
static char *folderstring[] = {
"frameworks",
"os9","desktop","systemdesktop","trash",
"systemtrash","emptytrash","printmonitor",
"startup","shutdown","applemenu","controlpanel",
"systemcontrolpanel","extensions","fonts",
"preferences","systempreferences","temporary",
"extdisabled","controldisabled",
"sysextdisabled","startupdisabled",
"shutdowndisabled","applications","documents",
"root","chewable","applicationsupport",
"textencodings","stationery","opendoc",
"opendocshellplugin","editors","opendoceditors",
"opendoclibraries","geneditors","help",
"internetplugins","modemscripts","printerdescriptions",
"printerdriver","scriptingadditions","sharedlibraries",
"voices","controlstrip","assistants",
"utilities","appleextras","contextualmenus",
"readme","colorsyncprofiles","themes",
"favorites","internet","appearance",
"soundsets","desktoppictures","internetsearch","findsupport",
"findbycontent","installerlogs","scripts",
"folderactions","launcheritems","recentapplications",
"recentdocuments","recentservers","speakableitems",
"keychain","quicktimeextensions","displayextensions",
"multiprocessing","printingplugins","coloursyncprofiles",
"favourites",
"toplevel","library","colorsync","coloursync",
"colorsynccmm","colorsyncscripting","printers",
"speech","carbonlibrary","documentation",
"developerdocs","developerhelp","issdownloads",
"userspecifictmp","cacheddata",
"privateframeworks","classicdesktop",
"developer","systemsounds","components",
"quicktimecomponents","coreservices","pictures",
"movies","music","internetsites",
"public","audiosupport","audiosounds",
"audiosoundbanks","audioalertsounds","audioplugins",
"audiocomponents","kernelextensions","directoryservices",
"directoryservicesplugins","installerreceipts","filesystemsupport",
"applesharesupport","appleshareauthentication","mididrivers",
"keyboardlayouts","indexfiles","findbycontentindexes",
"manageditems","boottimestartupitems",
0
};
Obj L,f; long dom,fol;
switch (N) {
case 2:
if (Tcl_GetIndexFromObj(intr,P[1],(CONST char**)folderstring,"folder",0,&folderindex)==TCL_ERROR)
return TCL_ERROR;
L = incr(Tcl_NewObj());
for (domainindex=0; domainstring[domainindex]!=0; domainindex++) {
f = wyrmFoldercommand(domainindex,folderindex,&dom,&fol);
if (f) {
Tcl_ListObjAppendElement(0,L,f);
}
}
Tcl_SetObjResult(intr,L);
return TCL_OK;
case 3:
if (Tcl_GetIndexFromObj(intr,P[1],(CONST char**)domainstring,"domain",0,&domainindex)==TCL_ERROR)
return TCL_ERROR;
if (Tcl_GetIndexFromObj(intr,P[2],(CONST char**)folderstring,"folder",0,&folderindex)==TCL_ERROR)
return TCL_ERROR;
f = wyrmFoldercommand(domainindex,folderindex,&dom,&fol);
if (f) {
Tcl_SetObjResult(intr,f);
return TCL_OK;
}else {
return rprintf(intr,"%!no such folder",TCL_ERROR);
}
default: usage:
Tcl_WrongNumArgs(intr,1,P,"[domain] folder");
return TCL_ERROR;
}
return TCL_OK;
}
| ^ | | | | | | section top | |
Tcl_Obj *wyrmFoldercommand(int domainindex,int folderindex,long *dom,long *fol) {
static long domainnumber [] = {kUserDomain,kLocalDomain,kNetworkDomain,kSystemDomain,kClassicDomain};
static long foldernumber[] = {
kFrameworksFolderType,
kSystemFolderType,kDesktopFolderType,kSystemDesktopFolderType,kTrashFolderType,
kSystemTrashFolderType,kWhereToEmptyTrashFolderType,kPrintMonitorDocsFolderType,
kStartupFolderType,kShutdownFolderType,kAppleMenuFolderType,kControlPanelFolderType,
kSystemControlPanelFolderType,kExtensionFolderType,kFontsFolderType,
kPreferencesFolderType,kSystemPreferencesFolderType,kTemporaryFolderType,
kExtensionDisabledFolderType,kControlPanelDisabledFolderType,
kSystemExtensionDisabledFolderType,kStartupItemsDisabledFolderType,
kShutdownItemsDisabledFolderType,kApplicationsFolderType,kDocumentsFolderType,
kVolumeRootFolderType,kChewableItemsFolderType,kApplicationSupportFolderType,
kTextEncodingsFolderType,kStationeryFolderType,kOpenDocFolderType,
kOpenDocShellPlugInsFolderType,kEditorsFolderType,kOpenDocEditorsFolderType,
kOpenDocLibrariesFolderType,kGenEditorsFolderType,kHelpFolderType,
kInternetPlugInFolderType,kModemScriptsFolderType,kPrinterDescriptionFolderType,
kPrinterDriverFolderType,kScriptingAdditionsFolderType,kSharedLibrariesFolderType,
kVoicesFolderType,kControlStripModulesFolderType,kAssistantsFolderType,
kUtilitiesFolderType,kAppleExtrasFolderType,kContextualMenuItemsFolderType,
kMacOSReadMesFolderType,kColorSyncProfilesFolderType,kThemesFolderType,
kFavoritesFolderType,kInternetFolderType,kAppearanceFolderType,
kSoundSetsFolderType,kDesktopPicturesFolderType,kInternetSearchSitesFolderType,kFindSupportFolderType,
kFindByContentFolderType,kInstallerLogsFolderType,kScriptsFolderType,
kFolderActionsFolderType,kLauncherItemsFolderType,kRecentApplicationsFolderType,
kRecentDocumentsFolderType,kRecentServersFolderType,kSpeakableItemsFolderType,
kKeychainFolderType,kQuickTimeExtensionsFolderType,kDisplayExtensionsFolderType,
kMultiprocessingFolderType,kPrintingPlugInsFolderType,kColorSyncProfilesFolderType,
kFavoritesFolderType,
kDomainTopLevelFolderType,kDomainLibraryFolderType,kColorSyncFolderType,kColorSyncFolderType,
kColorSyncCMMFolderType,kColorSyncScriptingFolderType,kPrintersFolderType,
kSpeechFolderType,kCarbonLibraryFolderType,kDocumentationFolderType,
kDeveloperDocsFolderType,kDeveloperHelpFolderType,kISSDownloadsFolderType,
kUserSpecificTmpFolderType,kCachedDataFolderType,
kPrivateFrameworksFolderType,kClassicDesktopFolderType,
kDeveloperFolderType,kSystemSoundsFolderType,kComponentsFolderType,
kQuickTimeComponentsFolderType,kCoreServicesFolderType,kPictureDocumentsFolderType,
kMovieDocumentsFolderType,kMusicDocumentsFolderType,kInternetSitesFolderType,
kPublicFolderType,kAudioSupportFolderType,kAudioSoundsFolderType,
kAudioSoundBanksFolderType,kAudioAlertSoundsFolderType,kAudioPlugInsFolderType,
kAudioComponentsFolderType,kKernelExtensionsFolderType,kDirectoryServicesFolderType,
kDirectoryServicesPlugInsFolderType,kInstallerReceiptsFolderType,kFileSystemSupportFolderType,
kAppleShareSupportFolderType,kAppleShareAuthenticationFolderType,kMIDIDriversFolderType,
kKeyboardLayoutsFolderType,kIndexFilesFolderType,kFindByContentIndexesFolderType,
kManagedItemsFolderType,kBootTimeStartupItemsFolderType,
};
FSRef fr; CFURLRef url; CFStringRef path = 0; Tcl_Obj *r = 0;
if (dom) *dom = domainnumber[domainindex];
if (fol) *fol = foldernumber[folderindex];
if (FSFindFolder(domainnumber[domainindex],foldernumber[folderindex],FALSE,&fr))
return 0;
url = CFURLCreateFromFSRef(NULL,&fr);
if (url) {
path = CFURLCopyFileSystemPath(url,kCFURLPOSIXPathStyle);
CFRelease(url);
if (path) {
r = objcf(path);
CFRelease(path);
}
}
return r;
}
| ^ | Definition continued at: 19, 23, 27. | | | | | section top | |
Tcl_CreateObjCommand(intr,"::wyrm::macosx::folder",foldercommand,0,0);
| ^ | Definition continued at: 18, 24, 28. | | | | | section top | | | ^ | Definition continued at: 21, 25, 29, 66. | |
| |