/****************************************************************************** * TMFSHook.cpp - description * ------------------- * begin : 2005/04/20 * copyright : (C) 2005 by Harald K. Strack * copyright : (C) 2005 by Trymedia Inc. * email : hstrack@trymedia.com ****************************************************************************** * changes name date comment * hks 2005/05/25 Mask support added. Revert fixed. */ /* TMFSHook: Trymedia FileSystem Hook * * This is an Adaptor (Wrapper) to hook P4's filesystem calls. * It only hooks (hopefully) calls for versioned files. Temporary files * are not hooked (see TMFSHook::CreateTemp()). * * It mainly does nothing, but if you need to add funcionality * to a filesytem call (like disabling Chmod(), ...) * you can do this in here or the header file. * This class is used by every TMClientUser and its subclasses. * * */ #include "TMFSHook.h" /* Create a "real (p4) FileSys * */ TMFSHook * TMFSHook::Create( FileSysType type ) { TMFSHook * tmp = new TMFSHook(); tmp->realFS = FileSys::Create (type); return tmp; } /* Do not use this directly */ TMFSHook::TMFSHook() : FileSys() { tmbo = NULL; attr = 0; tools = TMTools::Instance(); } TMFSHook::~TMFSHook() { delete this->realFS; } void TMFSHook::Open( FileOpenMode mode, Error *e ) { realFS->Open(mode,e); //Hook for submit if (this->tmbo != NULL && this->tmbo->GetType() == SUBMIT_HANDLER) { this->tmbo->SetFileSys(realFS); } } void TMFSHook::Write( const char *buf, int len, Error *e ) { realFS->Write(buf,len,e); } int TMFSHook::Read( char *buf, int len, Error *e ) { int tmp = realFS->Read(buf,len,e); return tmp; } int TMFSHook::ReadLine( StrBuf *buf, Error *e ) { int tmp = realFS->ReadLine(buf,e); return tmp; } void TMFSHook::Close( Error *e ) { realFS->Close(e); } int TMFSHook::Stat() { int tmp = realFS->Stat(); return tmp; } int TMFSHook::StatModTime() { int tmp = realFS->StatModTime(); return tmp; } void TMFSHook::Truncate( Error *e ) { realFS->Truncate(e); } void TMFSHook::Unlink( Error *e = 0 ) { realFS->Unlink(e); } void TMFSHook::Rename( FileSys * target, Error *e ) { realFS->Rename(target,e); } /* Hooked out for p4 edit, add, revert, sync, submit * The logic should be implemented in the Handlers. * */ void TMFSHook::Chmod( FilePerm perms, Error *e ) { /* Edit, Submit Hook * Chmodding for Sync and Revert * is done TMBOSync::Run() */ if (this->tmbo != NULL) { this->tmbo->Chmod (this, e); } } void TMFSHook::ChmodTime( Error *e ) { realFS->ChmodTime(e); } /* String for errormessages */ StrBuf & TMFSHook::GetDescription () { StrBuf * buf = new StrBuf; buf->Set ("TRYMEDIA FS HOOK"); return *buf; } /* Get Unix permissions */ mode_t TMFSHook::GetMode (Error * e) { if (this->attr == 0) { attr = tools->GetAttr(path.Text(), e); if (attr == NULL) return 0; } return attr->st_mode; } /* Set Unix permissions */ void TMFSHook::SetMode (mode_t st_mode, Error * e) { tools->SetMode (path.Text(), st_mode, e); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 5056 | harald_strack |
Directory support. Serious bug concerned to not unzipped binaries removed. Some other small bugfixes. |
||
#4 | 4980 | harald_strack |
Since I am maintaining the stuff in a local repository, I did some copy errors in the last revisions. Fixed. |
||
#3 | 4978 | harald_strack |
ap4 integrate implemented. Octal format is now used to save permissions. NOT backwards compatible anymore!!! |
||
#2 | 4975 | harald_strack |
Permissions are now masked to 555, so no write is possible. If you edit the Makefile and give the parameter -DFULL_PERMS, you have the old behaviour. Bugfix in ap4 revert: Edited and changed files were not reverted correctly. |
||
#1 | 4948 | harald_strack | Initial revision. |