SNAP Library 3.0, Developer Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TFile Class Reference

#include <fl.h>

Collaboration diagram for TFile:

Static Public Member Functions

static bool Exists (const TStr &FNm)
 
static void Copy (const TStr &SrcFNm, const TStr &DstFNm, const bool &ThrowExceptP=true, const bool &FailIfExistsP=false)
 
static void Del (const TStr &FNm, const bool &ThrowExceptP=true)
 
static void DelWc (const TStr &WcStr, const bool &RecurseDirP=false)
 
static void Rename (const TStr &SrcFNm, const TStr &DstFNm)
 
static TStr GetUniqueFNm (const TStr &FNm)
 
static uint64 GetSize (const TStr &FNm)
 
static uint64 GetCreateTm (const TStr &FNm)
 
static uint64 GetLastAccessTm (const TStr &FNm)
 
static uint64 GetLastWriteTm (const TStr &FNm)
 

Static Public Attributes

static const TStr TxtFExt =".Txt"
 
static const TStr HtmlFExt =".Html"
 
static const TStr HtmFExt =".Htm"
 
static const TStr GifFExt =".Gif"
 
static const TStr JarFExt =".Jar"
 

Detailed Description

Definition at line 587 of file fl.h.

Member Function Documentation

static void TFile::Copy ( const TStr SrcFNm,
const TStr DstFNm,
const bool &  ThrowExceptP = true,
const bool &  FailIfExistsP = false 
)
static
void TFile::Del ( const TStr FNm,
const bool &  ThrowExceptP = true 
)
static

Definition at line 1198 of file fl.cpp.

References TStr::CStr(), and EAssertR.

Referenced by DelWc().

1198  {
1199  if (ThrowExceptP){
1200  EAssertR(
1201  remove(FNm.CStr())==0,
1202  "Error removing file '"+FNm+"'.");
1203  } else {
1204  remove(FNm.CStr());
1205  }
1206 }
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

Here is the caller graph for this function:

void TFile::DelWc ( const TStr WcStr,
const bool &  RecurseDirP = false 
)
static

Definition at line 1208 of file fl.cpp.

References TVec< TVal, TSizeTy >::Add(), Del(), TVec< TVal, TSizeTy >::Len(), and TFFile::Next().

Referenced by TMBlobBs::TMBlobBs().

1208  {
1209  // collect file-names
1210  TStrV FNmV;
1211  TFFile FFile(WcStr, RecurseDirP); TStr FNm;
1212  while (FFile.Next(FNm)){
1213  FNmV.Add(FNm);}
1214  // delete files
1215  for (int FNmN=0; FNmN<FNmV.Len(); FNmN++){
1216  Del(FNmV[FNmN], false);}
1217 }
Definition: xfl.h:30
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:547
static void Del(const TStr &FNm, const bool &ThrowExceptP=true)
Definition: fl.cpp:1198
Definition: dt.h:412
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:429

Here is the call graph for this function:

Here is the caller graph for this function:

bool TFile::Exists ( const TStr FNm)
static

Definition at line 1100 of file fl.cpp.

References TStr::Empty().

Referenced by TGBlobBs::Exists(), TMBlobBs::Exists(), GetUniqueFNm(), TUniChDb::Test(), TMBlobBs::TMBlobBs(), and TZipIn::TZipIn().

1100  {
1101  if (FNm.Empty()) { return false; }
1102  bool DoExists;
1103  TFIn FIn(FNm, DoExists);
1104  return DoExists;
1105 }
Definition: fl.h:275
bool Empty() const
Definition: dt.h:488

Here is the call graph for this function:

Here is the caller graph for this function:

static uint64 TFile::GetCreateTm ( const TStr FNm)
static
static uint64 TFile::GetLastAccessTm ( const TStr FNm)
static
static uint64 TFile::GetLastWriteTm ( const TStr FNm)
static
static uint64 TFile::GetSize ( const TStr FNm)
static
TStr TFile::GetUniqueFNm ( const TStr FNm)
static

Definition at line 1225 of file fl.cpp.

References TStr::ChangeStr(), Exists(), TStr::Fmt(), forever, TStr::InsStr(), TStr::Len(), and TStr::SearchCh().

Referenced by TForestFire::PlotFire().

1225  {
1226  // <name>.#.txt --> <name>.<num>.txt
1227  int Cnt=1; int ch;
1228  TStr NewFNm; TStr TmpFNm=FNm;
1229  if (FNm.SearchCh('#') == -1) {
1230  for (ch = FNm.Len()-1; ch >= 0; ch--) if (FNm[ch] == '.') break;
1231  if (ch != -1) TmpFNm.InsStr(ch, ".#");
1232  else TmpFNm += ".#";
1233  }
1234  forever{
1235  NewFNm=TmpFNm;
1236  NewFNm.ChangeStr("#", TStr::Fmt("%03d", Cnt)); Cnt++;
1237  if (!TFile::Exists(NewFNm)){break;}
1238  }
1239  return NewFNm;
1240 }
int SearchCh(const char &Ch, const int &BChN=0) const
Definition: dt.cpp:1043
int Len() const
Definition: dt.h:487
static bool Exists(const TStr &FNm)
Definition: fl.cpp:1100
#define forever
Definition: bd.h:6
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
void InsStr(const int &BChN, const TStr &Str)
Definition: dt.cpp:825
int ChangeStr(const TStr &SrcStr, const TStr &DstStr, const int &BChN=0)
Definition: dt.cpp:1130

Here is the call graph for this function:

Here is the caller graph for this function:

void TFile::Rename ( const TStr SrcFNm,
const TStr DstFNm 
)
static

Definition at line 1219 of file fl.cpp.

References TStr::CStr(), and EAssertR.

1219  {
1220  EAssertR(
1221  rename(SrcFNm.CStr(), DstFNm.CStr())==0,
1222  "Error renaming file '"+SrcFNm+"' to "+DstFNm+"'.");
1223 }
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

Member Data Documentation

const TStr TFile::GifFExt =".Gif"
static

Definition at line 592 of file fl.h.

Referenced by THttp::IsGifFExt().

const TStr TFile::HtmFExt =".Htm"
static

Definition at line 591 of file fl.h.

Referenced by THttp::IsHtmlFExt().

const TStr TFile::HtmlFExt =".Html"
static

Definition at line 590 of file fl.h.

Referenced by THttp::IsHtmlFExt().

const TStr TFile::JarFExt =".Jar"
static

Definition at line 593 of file fl.h.

const TStr TFile::TxtFExt =".Txt"
static

Definition at line 589 of file fl.h.


The documentation for this class was generated from the following files: