Something went wrong. Try again.
Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
6.2 kB · 244 lines
C
at android
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245/*This file is part of Darling.
Copyright (C) 2012-2013 Lubos Dolezel
Darling is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.
Darling is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.
You should have received a copy of the GNU General Public Licensealong with Darling. If not, see <http://www.gnu.org/licenses/>.*/
#ifndef FILEMANAGER_H#define FILEMANAGER_H#include <stdint.h>#include <dirent.h>#include "MacErrors.h"#include "DateTimeUtils.h"#include "MacTypes.h"#include <CoreFoundation/CFURL.h>
#ifdef __cplusplusextern "C" {#endif
#define FSRef_MAX_DEPTH (80 / sizeof(ino_t))
struct FSRef{ union { uint8_t hidden[80];
// Inode numbers leading to the file in the directory structure // // EXAMPLES: // All zeroes: / // sequence 1,2,0: [dir with inode 1]/[dir or file with inode 2] ino_t inodes[FSRef_MAX_DEPTH]; };};typedef struct FSRef* FSRefPtr;
struct HFSUniStr255{ uint16_t length; uint16_t unicode[255];};struct FSSpec;
typedef struct FSSpec* FSSpecPtr;
struct FSPermissionInfo{ uint32_t userID, groupID; // uid, gid uint8_t reserved1; uint8_t userAccess; // mode for the current user uint16_t mode; // mode uint32_t reserved2;};
struct FSCatalogInfo{ uint16_t nodeFlags; int16_t volume; uint32_t parentDirID; uint32_t nodeID; uint8_t sharingFlags; uint8_t userPrivileges; uint8_t reserved1; uint8_t reserved2; struct UTCDateTime createDate; struct UTCDateTime contentModDate; struct UTCDateTime attributeModDate; struct UTCDateTime accessDate; struct UTCDateTime backupDate;
union { uint32_t permissions[4]; struct FSPermissionInfo fsPermissionInfo; };
uint8_t finderInfo[16]; uint8_t extFinderInfo[16]; uint64_t dataLogicalSize; uint64_t dataPhysicalSize; uint64_t rsrcLogicalSize; uint64_t rsrcPhysicalSize; uint32_t valence; // file count within a directory uint32_t textEncodingHint;};
typedef void* IOCompletionUPP;typedef void* QElemPtr;typedef uint16_t FSAllocationFlags;typedef uint32_t FSCatalogInfoBitmap;typedef unsigned long UniCharCount;typedef uint32_t TextEncoding;
struct FSRefParam{ QElemPtr qLink; short qType; short ioTrap; Ptr ioCmdAddr; IOCompletionUPP ioCompletion; volatile OSErr ioResult; const Str255* ioNamePtr; short ioVRefNum; SInt16 reserved1; UInt8 reserved2; UInt8 reserved3; const FSRefPtr ref; FSCatalogInfoBitmap whichInfo; struct FSCatalogInfo* catInfo; UniCharCount nameLength; const UniChar* name; long ioDirID; FSSpecPtr spec; FSRefPtr parentRef; FSRefPtr newRef; TextEncoding textEncodingHint; struct HFSUniStr255* outName;};
struct CatPositionRec{ long initialize; short priv[6];};
struct FSForkIOParam{ QElemPtr qLink; short qType; short ioTrap; Ptr ioCmdAddr; IOCompletionUPP ioCompletion; volatile OSErr ioResult; void * reserved1; SInt16 reserved2; SInt16 forkRefNum; UInt8 reserved3; SInt8 permissions; const FSRefPtr ref; Ptr buffer; UInt32 requestCount; UInt32 actualCount; UInt16 positionMode; SInt64 positionOffset; FSAllocationFlags allocationFlags; UInt64 allocationAmount; UniCharCount forkNameLength; const UniChar * forkName; struct CatPositionRec forkIterator; struct HFSUniStr255* outForkName;};
enum{ kFSPathMakeRefDefaultOptions = 0, kFSPathMakeRefDoNotFollowLeafSymlink = 1};
enum{ kFSCatInfoNone = 0x0, kFSCatInfoTextEncoding = 0x1, kFSCatInfoNodeFlags = 0x2, kFSCatInfoVolume = 0x4, kFSCatInfoParentDirID = 0x8, kFSCatInfoNodeID = 0x10, kFSCatInfoCreateDate = 0x20, kFSCatInfoContentMod = 0x40, kFSCatInfoAttrMod = 0x80, kFSCatInfoAccessDate = 0x100, kFSCatInfoBackupDate = 0x200, kFSCatInfoPermissions = 0x400, kFSCatInfoFinderInfo = 0x800, kFSCatInfoFinderXInfo = 0x1000, kFSCatInfoValence = 0x2000, kFSCatInfoDataSizes = 0x4000, kFSCatInfoRsrcSizes = 0x8000, kFSCatInfoSharingFlags = 0x10000, kFSCatInfoUserPrivs = 0x20000, kFSCatInfoUserAccess = 0x80000, kFSCatInfoSetOwnership = 0x100000};
enum{ kSystemFolderType = 'macs', kDesktopFolderType = 'desk', kSystemDesktopFolderType = 'sdsk', kTrashFolderType = 'trsh', kSystemTrashFolderType = 'strs', kWhereToEmptyTrashFolderType = 'empt', kPrintMonitorDocsFolderType = 'prnt', kStartupFolderType = 'strt', kShutdownFolderType = 'shdf', kAppleMenuFolderType = 'amnu', kControlPanelFolderType = 'ctrl', kSystemControlPanelFolderType = 'sctl', kExtensionFolderType = 'extn', kFontsFolderType = 'font', kPreferencesFolderType = 'pref', kSystemPreferencesFolderType = 'sprf', kTemporaryFolderType = 'temp'};
OSStatus FSPathMakeRef(const uint8_t* path, struct FSRef* fsref, Boolean* isDirectory);OSStatus FSPathMakeRefWithOptions(const uint8_t* path, long options, struct FSRef* fsref, Boolean* isDirectory);OSStatus FSRefMakePath(const struct FSRef* fsref, uint8_t* path, uint32_t maxSize);Boolean CFURLGetFSRef(CFURLRef urlref, struct FSRef* fsref); // in CFCFURLRef CFURLCreateFromFSRef(CFAllocatorRef alloc, struct FSRef* location); // --> in CFOSStatus FSFindFolder(long vRefNum, OSType folderType, Boolean createFolder, struct FSRef* location);
OSStatus FSGetCatalogInfo(const FSRefPtr ref, uint32_t infoBits, struct FSCatalogInfo* infoOut, struct HFSUniStr255* nameOut, FSSpecPtr fsspec, FSRefPtr parentDir);
OSErr PBCreateDirectoryUnicodeSync(struct FSRefParam* paramBlock);OSErr PBCreateFileUnicodeSync(struct FSRefParam* paramBlock);OSErr PBGetCatalogInfoSync(struct FSRefParam *paramBlock);OSErr PBMakeFSRefUnicodeSync(struct FSRefParam *paramBlock);OSErr PBOpenForkSync(struct FSForkIOParam *paramBlock);OSErr PBReadForkSync(struct FSForkIOParam *paramBlock);OSErr PBWriteForkSync(struct FSForkIOParam *paramBlock);OSErr PBIterateForksSync(struct FSForkIOParam *paramBlock);OSErr PBCloseForkSync(struct FSForkIOParam *paramBlock);
#ifdef __cplusplus}#endif
#endif