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 508 of file XrdClXRootDResponses.cc.

509  {
510  }

◆ ~DirectoryList()

XrdCl::DirectoryList::~DirectoryList ( )

Destructor.

Definition at line 515 of file XrdClXRootDResponses.cc.

516  {
517  for( Iterator it = pDirList.begin(); it != pDirList.end(); ++it )
518  delete *it;
519  }
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 588 of file XrdClXRootDResponses.cc.

589  {
590  std::string dat = data;
591  return !dat.compare( 0, dStatPrefix.size(), dStatPrefix );
592  }

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 524 of file XrdClXRootDResponses.cc.

526  {
527  if( !data )
528  return false;
529 
530  //--------------------------------------------------------------------------
531  // Check what kind of response we're dealing with
532  //--------------------------------------------------------------------------
533  bool isDStat = HasStatInfo( data );
534  if( isDStat )
535  data += dStatPrefix.size();
536  return ParseServerResponse( hostId, data, isDStat );
537  }
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 542 of file XrdClXRootDResponses.cc.

545  {
546  if( !data )
547  return false;
548 
549  std::string dat = data;
550  std::vector<std::string> entries;
551  std::vector<std::string>::iterator it;
552  Utils::splitString( entries, dat, "\n" );
553 
554  //--------------------------------------------------------------------------
555  // Normal response
556  //--------------------------------------------------------------------------
557  if( !isDStat )
558  {
559  for( it = entries.begin(); it != entries.end(); ++it )
560  Add( new ListEntry( hostId, *it ) );
561  return true;
562  }
563 
564  //--------------------------------------------------------------------------
565  // kXR_dstat
566  //--------------------------------------------------------------------------
567  if( entries.size() % 2 )
568  return false;
569 
570  it = entries.begin(); //++it; ++it;
571  for( ; it != entries.end(); ++it )
572  {
573  ListEntry *entry = new ListEntry( hostId, *it );
574  Add( entry );
575  ++it;
576  StatInfo *i = new StatInfo();
577  entry->SetStatInfo( i );
578  bool ok = i->ParseServerResponse( it->c_str() );
579  if( !ok )
580  return false;
581  }
582  return true;
583  }
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: