/** * Copyright Mikael Högdahl - triyana@users.sourceforge.net * * This source is distributed under the terms of the Q Public License version 1.0, * created by Trolltech (www.trolltech.com). */ #ifndef MHFileTransaction_h #define MHFileTransaction_h #include "MH.h" #include "MHFile.h" #include "MHString.h" class MHVector; /** * A file transaction object. If turned on with begin all file names * that are returned are temporary names. To rename them call Commit * or do a Rollback to delete all temporary files. */ class MHFileTransaction : public MH { public: MHFileTransaction (); ~MHFileTransaction (); const char* Class () {return "MHFileTransaction";} static void Begin (); static bool Commit (); static void GetFileName (const char* orgName, MHString* newName, bool read) {if (MHFileTransaction::aaTransaction) MHFileTransaction::aaTransaction->getFileName (orgName, newName, read); else *newName = orgName;} static void Rollback (); private: MHVector* aOrgFiles; MHVector* aNewFiles; static MHFileTransaction* aaTransaction; void Check (bool rollback); bool commit2 (); void getFileName (const char* orgName, MHString* newName, bool read); void rollback2 (); }; #endif