#include "TSystemFile.h"
#include "TBrowser.h"
#include "TSystem.h"
#include "TEnv.h"
ClassImp(TSystemFile)
TSystemFile::TSystemFile() : TNamed()
{
   
}
TSystemFile::TSystemFile(const char *filename, const char *dirname)
   : TNamed(filename, dirname)
{
   
   SetBit(kCanDelete);
}
TSystemFile::~TSystemFile()
{
   
}
Bool_t TSystemFile::IsDirectory(const char *dir) const
{
   
   Long64_t size;
   Long_t id, flags, modtime;
   flags = id = size = modtime = 0;
   gSystem->GetPathInfo(!dir ? fName.Data() : dir, &id, &size, &flags, &modtime);
   Int_t isdir = (Int_t)flags & 2;
   return isdir ? kTRUE : kFALSE;
}
void TSystemFile::Browse(TBrowser *b)
{
   
   
   if (b)
      b->ExecuteDefaultAction(this);
}
void TSystemFile::Edit()
{
   
#ifndef _WIN32
   const char *ed = gEnv->GetValue("Editor", "vi");
   Char_t *cmd = new Char_t[strlen(ed)+strlen(GetName()) + 50];
   if (!strcmp(ed, "vi"))
      sprintf(cmd, "xterm -e vi %s &", GetName());
   else
      sprintf(cmd, "%s %s &", ed, GetName());
#else
   const char *ed = gEnv->GetValue("Editor", "notepad");
   Char_t *cmd = new Char_t[strlen(ed)+strlen(GetName()) + 50];
   sprintf(cmd, "start %s %s", ed, GetName());
#endif
   gSystem->Exec(cmd);
   delete [] cmd;
}
void TSystemFile::Copy(const char *to)
{
   
   TString name = to;
   if (IsDirectory(to)) {
      if (name.EndsWith("/")) name.Chop();
      name = gSystem->ConcatFileName(name, fName);
   }
   Int_t status = gSystem->CopyFile(fName, name, kFALSE);
   if (status == -2) {
      Warning("Copy", "File %s already exists", name.Data());
   } else if (status == -1) {
      Warning("Copy", "Failed to move file %s", name.Data());
   }
}
void TSystemFile::Move(const char *to)
{
   
   if (!to) {
      Warning("Move", "No file/dir name specified");
      return;
   }
   TString name = to;
   if (IsDirectory(to)) {
      if (name.EndsWith("/")) name.Chop();
      name = gSystem->ConcatFileName(name, fName);
   }
   Int_t status = gSystem->CopyFile(fName, name, kFALSE);
   if (!status) {
      gSystem->Unlink(fName);
   } else if (status == -2) {
      Warning("Move", "File %s already exists", name.Data());
   } else if (status == -1) {
      Warning("Move", "Failed to move file %s", name.Data());
   }
}
void TSystemFile::Delete()
{
   
   gSystem->Unlink(fName);
}
void TSystemFile::Rename(const char *name)
{
   
   gSystem->Rename(fName, name);
}
void TSystemFile::Inspect() const
{
   
}
void TSystemFile::Dump() const
{
   
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.