XRootD
XrdCl::DirectoryList Class Reference

Directory list. More...

#include <XrdClXRootDResponses.hh>

+ Collaboration diagram for XrdCl::DirectoryList:

Classes

class  ListEntry
 Directory entry. More...
 

Public Types

typedef DirList::const_iterator ConstIterator
 Directory listing const iterator. More...
 
typedef std::vector< ListEntry * > DirList
 Directory listing. More...
 
typedef DirList::iterator Iterator
 Directory listing iterator. More...
 

Public Member Functions

 DirectoryList ()
 Constructor. More...
 
 ~DirectoryList ()
 Destructor. More...
 
void Add (ListEntry *entry)
 Add an entry to the list - takes ownership. More...
 
ListEntryAt (uint32_t index)
 Get an entry at given index. More...
 
Iterator Begin ()
 Get the begin iterator. More...
 
ConstIterator Begin () const
 Get the begin iterator. More...
 
Iterator End ()
 Get the end iterator. More...
 
ConstIterator End () const
 Get the end iterator. More...
 
const std::string & GetParentName () const
 Get parent directory name. More...
 
uint32_t GetSize () const
 Get the size of the listing. More...
 
bool ParseServerResponse (const std::string &hostId, const char *data)
 Parse server response and fill up the object. More...
 
bool ParseServerResponse (const std::string &hostId, const char *data, bool isDStat)
 Parse chunked server response and fill up the object. More...
 
void SetParentName (const std::string &parent)
 Set name of the parent directory. More...
 

Static Public Member Functions

static bool HasStatInfo (const char *data)
 Returns true if data contain stat info. More...
 

Detailed Description

Directory list.

Definition at line 650 of file XrdClXRootDResponses.hh.

Member Typedef Documentation

◆ ConstIterator

typedef DirList::const_iterator XrdCl::DirectoryList::ConstIterator

Directory listing const iterator.

Definition at line 757 of file XrdClXRootDResponses.hh.

◆ DirList

Directory listing.

Definition at line 747 of file XrdClXRootDResponses.hh.

◆ Iterator

typedef DirList::iterator XrdCl::DirectoryList::Iterator

Directory listing iterator.

Definition at line 752 of file XrdClXRootDResponses.hh.

Constructor & Destructor Documentation

◆ DirectoryList()

XrdCl::DirectoryList::DirectoryList ( )

Constructor.

Definition at line 514 of file XrdClXRootDResponses.cc.

515  {
516  }

◆ ~DirectoryList()

XrdCl::DirectoryList::~DirectoryList ( )

Destructor.

Definition at line 521 of file XrdClXRootDResponses.cc.

522  {
523  for( Iterator it = pDirList.begin(); it != pDirList.end(); ++it )
524  delete *it;
525  }
DirList::iterator Iterator
Directory listing iterator.

Member Function Documentation

◆ Add()

void XrdCl::DirectoryList::Add ( ListEntry entry)
inline

Add an entry to the list - takes ownership.

Definition at line 762 of file XrdClXRootDResponses.hh.

763  {
764  pDirList.push_back( entry );
765  }

Referenced by XrdCl::FileSystem::DirList(), XrdCl::ZipArchive::List(), and ParseServerResponse().

+ Here is the caller graph for this function:

◆ At()

ListEntry* XrdCl::DirectoryList::At ( uint32_t  index)
inline

Get an entry at given index.

Definition at line 770 of file XrdClXRootDResponses.hh.

771  {
772  return pDirList[index];
773  }

Referenced by XrdCl::FileSystem::DirList(), and XrdPosixDir::nextEntry().

+ Here is the caller graph for this function:

◆ Begin() [1/2]

Iterator XrdCl::DirectoryList::Begin ( )
inline

Get the begin iterator.

Definition at line 778 of file XrdClXRootDResponses.hh.

779  {
780  return pDirList.begin();
781  }

Referenced by XrdCl::FileSystem::DirList(), DoLS(), and IndexRemote().

+ Here is the caller graph for this function:

◆ Begin() [2/2]

ConstIterator XrdCl::DirectoryList::Begin ( ) const
inline

Get the begin iterator.

Definition at line 786 of file XrdClXRootDResponses.hh.

787  {
788  return pDirList.begin();
789  }

◆ End() [1/2]

Iterator XrdCl::DirectoryList::End ( )
inline

Get the end iterator.

Definition at line 794 of file XrdClXRootDResponses.hh.

795  {
796  return pDirList.end();
797  }

Referenced by XrdCl::FileSystem::DirList(), DoLS(), and IndexRemote().

+ Here is the caller graph for this function:

◆ End() [2/2]

ConstIterator XrdCl::DirectoryList::End ( ) const
inline

Get the end iterator.

Definition at line 802 of file XrdClXRootDResponses.hh.

803  {
804  return pDirList.end();
805  }

◆ GetParentName()

const std::string& XrdCl::DirectoryList::GetParentName ( ) const
inline

Get parent directory name.

Definition at line 818 of file XrdClXRootDResponses.hh.

819  {
820  return pParent;
821  }

Referenced by XrdCl::FileSystem::DirList(), and DoLS().

+ Here is the caller graph for this function:

◆ GetSize()

uint32_t XrdCl::DirectoryList::GetSize ( ) const
inline

Get the size of the listing.

Definition at line 810 of file XrdClXRootDResponses.hh.

811  {
812  return pDirList.size();
813  }

Referenced by XrdCl::FileSystem::DirList(), and XrdPosixDir::Open().

+ Here is the caller graph for this function:

◆ HasStatInfo()

bool XrdCl::DirectoryList::HasStatInfo ( const char *  data)
static

Returns true if data contain stat info.

Definition at line 594 of file XrdClXRootDResponses.cc.

595  {
596  std::string dat = data;
597  return !dat.compare( 0, dStatPrefix.size(), dStatPrefix );
598  }

Referenced by ParseServerResponse().

+ Here is the caller graph for this function:

◆ ParseServerResponse() [1/2]

bool XrdCl::DirectoryList::ParseServerResponse ( const std::string &  hostId,
const char *  data 
)

Parse server response and fill up the object.

Definition at line 530 of file XrdClXRootDResponses.cc.

532  {
533  if( !data )
534  return false;
535 
536  //--------------------------------------------------------------------------
537  // Check what kind of response we're dealing with
538  //--------------------------------------------------------------------------
539  bool isDStat = HasStatInfo( data );
540  if( isDStat )
541  data += dStatPrefix.size();
542  return ParseServerResponse( hostId, data, isDStat );
543  }
static bool HasStatInfo(const char *data)
Returns true if data contain stat info.
bool ParseServerResponse(const std::string &hostId, const char *data)
Parse server response and fill up the object.

References HasStatInfo().

+ Here is the call graph for this function:

◆ ParseServerResponse() [2/2]

bool XrdCl::DirectoryList::ParseServerResponse ( const std::string &  hostId,
const char *  data,
bool  isDStat 
)

Parse chunked server response and fill up the object.

Definition at line 548 of file XrdClXRootDResponses.cc.

551  {
552  if( !data )
553  return false;
554 
555  std::string dat = data;
556  std::vector<std::string> entries;
557  std::vector<std::string>::iterator it;
558  Utils::splitString( entries, dat, "\n" );
559 
560  //--------------------------------------------------------------------------
561  // Normal response
562  //--------------------------------------------------------------------------
563  if( !isDStat )
564  {
565  for( it = entries.begin(); it != entries.end(); ++it )
566  Add( new ListEntry( hostId, *it ) );
567  return true;
568  }
569 
570  //--------------------------------------------------------------------------
571  // kXR_dstat
572  //--------------------------------------------------------------------------
573  if( entries.size() % 2 )
574  return false;
575 
576  it = entries.begin(); //++it; ++it;
577  for( ; it != entries.end(); ++it )
578  {
579  ListEntry *entry = new ListEntry( hostId, *it );
580  Add( entry );
581  ++it;
582  StatInfo *i = new StatInfo();
583  entry->SetStatInfo( i );
584  bool ok = i->ParseServerResponse( it->c_str() );
585  if( !ok )
586  return false;
587  }
588  return true;
589  }
void Add(ListEntry *entry)
Add an entry to the list - takes ownership.
static void splitString(Container &result, const std::string &input, const std::string &delimiter)
Split a string.
Definition: XrdClUtils.hh:56

References Add(), XrdCl::StatInfo::ParseServerResponse(), XrdCl::DirectoryList::ListEntry::SetStatInfo(), and XrdCl::Utils::splitString().

+ Here is the call graph for this function:

◆ SetParentName()

void XrdCl::DirectoryList::SetParentName ( const std::string &  parent)
inline

Set name of the parent directory.

Definition at line 826 of file XrdClXRootDResponses.hh.

827  {
828  size_t pos = parent.find( '?' );
829  pParent = pos == std::string::npos ? parent : parent.substr( 0, pos );
830  if( !pParent.empty() && pParent[pParent.length()-1] != '/' )
831  pParent += "/";
832  }
static void parent()

References parent().

Referenced by XrdCl::FileSystem::DirList(), and XrdCl::ZipArchive::List().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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