this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CoreService: Move FSRef APIs to the new file_handle stuff, add Resources header defs

+293 -410
+4
src/frameworks/CoreServices/ComponentManager.cpp
··· 19 19 20 20 #include "ComponentManager.h" 21 21 #include <CoreServices/MacErrors.h> 22 + #include <CoreServices/Resources.h> 23 + 24 + // Some clues about how this work can be found here: 25 + // https://vintageapple.org/develop/pdf/develop-12_9212_December_1992.pdf 22 26 23 27 ComponentManager* ComponentManager::instance() 24 28 {
+2
src/frameworks/CoreServices/ComponentManager.h
··· 67 67 ComponentDescription cd; 68 68 ComponentRoutineUPP entryPoint; 69 69 std::string name, info; 70 + 71 + std::string bundlePath; 70 72 71 73 uint32_t instances; 72 74 };
+23
src/frameworks/CoreServices/Components.cpp
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 1 20 #include "Components.h" 2 21 #include <CoreServices/MacErrors.h> 3 22 #include "ComponentManager.h" ··· 73 92 ComponentManager::instance()->setStorage(aComponentInstance, theStorage); 74 93 } 75 94 95 + OSErr OpenAComponentResFile(Component aComponent, ResFileRefNum* resRef) 96 + { 97 + return kResFileNotOpened; 98 + }
+28 -145
src/frameworks/CoreServices/FileManager.cpp
··· 1 1 /* 2 2 This file is part of Darling. 3 3 4 - Copyright (C) 2012-2013 Lubos Dolezel 4 + Copyright (C) 2012-2020 Lubos Dolezel 5 5 6 6 Darling is free software: you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by ··· 17 17 along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 19 20 - #include "FileManager.h" 20 + #include <CoreServices/FileManager.h> 21 21 #include <cstdlib> 22 22 #include <string> 23 23 #include <cstring> ··· 38 38 #include <vector> 39 39 #include "DateTimeUtils.h" 40 40 #include <errno.h> 41 + #include <ext/file_handle.h> 41 42 42 43 #define STUB() // TODO 43 44 44 - // Doesn't resolve the last symlink 45 - // Mallocates a new buffer 46 - static char* realpath_ns(const char* path); 47 - /*static*/ bool FSRefMakePath(const FSRef* ref, std::string& out); 48 - static bool FSRefParamMakePath(const FSRefParam* param, std::string& out); 49 45 // Is the current user member of the specified group? 50 46 static bool hasgid(gid_t gid); 51 47 52 - static bool string_endsWith(const std::string& str, const std::string& what) 53 - { 54 - if (str.size() < what.size()) 55 - return false; 56 - else 57 - return str.compare(str.size()-what.size(), what.size(), what) == 0; 58 - } 59 - 60 - static std::vector<std::string> string_explode(const std::string& str, char delim, bool keepEmpty) 61 - { 62 - std::vector<std::string> rv; 63 - size_t start = 0, end; 64 - 65 - do 66 - { 67 - std::string substr; 68 - 69 - end = str.find(delim, start); 70 - substr = str.substr(start, (end != std::string::npos) ? end-start : std::string::npos); 71 - 72 - if (keepEmpty || !substr.empty()) 73 - rv.push_back(substr); 74 - 75 - start = end+1; 76 - } 77 - while (end != std::string::npos); 78 - 79 - return rv; 80 - } 81 - 82 48 OSStatus FSPathMakeRef(const uint8_t* path, FSRef* fsref, Boolean* isDirectory) 83 49 { 84 50 return FSPathMakeRefWithOptions(path, kFSPathMakeRefDoNotFollowLeafSymlink, fsref, isDirectory); ··· 89 55 if (!path || !fsref) 90 56 return paramErr; 91 57 92 - std::string fullPath; 93 - char* rpath; 94 - 58 + int flags = 1; 95 59 if (options & kFSPathMakeRefDoNotFollowLeafSymlink) 96 - rpath = realpath_ns(reinterpret_cast<const char*>(path)); 97 - else 98 - rpath = realpath(reinterpret_cast<const char*>(path), nullptr); 60 + flags = 0; 99 61 100 - if (!rpath) 62 + int err = sys_name_to_handle((const char*) path, (RefData*) fsref, flags); 63 + if (err != 0) 101 64 return fnfErr; 102 - if (std::count(rpath, rpath+strlen(rpath), '/') > FSRef_MAX_DEPTH) 103 - { 104 - free(rpath); 105 - return unimpErr; 106 - } 107 65 108 - fullPath = rpath; 109 - free(rpath); 110 - 111 - memset(fsref, 0, sizeof(*fsref)); 112 - 113 - if (fullPath == "/") 66 + if (isDirectory) 114 67 { 115 - if (isDirectory) 116 - *isDirectory = true; 117 - return noErr; 118 - } 68 + struct stat st; 119 69 120 - std::vector<std::string> components = string_explode(fullPath, '/', false); 121 - std::string position = "/"; 122 - size_t pos; 70 + if (options & kFSPathMakeRefDoNotFollowLeafSymlink) 71 + err = lstat((const char*) path, &st); 72 + else 73 + err = stat((const char*) path, &st); 123 74 124 - for (size_t pos = 0; pos < components.size(); pos++) 125 - { 126 - bool found = false; 127 - struct dirent* ent; 128 - 129 - DIR* dir = opendir(position.c_str()); 130 - if (!dir) 131 - return makeOSStatus(errno); 132 - 133 - while ((ent = readdir(dir))) 134 - { 135 - if (components[pos] == ent->d_name) 136 - { 137 - found = true; 138 - fsref->inodes[pos] = ent->d_ino; 139 - 140 - if (pos+1 == components.size() && isDirectory != nullptr) 141 - *isDirectory = ent->d_type == DT_DIR; 142 - break; 143 - } 144 - } 145 - 146 - closedir(dir); 147 - 148 - if (!found) 149 - return fnfErr; 150 - 151 - if (!string_endsWith(position, "/")) 152 - position += '/'; 153 - position += components[pos]; 154 - 155 - pos++; 75 + if (err == 0) 76 + *isDirectory = S_ISDIR(st.st_mode); 77 + else 78 + *isDirectory = 0; 156 79 } 157 80 158 81 return noErr; 159 82 } 160 83 161 - char* realpath_ns(const char* path) 162 - { 163 - char *dup1, *dup2; 164 - char *dname, *bname; 165 - char *real, *complete; 166 - 167 - dup1 = strdup(path); 168 - dup2 = strdup(path); 169 - dname = dirname(dup1); 170 - bname = basename(dup2); 171 - 172 - real = realpath(dname, nullptr); 173 - complete = (char*) malloc(strlen(real) + strlen(bname) + 2); 174 - 175 - strcpy(complete, real); 176 - if (strrchr(complete, '/') != complete+strlen(complete)-1) 177 - strcat(complete, "/"); 178 - strcat(complete, bname); 179 - 180 - free(real); 181 - free(dup1); 182 - free(dup2); 183 - 184 - return complete; 185 - } 186 - 187 84 bool FSRefMakePath(const FSRef* fsref, std::string& out) 188 85 { 189 - out = '/'; 190 - for (int i = 0; i < FSRef_MAX_DEPTH && fsref->inodes[i] != 0; i++) 191 - { 192 - ino_t inode = fsref->inodes[i]; 193 - DIR* dir = opendir(out.c_str()); 194 - struct dirent* ent; 195 - bool found = false; 86 + char name[4096]; 87 + int ret = sys_handle_to_name((RefData*) fsref, name); 88 + if (ret != 0) 89 + return false; 196 90 197 - while ((ent = readdir(dir))) 198 - { 199 - if (strcmp(ent->d_name, "..") == 0 || strcmp(ent->d_name, ".") == 0) 200 - continue; 201 - if (ent->d_ino == inode) 202 - { 203 - found = true; 204 - if (!string_endsWith(out, "/")) 205 - out += '/'; 206 - out += ent->d_name; 207 - } 208 - } 209 - 210 - closedir(dir); 211 - 212 - if (!found) 213 - return false; 214 - } 91 + out = name; 215 92 return true; 216 93 } 217 94 ··· 279 156 280 157 if (parentDir) 281 158 { 159 + /* 282 160 memcpy(parentDir, ref, sizeof(FSRef)); 283 161 ino_t* last = std::find(parentDir->inodes, parentDir->inodes+FSRef_MAX_DEPTH, 0); 284 162 285 163 if (last != parentDir->inodes) 286 164 *(last-1) = 0; 165 + */ 166 + // TODO 287 167 } 288 168 289 169 if (infoOut && infoBits != kFSCatInfoNone) ··· 303 183 304 184 if (infoBits & (kFSCatInfoParentDirID|kFSCatInfoNodeID)) 305 185 { 186 + /* 306 187 if (infoBits & kFSCatInfoNodeID) 307 188 infoOut->nodeID = ref->inodes[0]; 308 189 for (int i = FSRef_MAX_DEPTH-1; i > 0; i--) ··· 315 196 if (infoBits & kFSCatInfoNodeID) 316 197 infoOut->nodeID = ref->inodes[i]; 317 198 } 199 + */ 200 + // TODO 318 201 } 319 202 320 203 if (infoBits & kFSCatInfoDataSizes)
-245
src/frameworks/CoreServices/FileManager.h
··· 1 - /* 2 - This file is part of Darling. 3 - 4 - Copyright (C) 2012-2013 Lubos Dolezel 5 - 6 - Darling is free software: you can redistribute it and/or modify 7 - it under the terms of the GNU General Public License as published by 8 - the Free Software Foundation, either version 3 of the License, or 9 - (at your option) any later version. 10 - 11 - Darling is distributed in the hope that it will be useful, 12 - but WITHOUT ANY WARRANTY; without even the implied warranty of 13 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 - GNU General Public License for more details. 15 - 16 - You should have received a copy of the GNU General Public License 17 - along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 - */ 19 - 20 - 21 - #ifndef FILEMANAGER_H 22 - #define FILEMANAGER_H 23 - #include <stdint.h> 24 - #include <dirent.h> 25 - #include "MacErrors.h" 26 - #include "DateTimeUtils.h" 27 - #include "MacTypes.h" 28 - #include <CoreFoundation/CFURL.h> 29 - 30 - #ifdef __cplusplus 31 - extern "C" { 32 - #endif 33 - 34 - #define FSRef_MAX_DEPTH (80 / sizeof(ino_t)) 35 - 36 - typedef struct FSRef 37 - { 38 - union 39 - { 40 - uint8_t hidden[80]; 41 - 42 - // Inode numbers leading to the file in the directory structure 43 - // 44 - // EXAMPLES: 45 - // All zeroes: / 46 - // sequence 1,2,0: [dir with inode 1]/[dir or file with inode 2] 47 - ino_t inodes[FSRef_MAX_DEPTH]; 48 - }; 49 - } FSRef; 50 - typedef struct FSRef* FSRefPtr; 51 - typedef struct FSRef FSRef; 52 - 53 - struct HFSUniStr255 54 - { 55 - uint16_t length; 56 - uint16_t unicode[255]; 57 - }; 58 - struct FSSpec; 59 - 60 - typedef struct FSSpec* FSSpecPtr; 61 - 62 - struct FSPermissionInfo 63 - { 64 - uint32_t userID, groupID; // uid, gid 65 - uint8_t reserved1; 66 - uint8_t userAccess; // mode for the current user 67 - uint16_t mode; // mode 68 - uint32_t reserved2; 69 - }; 70 - 71 - struct FSCatalogInfo 72 - { 73 - uint16_t nodeFlags; 74 - int16_t volume; 75 - uint32_t parentDirID; 76 - uint32_t nodeID; 77 - uint8_t sharingFlags; 78 - uint8_t userPrivileges; 79 - uint8_t reserved1; 80 - uint8_t reserved2; 81 - struct UTCDateTime createDate; 82 - struct UTCDateTime contentModDate; 83 - struct UTCDateTime attributeModDate; 84 - struct UTCDateTime accessDate; 85 - struct UTCDateTime backupDate; 86 - 87 - union 88 - { 89 - uint32_t permissions[4]; 90 - struct FSPermissionInfo fsPermissionInfo; 91 - }; 92 - 93 - uint8_t finderInfo[16]; 94 - uint8_t extFinderInfo[16]; 95 - uint64_t dataLogicalSize; 96 - uint64_t dataPhysicalSize; 97 - uint64_t rsrcLogicalSize; 98 - uint64_t rsrcPhysicalSize; 99 - uint32_t valence; // file count within a directory 100 - uint32_t textEncodingHint; 101 - }; 102 - 103 - typedef void* IOCompletionUPP; 104 - typedef void* QElemPtr; 105 - typedef uint16_t FSAllocationFlags; 106 - typedef uint32_t FSCatalogInfoBitmap; 107 - typedef unsigned long UniCharCount; 108 - typedef UInt32 TextEncoding; 109 - 110 - struct FSRefParam 111 - { 112 - QElemPtr qLink; 113 - short qType; 114 - short ioTrap; 115 - Ptr ioCmdAddr; 116 - IOCompletionUPP ioCompletion; 117 - volatile OSErr ioResult; 118 - const Str255* ioNamePtr; 119 - short ioVRefNum; 120 - SInt16 reserved1; 121 - UInt8 reserved2; 122 - UInt8 reserved3; 123 - const FSRefPtr ref; 124 - FSCatalogInfoBitmap whichInfo; 125 - struct FSCatalogInfo* catInfo; 126 - UniCharCount nameLength; 127 - const UniChar* name; 128 - long ioDirID; 129 - FSSpecPtr spec; 130 - FSRefPtr parentRef; 131 - FSRefPtr newRef; 132 - TextEncoding textEncodingHint; 133 - struct HFSUniStr255* outName; 134 - }; 135 - 136 - struct CatPositionRec 137 - { 138 - long initialize; 139 - short priv[6]; 140 - }; 141 - 142 - struct FSForkIOParam 143 - { 144 - QElemPtr qLink; 145 - short qType; 146 - short ioTrap; 147 - Ptr ioCmdAddr; 148 - IOCompletionUPP ioCompletion; 149 - volatile OSErr ioResult; 150 - void * reserved1; 151 - SInt16 reserved2; 152 - SInt16 forkRefNum; 153 - UInt8 reserved3; 154 - SInt8 permissions; 155 - const FSRefPtr ref; 156 - Ptr buffer; 157 - UInt32 requestCount; 158 - UInt32 actualCount; 159 - UInt16 positionMode; 160 - SInt64 positionOffset; 161 - FSAllocationFlags allocationFlags; 162 - UInt64 allocationAmount; 163 - UniCharCount forkNameLength; 164 - const UniChar * forkName; 165 - struct CatPositionRec forkIterator; 166 - struct HFSUniStr255* outForkName; 167 - }; 168 - 169 - enum 170 - { 171 - kFSPathMakeRefDefaultOptions = 0, 172 - kFSPathMakeRefDoNotFollowLeafSymlink = 1 173 - }; 174 - 175 - enum 176 - { 177 - kFSCatInfoNone = 0x0, 178 - kFSCatInfoTextEncoding = 0x1, 179 - kFSCatInfoNodeFlags = 0x2, 180 - kFSCatInfoVolume = 0x4, 181 - kFSCatInfoParentDirID = 0x8, 182 - kFSCatInfoNodeID = 0x10, 183 - kFSCatInfoCreateDate = 0x20, 184 - kFSCatInfoContentMod = 0x40, 185 - kFSCatInfoAttrMod = 0x80, 186 - kFSCatInfoAccessDate = 0x100, 187 - kFSCatInfoBackupDate = 0x200, 188 - kFSCatInfoPermissions = 0x400, 189 - kFSCatInfoFinderInfo = 0x800, 190 - kFSCatInfoFinderXInfo = 0x1000, 191 - kFSCatInfoValence = 0x2000, 192 - kFSCatInfoDataSizes = 0x4000, 193 - kFSCatInfoRsrcSizes = 0x8000, 194 - kFSCatInfoSharingFlags = 0x10000, 195 - kFSCatInfoUserPrivs = 0x20000, 196 - kFSCatInfoUserAccess = 0x80000, 197 - kFSCatInfoSetOwnership = 0x100000 198 - }; 199 - 200 - enum 201 - { 202 - kSystemFolderType = 'macs', 203 - kDesktopFolderType = 'desk', 204 - kSystemDesktopFolderType = 'sdsk', 205 - kTrashFolderType = 'trsh', 206 - kSystemTrashFolderType = 'strs', 207 - kWhereToEmptyTrashFolderType = 'empt', 208 - kPrintMonitorDocsFolderType = 'prnt', 209 - kStartupFolderType = 'strt', 210 - kShutdownFolderType = 'shdf', 211 - kAppleMenuFolderType = 'amnu', 212 - kControlPanelFolderType = 'ctrl', 213 - kSystemControlPanelFolderType = 'sctl', 214 - kExtensionFolderType = 'extn', 215 - kFontsFolderType = 'font', 216 - kPreferencesFolderType = 'pref', 217 - kSystemPreferencesFolderType = 'sprf', 218 - kTemporaryFolderType = 'temp' 219 - }; 220 - 221 - OSStatus FSPathMakeRef(const uint8_t* path, struct FSRef* fsref, Boolean* isDirectory); 222 - OSStatus FSPathMakeRefWithOptions(const uint8_t* path, long options, struct FSRef* fsref, Boolean* isDirectory); 223 - OSStatus FSRefMakePath(const struct FSRef* fsref, uint8_t* path, uint32_t maxSize); 224 - Boolean CFURLGetFSRef(CFURLRef urlref, struct FSRef* fsref); // in CF 225 - CFURLRef CFURLCreateFromFSRef(CFAllocatorRef alloc, struct FSRef* location); // --> in CF 226 - OSStatus FSFindFolder(long vRefNum, OSType folderType, Boolean createFolder, struct FSRef* location); 227 - 228 - OSStatus FSGetCatalogInfo(const FSRefPtr ref, uint32_t infoBits, struct FSCatalogInfo* infoOut, struct HFSUniStr255* nameOut, FSSpecPtr fsspec, FSRefPtr parentDir); 229 - 230 - OSErr PBCreateDirectoryUnicodeSync(struct FSRefParam* paramBlock); 231 - OSErr PBCreateFileUnicodeSync(struct FSRefParam* paramBlock); 232 - OSErr PBGetCatalogInfoSync(struct FSRefParam *paramBlock); 233 - OSErr PBMakeFSRefUnicodeSync(struct FSRefParam *paramBlock); 234 - OSErr PBOpenForkSync(struct FSForkIOParam *paramBlock); 235 - OSErr PBReadForkSync(struct FSForkIOParam *paramBlock); 236 - OSErr PBWriteForkSync(struct FSForkIOParam *paramBlock); 237 - OSErr PBIterateForksSync(struct FSForkIOParam *paramBlock); 238 - OSErr PBCloseForkSync(struct FSForkIOParam *paramBlock); 239 - 240 - #ifdef __cplusplus 241 - } 242 - #endif 243 - 244 - #endif 245 -
+23
src/frameworks/CoreServices/Resources.cpp
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 20 + #include <CoreServices/Resources.h> 21 + 22 + // Usage example: 23 + // https://github.com/nathanday/ndalias/blob/master/Classes/NDResourceFork.m
+55 -6
src/frameworks/CoreServices/include/CoreServices/Components.h
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 1 20 #ifndef COMPONENTS_H 2 21 #define COMPONENTS_H 3 22 #include <MacTypes.h> 23 + #include <CoreServices/Resources.h> 4 24 5 25 struct ComponentDescription; 6 26 typedef struct ComponentDescription ComponentDescription; ··· 62 82 defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType), 63 83 }; 64 84 85 + typedef struct ResourceSpec 86 + { 87 + OSType resType; 88 + SInt16 resID; 89 + } ResourceSpec; 90 + 91 + typedef struct ComponentPlatformInfo 92 + { 93 + SInt32 componentFlags; 94 + ResourceSpec component; 95 + SInt16 platformType; 96 + } ComponentPlatformInfo; 97 + 98 + struct ComponentDescription 99 + { 100 + OSType componentType, componentSubType, componentManufacturer; 101 + UInt32 componentFlags, componentFlagsMask; 102 + }; 103 + 104 + typedef struct ExtComponentResource 105 + { 106 + ComponentDescription cs; 107 + ResourceSpec component; 108 + ResourceSpec componentName; 109 + ResourceSpec componentInfo; 110 + ResourceSpec componentIcon; 111 + SInt32 componentVersion; 112 + SInt32 componentRegisterFlags; 113 + SInt16 componentIconFamily; 114 + SInt32 count; 115 + ComponentPlatformInfo platformArray[1]; 116 + } ExtComponentResource; 117 + 65 118 typedef ComponentResult (*ComponentRoutineProcPtr)(ComponentParameters* cp, Handle componentStorage); 66 119 typedef ComponentRoutineProcPtr ComponentRoutineUPP; 67 120 ··· 86 139 Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance); 87 140 void SetComponentInstanceStorage(ComponentInstance aComponentInstance, Handle theStorage); 88 141 142 + OSErr OpenAComponentResFile(Component aComponent, ResFileRefNum* resRef); 143 + 89 144 #ifdef __cplusplus 90 145 } 91 146 #endif 92 - 93 - struct ComponentDescription 94 - { 95 - OSType componentType, componentSubType, componentManufacturer; 96 - UInt32 componentFlags, componentFlagsMask; 97 - }; 98 147 99 148 enum 100 149 {
+4 -13
src/frameworks/CoreServices/include/CoreServices/FileManager.h
··· 33 33 34 34 #define FSRef_MAX_DEPTH (80 / sizeof(ino_t)) 35 35 36 - struct FSRef 36 + typedef struct FSRef 37 37 { 38 - union 39 - { 40 - uint8_t hidden[80]; 41 - 42 - // Inode numbers leading to the file in the directory structure 43 - // 44 - // EXAMPLES: 45 - // All zeroes: / 46 - // sequence 1,2,0: [dir with inode 1]/[dir or file with inode 2] 47 - ino_t inodes[FSRef_MAX_DEPTH]; 48 - }; 49 - }; 38 + uint8_t hidden[80]; 39 + } FSRef; 50 40 typedef struct FSRef* FSRefPtr; 51 41 typedef struct FSRef FSRef; 52 42 ··· 99 89 uint32_t valence; // file count within a directory 100 90 uint32_t textEncodingHint; 101 91 }; 92 + typedef struct FSCatalogInfo FSCatalogInfo; 102 93 103 94 typedef void* IOCompletionUPP; 104 95 typedef void* QElemPtr;
+31
src/frameworks/CoreServices/include/CoreServices/Files.h
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 20 + 21 + #ifndef _CS_FILES_H 22 + #define _CS_FILES_H 23 + #include <CoreServices/MacTypes.h> 24 + 25 + #if __LP64__ 26 + typedef int FSIORefNum; 27 + #else 28 + typedef SInt16 FSIORefNum; 29 + #endif 30 + 31 + #endif
+6
src/frameworks/CoreServices/include/CoreServices/MacMemory.h
··· 18 18 Ptr NewPtrClear(long len); 19 19 void DiposePtr(Ptr p); 20 20 void DisposeHandle(Handle handle); 21 + Size GetHandleSize(Handle h); 22 + void EmptyHandle(Handle h); 23 + OSErr PtrToHand(const void* srcPtr, Handle* dstHndl, long size); 24 + 25 + // free and new alloc 26 + void ReallocateHandle(Handle h, Size byteCount); 21 27 // and other crap with relocatable memory blocks etc. 22 28 23 29 #ifdef __cplusplus
+1 -1
src/frameworks/CoreServices/include/CoreServices/Processes.h
··· 1 1 #ifndef PROCESSES_H 2 2 #define PROCESSES_H 3 3 #include "MacTypes.h" 4 - #include "FileManager.h" 4 + #include <CoreServices/FileManager.h> 5 5 #include <CoreFoundation/CFString.h> 6 6 #include <CoreFoundation/CFDictionary.h> 7 7 #include <sys/types.h>
+116
src/frameworks/CoreServices/include/CoreServices/Resources.h
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + 20 + 21 + #ifndef _CS_RESOURCES_H 22 + #define _CS_RESOURCES_H 23 + #include <CoreServices/MacTypes.h> 24 + #include <CoreServices/Files.h> 25 + #include <CoreServices/FileManager.h> 26 + 27 + #ifdef __cplusplus 28 + extern "C" { 29 + #endif 30 + 31 + enum { 32 + kResFileNotOpened = -1, 33 + kSystemResFile = 0, 34 + }; 35 + 36 + typedef SInt16 ResID; 37 + typedef SInt16 ResAttributes; 38 + typedef SInt16 ResFileAttributes; 39 + typedef SInt16 ResourceCount; 40 + typedef SInt16 ResourceIndex; 41 + typedef FSIORefNum ResFileRefNum; 42 + 43 + void CloseResFile(ResFileRefNum refNum); 44 + OSErr ResError(void); 45 + ResFileRefNum CurResFile(void); 46 + ResFileRefNum HomeResFile(Handle resource); 47 + void UseResFile(ResFileRefNum ref); 48 + 49 + ResourceCount CountTypes(void); 50 + ResourceCount Count1Types(void); 51 + 52 + void GetIndType(ResType* type, ResourceIndex index); 53 + void Get1IndType(ResType* type, ResourceIndex index); 54 + 55 + void SetResLoad(Boolean load); 56 + 57 + ResourceCount CountResources(ResType type); 58 + ResourceCount Count1Resources(ResType type); 59 + 60 + Handle GetIndResource(ResType type, ResourceIndex index); 61 + Handle Get1IndResource(ResType type, ResourceIndex index); 62 + 63 + Handle GetResource(ResType type, ResID resId); 64 + Handle Get1Resource(ResType type, ResID resId); 65 + 66 + Handle GetNamedResource(ResType type, ConstStr255Param name); 67 + Handle Get1NamedResource(ResType type, ConstStr255Param name); 68 + 69 + void LoadResource(Handle res); 70 + void ReleaseResource(Handle res); 71 + void DetachResource(Handle res); 72 + 73 + ResID UniqueID(ResType type); 74 + ResID Unique1ID(ResType type); 75 + 76 + ResAttributes GetResAttrs(Handle res); 77 + void GetResInfo(Handle res, ResID* resId, ResType* type, Str255 name); 78 + void SetResInfo(Handle res, ResID theID, ConstStr255Param name); 79 + 80 + void AddResource(Handle data, ResType type, ResID resId, ConstStr255Param name); 81 + long GetResourceSizeOnDisk(Handle res); 82 + long GetMaxResourceSize(Handle res); 83 + 84 + void SetResAttrs(Handle res, ResAttributes attrs); 85 + void ChangedResource(Handle res); 86 + void RemoveResource(Handle res); 87 + void UpdateResFile(ResFileRefNum refNum); 88 + void WriteResource(Handle res); 89 + 90 + void SetResPurge(Boolean install); 91 + 92 + ResFileAttributes GetResFileAttrs(ResFileRefNum refNum); 93 + void SetResFileAttrs(ResFileRefNum refNum, ResFileAttributes attrs); 94 + 95 + void ReadPartialResource(Handle res, long offset, void* buffer, long count); 96 + void WritePartialResource(Handle res, long offset, const void* buffer, long count); 97 + 98 + void SetResourceSize(Handle res, long size); 99 + 100 + ResFileRefNum FSOpenResFile(const FSRef* ref, SInt8 permission); 101 + void FSCreateResFile(const FSRef* parentDir, UniCharCount nameLength, const UniChar* name, 102 + FSCatalogInfoBitmap whichInfo, const FSCatalogInfo* catalolgInfo, FSRef* newRef, FSSpecPtr* newSpec); 103 + OSErr FSCreateResourceFile(const FSRef* parentDir, UniCharCount nameLength, const UniChar* name, 104 + FSCatalogInfoBitmap whichInfo, const FSCatalogInfo* catalolgInfo, 105 + UniCharCount forkNameLength, const UniChar* forkName, 106 + FSRef* newRef, FSSpecPtr* newSpec); 107 + OSErr FSCreateResourceFork(const FSRef* ref, UniCharCount forkNameLength, const UniChar* forkName, UInt32 flags); 108 + OSErr FSOpenResourceFile(const FSRef* ref, UniCharCount forkNameLength, const UniChar* forkName, SInt8 permissions, ResFileRefNum* refNum); 109 + 110 + // TODO: More 32-bit only crap 111 + 112 + #ifdef __cplusplus 113 + } 114 + #endif 115 + 116 + #endif