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