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]
List of all members.

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

Private Member Functions

 File (const ACE_TString &fname_phys, const ACE_TString &logical, Directory *parent)

Private Attributes

ACE_TString physical_file_
ACE_TString physical_dir_
ACE_TString logical_relative_
Directory::Ptr parent_

Friends

class Directory
class Directory::Iterator

Detailed Description

Definition at line 217 of file FileSystemStorage.h.


Member Typedef Documentation

typedef RcHandle<File> OpenDDS::FileSystemStorage::File::Ptr

Definition at line 219 of file FileSystemStorage.h.


Constructor & Destructor Documentation

OpenDDS::FileSystemStorage::File::File ( const ACE_TString &  fname_phys,
const ACE_TString &  logical,
Directory parent 
) [private]

Definition at line 457 of file FileSystemStorage.cpp.

References physical_dir_, and physical_file_.

00459   : physical_file_()
00460   , physical_dir_()
00461   , logical_relative_(logical)
00462   , parent_(parent, false)
00463 {
00464   String_Index_t last_slash = fname_phys.rfind(ACE_TEXT('/'));
00465 
00466   if (last_slash == ACE_TString::npos) {
00467     physical_file_ = fname_phys;
00468     physical_dir_ = ACE_TEXT(".");
00469 
00470   } else {
00471     physical_file_ = fname_phys.c_str() + last_slash + 1;
00472     physical_dir_.set(fname_phys.c_str(), last_slash, true);
00473   }
00474 }


Member Function Documentation

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

Definition at line 508 of file FileSystemStorage.cpp.

References logical_relative_.

00509 {
00510   return ACE_TEXT_ALWAYS_CHAR(logical_relative_.c_str());
00511 }

Directory::Ptr OpenDDS::FileSystemStorage::File::parent (  )  const [inline]

Definition at line 225 of file FileSystemStorage.h.

00225                               {
00226     return parent_;
00227   }

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

Definition at line 484 of file FileSystemStorage.cpp.

References physical_dir_, and physical_file_.

00485 {
00486   CwdGuard cg(physical_dir_);
00487   stream.open(ACE_TEXT_ALWAYS_CHAR(physical_file_.c_str()),
00488               ios::binary | ios::in);
00489   return !stream.bad() && !stream.fail();
00490 }

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

Definition at line 492 of file FileSystemStorage.cpp.

References logical_relative_, parent_, physical_dir_, and physical_file_.

00493 {
00494   int unlink_result = -1;
00495   {
00496     CwdGuard cg(physical_dir_);
00497     unlink_result = ACE_OS::unlink(physical_file_.c_str());
00498   }
00499 
00500   if (unlink_result != -1) {
00501     parent_->removing(logical_relative_, true);
00502     return true;
00503   }
00504 
00505   return false;
00506 }

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

Definition at line 476 of file FileSystemStorage.cpp.

References physical_dir_, and physical_file_.

00477 {
00478   CwdGuard cg(physical_dir_);
00479   stream.open(ACE_TEXT_ALWAYS_CHAR(physical_file_.c_str()),
00480               ios::binary | ios::out);
00481   return !stream.bad() && !stream.fail();
00482 }


Friends And Related Function Documentation

friend class Directory [friend]

Definition at line 230 of file FileSystemStorage.h.

friend class Directory::Iterator [friend]

Definition at line 231 of file FileSystemStorage.h.


Member Data Documentation

ACE_TString OpenDDS::FileSystemStorage::File::logical_relative_ [private]

Definition at line 235 of file FileSystemStorage.h.

Referenced by name(), and remove().

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

Definition at line 236 of file FileSystemStorage.h.

Referenced by remove().

ACE_TString OpenDDS::FileSystemStorage::File::physical_dir_ [private]

Definition at line 235 of file FileSystemStorage.h.

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

ACE_TString OpenDDS::FileSystemStorage::File::physical_file_ [private]

Definition at line 235 of file FileSystemStorage.h.

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


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:47 2016 for OpenDDS by  doxygen 1.4.7