#ifndef _H_BUNDLEDISKREP
#define _H_BUNDLEDISKREP
#include "diskrep.h"
#include "machorep.h"
namespace Security {
namespace CodeSigning {
#define BUNDLEDISKREP_DIRECTORY "_CodeSignature"
#define STORE_RECEIPT_DIRECTORY "_MASReceipt"
class BundleDiskRep : public DiskRep {
public:
BundleDiskRep(const char *path, const Context *ctx = NULL);
BundleDiskRep(CFBundleRef ref, const Context *ctx = NULL);
CFDataRef component(CodeDirectory::SpecialSlot slot);
CFDataRef identification();
std::string mainExecutablePath();
CFURLRef canonicalPath();
std::string resourcesRootPath();
void adjustResources(ResourceBuilder &builder);
Universal *mainExecutableImage();
size_t signingBase();
size_t signingLimit();
std::string format();
CFArrayRef modifiedFiles();
UnixPlusPlus::FileDesc &fd();
void flush();
std::string recommendedIdentifier(const SigningContext &ctx);
CFDictionaryRef defaultResourceRules(const SigningContext &ctx);
const Requirements *defaultRequirements(const Architecture *arch, const SigningContext &ctx);
size_t pageSize(const SigningContext &ctx);
CFBundleRef bundle() const { return mBundle; }
public:
Writer *writer();
class Writer;
friend class Writer;
protected:
std::string metaPath(const char *name);
CFDataRef metaData(const char *name) { return cfLoadFile(CFTempURL(metaPath(name))); }
void createMeta();
private:
void setup(const Context *ctx); void checkModifiedFile(CFMutableArrayRef files, CodeDirectory::SpecialSlot slot);
private:
CFRef<CFBundleRef> mBundle;
std::string mMetaPath; bool mMetaExists; CFRef<CFURLRef> mMainExecutableURL; bool mInstallerPackage; string mFormat; RefPointer<DiskRep> mExecRep; };
class BundleDiskRep::Writer : public DiskRep::Writer {
friend class BundleDiskRep;
public:
Writer(BundleDiskRep *r);
void component(CodeDirectory::SpecialSlot slot, CFDataRef data);
void remove();
void flush();
protected:
DiskRep *execRep() { return rep->mExecRep; }
void remove(CodeDirectory::SpecialSlot slot);
protected:
RefPointer<BundleDiskRep> rep;
RefPointer<DiskRep::Writer> execWriter;
bool mMadeMetaDirectory;
};
} }
#endif // !_H_BUNDLEDISKREP