FileUtil.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 CSIRO ICT Centre
00003  *
00004  * $Id: FileUtil.h 5491 2009-02-05 18:09:29Z RossCollins $
00005  */
00006 
00007 /*
00008  * Common file operations. Opening a file for reading or writing,
00009  * closing a file, and reading the filenames in a given directory
00010  * with a common prefix.
00011  *
00012  * This is a singleton class. Call using FileUtil::instance().
00013  */
00014 
00015 #ifndef FILEUTIL_DEFINED
00016 #define FILEUTIL_DEFINED
00017 
00018 #include "String.h"
00019 #include <vector>
00020 
00021 #include "Destroyer.h"
00022 #include "FileHeader.h"
00023 
00024 
00025 class FileUtil
00026 {
00027   public:
00028     static FileUtil * instance()
00029     {
00030       if (s_instance == 0)
00031       {
00032         s_instance = new FileUtil();
00033         DestroyerInit(s_instance)
00034       }
00035       return s_instance;
00036     }
00037     DestroyerFriend(FileUtil)
00038 
00039     ~FileUtil() {};
00040 
00041     void readDir(std::vector<String> & files, char * dirName, char * prefix);
00042 
00043     FILE * readOpen(String const & fileName, bool isLarge=false);
00044     FILE * writeOpen(String const & fileName, bool isLarge=false);
00045     void close(FILE * & fp);
00046 
00047   private:
00048     DestroyerDefine(FileUtil)
00049     static FileUtil * s_instance;
00050 
00051     FileUtil() {};
00052     FileUtil(FileUtil const &);
00053     FileUtil & operator=(FileUtil const &);
00054 };
00055 
00056 #endif // ifndef FILEUTIL_DEFINED
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3