Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
vfsdirchange.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2005 by Jorrit Tyberghein 00003 (C) 2005 by Frank Richter 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00023 #include "iutil/vfs.h" 00024 #include "csutil/csstring.h" 00025 00030 class csVfsDirectoryChanger 00031 { 00032 csRef<iVFS> vfs; 00037 uint popCount; 00038 public: 00040 csVfsDirectoryChanger (iVFS* vfs) : vfs(vfs), popCount(0) { } 00042 ~csVfsDirectoryChanger() 00043 { 00044 while (popCount--) vfs->PopDir(); 00045 } 00052 void ChangeTo (const char* filename) 00053 { 00054 if (!vfs) return; 00055 const char* slash = strrchr (filename, '/'); 00056 if (slash != 0) 00057 { 00058 csString dir; 00059 dir.Replace (filename, slash - filename); 00060 vfs->PushDir (); 00061 vfs->ChDir (dir); 00062 popCount++; 00063 } 00064 } 00071 void PushDir () 00072 { 00073 vfs->PushDir (); 00074 popCount++; 00075 } 00076 };
Generated for Crystal Space by doxygen 1.4.4