From: Laszlo T. <ave...@us...> - 2005-06-05 10:55:11
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4185/Core Modified Files: Interface.cpp Interface.h StoreMgr.h Log Message: Saving stores to Cache in CloseCurrentStore Index: Interface.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Interface.cpp,v retrieving revision 1.316 retrieving revision 1.317 diff -C2 -d -r1.316 -r1.317 *** Interface.cpp 5 Jun 2005 09:53:17 -0000 1.316 --- Interface.cpp 5 Jun 2005 10:54:59 -0000 1.317 *************** *** 2804,2807 **** --- 2804,2816 ---- } + void Interface::RemoveFromCache( ieResRef resref) + { + char filename[_MAX_PATH]; + + strcpy( filename, CachePath ); + strcat( filename, resref ); + unlink ( filename); + } + void Interface::DelTree(const char* Pt, bool onlysave) { *************** *** 3162,3167 **** return -1; } ! // save current store to cache! ! // FreeInterface( sm ); delete CurrentStore; --- 3171,3192 ---- return -1; } ! int size = sm->GetStoredFileSize (CurrentStore); ! if (size > 0) { ! //created streams are always autofree (close file on destruct) ! //this one will be destructed when we return from here ! FileStream str; ! str.Create( CurrentStore->Name ); ! int ret = sm->PutStore (&str, CurrentStore); ! if (ret <0) { ! printMessage("Core"," ", YELLOW); ! printf("Store removed: %s\n", CurrentStore->Name); ! RemoveFromCache(CurrentStore->Name); ! } ! } else { ! printMessage("Core"," ", YELLOW); ! printf("Store removed: %s\n", CurrentStore->Name); ! RemoveFromCache(CurrentStore->Name); ! } ! //make sure the stream isn't connected to sm, or it will be double freed FreeInterface( sm ); delete CurrentStore; Index: Interface.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Interface.h,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** Interface.h 5 Jun 2005 09:53:17 -0000 1.156 --- Interface.h 5 Jun 2005 10:54:59 -0000 1.157 *************** *** 378,381 **** --- 378,383 ---- /*returns true if an itemtype is acceptable for a slottype */ int CanUseItemType(int itype, int slottype) const; + /*removes single file from cache*/ + void RemoveFromCache( ieResRef resref); /*removes all files from directory*/ void DelTree(const char *path, bool onlysaved); Index: StoreMgr.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/StoreMgr.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** StoreMgr.h 7 Mar 2005 18:26:27 -0000 1.3 --- StoreMgr.h 5 Jun 2005 10:54:59 -0000 1.4 *************** *** 45,48 **** --- 45,51 ---- virtual bool Open(DataStream* stream, bool autoFree = true) = 0; virtual Store* GetStore(Store *s) = 0; + + virtual int GetStoredFileSize(Store *s) = 0; + virtual int PutStore(DataStream* stream, Store *s) = 0; }; |