SNAP Library, Developer Reference  2012-10-15 15:06:59
SNAP, a general purpose network analysis and graph mining library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
xfl.h
Go to the documentation of this file.
00001 
00002 // Find-File-Descriptor
00003 ClassTP(TFFileDesc, PFFileDesc)//{
00004 public:
00005 #ifdef GLib_WIN
00006   WIN32_FIND_DATA FDesc;
00007   HANDLE FFileH;
00008 #else
00009   DIR* FDesc;
00010   dirent* DirEnt;
00011 #endif
00012 public:
00013   TFFileDesc();
00014   static PFFileDesc New(){return PFFileDesc(new TFFileDesc());}
00015   ~TFFileDesc();
00016   TFFileDesc(TSIn&){Fail;}
00017   static PFFileDesc Load(TSIn& SIn){return new TFFileDesc(SIn);}
00018   void Save(TSOut&){Fail;}
00019 
00020   TFFileDesc& operator=(const TFFileDesc&){Fail; return *this;}
00021 
00022   TStr GetFBase() const;
00023   bool IsDir() const;
00024 };
00025 
00027 // Find-File
00028 ClassTP(TFFile, PFFile)//{
00029 private:
00030   TStrV FPathV, FExtV;
00031   TStr FBaseWc;
00032   bool CsImpP;
00033   bool RecurseP;
00034   int FPathN;
00035   PFFileDesc FFileDesc;
00036   PFFile SubFFile;
00037   TStr CurFNm;
00038   int CurFNmN;
00039   UndefDefaultCopyAssign(TFFile);
00040 public:
00041   TFFile(const TStr& _FNmWc, const bool& _RecurseP=false);
00042   TFFile(const TStr& _FPath, const TStr& _FExt, const bool& _RecurseP=false);
00043   TFFile(const TStrV& _FPathV, const TStrV& _FExtV,
00044    const TStr& _FBaseWc, const bool& _RecurseP);
00045   static PFFile New(const TStr& FNmWc, const bool& RecurseP){
00046     return PFFile(new TFFile(FNmWc, RecurseP));}
00047   static PFFile New(const TStrV& FPathV, const TStrV& FExtV,
00048    const TStr FBaseWc, const bool& RecurseP){
00049     return PFFile(new TFFile(FPathV, FExtV, FBaseWc, RecurseP));}
00050   static PFFile New(const TStr& FPath, const TStr& FExt, const bool& RecurseP){
00051     return PFFile(new TFFile(FPath, FExt, RecurseP));}
00052   ~TFFile();
00053   TFFile(TSIn&){Fail;}
00054   static PFFile Load(TSIn& SIn){return new TFFile(SIn);}
00055   void Save(TSOut&){Fail;}
00056 
00057   bool Next(TStr& FNm);
00058   bool Next(){TStr FNm; return Next(FNm);}
00059   TStr GetFNm() const {return CurFNm;}
00060   int GetFNmN() const {return CurFNmN;}
00061 
00062   static void GetFNmV(
00063    const TStr& FPath, const TStrV& FExtV, const bool& RecurseP, TStrV& FNmV);
00064 
00065   bool IsDir() const {
00066    return FFileDesc->IsDir();}
00067 };
00068 
00070 // Directories
00071 class TDir{
00072 public:
00073   static TStr GetCurDir();
00074   static TStr GetExeDir();
00075   static bool GenDir(const TStr& FPathFNm);
00076   static bool DelDir(const TStr& FPathFNm);
00077 };
00078 
00080 // File-Path-Log
00081 class TFPathNotify : public TNotify {
00082 private:
00083         TStr LogFPath;
00084         TStr PrefixFNm;
00085         TTm LastTm;
00086         PSOut LogSOut;
00087         TBool FlushP;
00088 
00089 private:
00090         void UpdateSOut(const TTm& NowTm);
00091         UndefDefaultCopyAssign(TFPathNotify);
00092 
00093 public:
00094         TFPathNotify(const TStr& _LogFPath, const TStr& _PrefixFNm, const bool& _FlushP);
00095         static PNotify New(const TStr& LogFPath, const TStr& PrefixFNm, const bool& FlushP) {
00096                 return PNotify(new TFPathNotify(LogFPath, PrefixFNm, FlushP));}
00097 
00098         void OnStatus(const TStr& MsgStr);
00099 };