XRootD
XrdCl::DirectoryList Class Reference

Directory list. More...

#include <XrdClXRootDResponses.hh>

+ Inheritance diagram for XrdCl::DirectoryList:
+ 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...
 
virtual ~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 669 of file XrdClXRootDResponses.hh.

Member Typedef Documentation

◆ ConstIterator

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

Directory listing const iterator.

Definition at line 776 of file XrdClXRootDResponses.hh.

◆ DirList

Directory listing.

Definition at line 766 of file XrdClXRootDResponses.hh.

◆ Iterator

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

Directory listing iterator.

Definition at line 771 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 ( )
virtual

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 781 of file XrdClXRootDResponses.hh.

782  {
783  pDirList.push_back( entry );
784  }

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 789 of file XrdClXRootDResponses.hh.

790  {
791  return pDirList[index];
792  }

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 797 of file XrdClXRootDResponses.hh.

798  {
799  return pDirList.begin();
800  }

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 805 of file XrdClXRootDResponses.hh.

806  {
807  return pDirList.begin();
808  }

◆ End() [1/2]

Iterator XrdCl::DirectoryList::End ( )
inline

Get the end iterator.

Definition at line 813 of file XrdClXRootDResponses.hh.

814  {
815  return pDirList.end();
816  }

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 821 of file XrdClXRootDResponses.hh.

822  {
823  return pDirList.end();
824  }

◆ GetParentName()

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

Get parent directory name.

Definition at line 837 of file XrdClXRootDResponses.hh.

838  {
839  return pParent;
840  }

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 829 of file XrdClXRootDResponses.hh.

830  {
831  return pDirList.size();
832  }

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 845 of file XrdClXRootDResponses.hh.

846  {
847  size_t pos = parent.find( '?' );
848  pParent = pos == std::string::npos ? parent : parent.substr( 0, pos );
849  if( !pParent.empty() && pParent[pParent.length()-1] != '/' )
850  pParent += "/";
851  }
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: