OpenDDS  Snapshot(2023/04/07-19:43)
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
OpenDDS::FileSystemStorage::File Class Reference

#include <FileSystemStorage.h>

Inheritance diagram for OpenDDS::FileSystemStorage::File:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::FileSystemStorage::File:
Collaboration graph
[legend]

Public Types

typedef RcHandle< FilePtr
 

Public Member Functions

bool write (std::ofstream &stream)
 
bool read (std::ifstream &stream)
 
bool remove ()
 
OPENDDS_STRING name () const
 
Directory::Ptr parent () const
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Private Member Functions

 File (const ACE_TString &fname_phys, const ACE_TString &logical, const Directory::Ptr &parent)
 

Private Attributes

ACE_TString physical_file_
 
ACE_TString physical_dir_
 
ACE_TString logical_relative_
 
Directory::Ptr parent_
 

Friends

class Directory
 
template<typename Item >
class Directory::Iterator
 
template<typename T , typename U0 , typename U1 , typename U2 >
OpenDDS::DCPS::RcHandle< T > OpenDDS::DCPS::make_rch (const U0 &, const U1 &, const U2 &)
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Detailed Description

Definition at line 224 of file FileSystemStorage.h.

Member Typedef Documentation

◆ Ptr

Definition at line 226 of file FileSystemStorage.h.

Constructor & Destructor Documentation

◆ File()

OpenDDS::FileSystemStorage::File::File ( const ACE_TString fname_phys,
const ACE_TString logical,
const Directory::Ptr parent 
)
private

Definition at line 459 of file FileSystemStorage.cpp.

References ACE_TEXT(), ACE_String_Base< char >::c_str(), ACE_String_Base_Const::npos, physical_dir_, physical_file_, ACE_String_Base< char >::rfind(), and ACE_String_Base< char >::set().

461  : physical_file_()
462  , physical_dir_()
463  , logical_relative_(logical)
464  , parent_(parent)
465 {
466  String_Index_t last_slash = fname_phys.rfind(ACE_TEXT('/'));
467 
468  if (last_slash == ACE_TString::npos) {
469  physical_file_ = fname_phys;
470  physical_dir_ = ACE_TEXT(".");
471 
472  } else {
473  physical_file_ = fname_phys.c_str() + last_slash + 1;
474  physical_dir_.set(fname_phys.c_str(), last_slash, true);
475  }
476 }
const char * c_str(void) const
size_type rfind(char c, size_type pos=npos) const
size_t String_Index_t
static size_type const npos
void set(const char *s, bool release=true)
ACE_TEXT("TCP_Factory")

Member Function Documentation

◆ name()

OPENDDS_STRING OpenDDS::FileSystemStorage::File::name ( void  ) const

Definition at line 510 of file FileSystemStorage.cpp.

References ACE_TEXT_ALWAYS_CHAR, ACE_String_Base< char >::c_str(), and logical_relative_.

511 {
513 }
const char * c_str(void) const
#define ACE_TEXT_ALWAYS_CHAR(STRING)

◆ parent()

Directory::Ptr OpenDDS::FileSystemStorage::File::parent ( void  ) const
inline

Definition at line 232 of file FileSystemStorage.h.

232  {
233  return parent_;
234  }

◆ read()

bool OpenDDS::FileSystemStorage::File::read ( std::ifstream &  stream)

Definition at line 486 of file FileSystemStorage.cpp.

References ACE_TEXT_ALWAYS_CHAR, ACE_String_Base< char >::c_str(), physical_dir_, and physical_file_.

487 {
488  CwdGuard cg(physical_dir_);
490  ios::binary | ios::in);
491  return !stream.bad() && !stream.fail();
492 }
const char * c_str(void) const
#define ACE_TEXT_ALWAYS_CHAR(STRING)

◆ remove()

bool OpenDDS::FileSystemStorage::File::remove ( void  )

Definition at line 494 of file FileSystemStorage.cpp.

References ACE_String_Base< char >::c_str(), logical_relative_, parent_, physical_dir_, physical_file_, and ACE_OS::unlink().

495 {
496  int unlink_result = -1;
497  {
498  CwdGuard cg(physical_dir_);
499  unlink_result = ACE_OS::unlink(physical_file_.c_str());
500  }
501 
502  if (unlink_result != -1) {
503  parent_->removing(logical_relative_, true);
504  return true;
505  }
506 
507  return false;
508 }
const char * c_str(void) const
int unlink(const char *path)

◆ write()

bool OpenDDS::FileSystemStorage::File::write ( std::ofstream &  stream)

Definition at line 478 of file FileSystemStorage.cpp.

References ACE_TEXT_ALWAYS_CHAR, ACE_String_Base< char >::c_str(), physical_dir_, and physical_file_.

479 {
480  CwdGuard cg(physical_dir_);
482  ios::binary | ios::out);
483  return !stream.bad() && !stream.fail();
484 }
const char * c_str(void) const
#define ACE_TEXT_ALWAYS_CHAR(STRING)

Friends And Related Function Documentation

◆ Directory

friend class Directory
friend

Definition at line 237 of file FileSystemStorage.h.

◆ Directory::Iterator

template<typename Item >
friend class Directory::Iterator
friend

Definition at line 240 of file FileSystemStorage.h.

◆ OpenDDS::DCPS::make_rch

template<typename T , typename U0 , typename U1 , typename U2 >
OpenDDS::DCPS::RcHandle<T> OpenDDS::DCPS::make_rch ( const U0 &  ,
const U1 &  ,
const U2 &   
)
friend

Member Data Documentation

◆ logical_relative_

ACE_TString OpenDDS::FileSystemStorage::File::logical_relative_
private

Definition at line 244 of file FileSystemStorage.h.

Referenced by name(), and remove().

◆ parent_

Directory::Ptr OpenDDS::FileSystemStorage::File::parent_
private

Definition at line 245 of file FileSystemStorage.h.

Referenced by OpenDDS::FileSystemStorage::Directory::remove(), and remove().

◆ physical_dir_

ACE_TString OpenDDS::FileSystemStorage::File::physical_dir_
private

Definition at line 244 of file FileSystemStorage.h.

Referenced by File(), read(), remove(), and write().

◆ physical_file_

ACE_TString OpenDDS::FileSystemStorage::File::physical_file_
private

Definition at line 244 of file FileSystemStorage.h.

Referenced by File(), read(), remove(), and write().


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