ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ucommon::dir Class Reference

#include <fsys.h>

Inheritance diagram for ucommon::dir:
[legend]
Collaboration diagram for ucommon::dir:
[legend]

Public Member Functions

 dir (const char *path)
 
 dir ()
 
 ~dir ()
 
void open (const char *path)
 
ssize_t read (char *buffer, size_t count)
 
void close (void)
 
int err (void) const
 
void reset (void)
 
 operator bool () const
 
bool operator! () const
 

Static Public Member Functions

static int create (const char *path, unsigned mode)
 
static int remove (const char *path)
 

Private Attributes

void * ptr
 
- Private Attributes inherited from ucommon::fsys
fd_t fd
 
int error
 

Additional Inherited Members

- Private Types inherited from ucommon::fsys
enum  {
  OWNER_READONLY = 0400, GROUP_READONLY = 0440, PUBLIC_READONLY = 0444, OWNER_PRIVATE = 0600,
  OWNER_PUBLIC = 0644, GROUP_PRIVATE = 0660, GROUP_PUBLIC = 0664, EVERYONE = 0666,
  DIR_TEMPORARY = 01777
}
 
enum  access_t {
  RDONLY, WRONLY, REWRITE, RDWR = REWRITE,
  APPEND, SHARED, EXCLUSIVE, DEVICE,
  STREAM, RANDOM
}
 
typedef struct stat fileinfo_t
 
typedef long offset_t
 
- Private Member Functions inherited from ucommon::fsys
 fsys ()
 
 fsys (fd_t handle)
 
 fsys (const fsys &descriptor)
 
 fsys (const char *path, access_t access)
 
 fsys (const char *path, unsigned permission, access_t access)
 
 ~fsys ()
 
fd_t operator* () const
 
 operator fd_t () const
 
void reset (void)
 
 operator bool () const
 
bool operator! () const
 
fsysoperator= (const fsys &descriptor)
 
fsysoperator*= (fd_t &descriptor)
 
fsysoperator= (fd_t descriptor)
 
fd_t handle (void) const
 
void set (fd_t descriptor)
 
fd_t release (void)
 
int seek (offset_t offset)
 
int drop (offset_t size=0)
 
bool is_tty (void) const
 
ssize_t read (void *buffer, size_t count)
 
ssize_t write (const void *buffer, size_t count)
 
int info (fileinfo_t *buffer)
 
int trunc (offset_t offset)
 
int sync (void)
 
void open (const char *path, access_t access)
 
void assign (fd_t descriptor)
 
void open (const char *path, unsigned mode, access_t access)
 
int close (void)
 
int err (void) const
 
- Static Private Member Functions inherited from ucommon::fsys
static int remapError (void)
 
static bool is_tty (fd_t fd)
 
static int prefix (const char *path)
 
static int prefix (char *path, size_t size)
 
static stringref_t prefix (void)
 
static int info (const char *path, fileinfo_t *buffer)
 
static int erase (const char *path)
 
static int copy (const char *source, const char *target, size_t size=1024)
 
static int rename (const char *oldpath, const char *newpath)
 
static int mode (const char *path, unsigned value)
 
static bool is_exists (const char *path)
 
static bool is_readable (const char *path)
 
static bool is_writable (const char *path)
 
static bool is_executable (const char *path)
 
static bool is_file (const char *path)
 
static bool is_dir (const char *path)
 
static bool is_link (const char *path)
 
static bool is_device (const char *path)
 
static bool is_hidden (const char *path)
 
static void assign (fsys &object, fd_t descriptor)
 
static int unlink (const char *path)
 
static int link (const char *path, const char *target)
 
static int hardlink (const char *path, const char *target)
 
static int linkinfo (const char *path, char *buffer, size_t size)
 
static fd_t input (const char *path)
 
static fd_t output (const char *path)
 
static fd_t append (const char *path)
 
static void release (fd_t descriptor)
 
static int pipe (fd_t &input, fd_t &output, size_t size=0)
 
static int inherit (fd_t &descriptor, bool enable)
 
static fd_t null (void)
 
static int load (const char *path)
 
static int exec (const char *path, char **argv, char **envp=NULL)
 
static bool is_file (struct stat *inode)
 
static bool is_dir (struct stat *inode)
 
static bool is_link (struct stat *inode)
 
static bool is_dev (struct stat *inode)
 
static bool is_char (struct stat *inode)
 
static bool is_disk (struct stat *inode)
 
static bool is_sys (struct stat *inode)
 
- Static Private Attributes inherited from ucommon::fsys
static const offset_t end = (offset_t)(-1)
 

Detailed Description

Convenience class for directories.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 743 of file fsys.h.

Constructor & Destructor Documentation

◆ dir() [1/2]

ucommon::dir::dir ( const char *  path)

Construct and open a directory path.

Parameters
pathof directory.

Definition at line 1177 of file fsys.cpp.

References open(), and ptr.

◆ dir() [2/2]

ucommon::dir::dir ( )

Construct an unopened directory.

Definition at line 1160 of file fsys.cpp.

References ptr.

◆ ~dir()

ucommon::dir::~dir ( )

Close and release directory.

Definition at line 1166 of file fsys.cpp.

References close().

Member Function Documentation

◆ close()

void ucommon::dir::close ( void  )

Close and release directory object.

Definition at line 808 of file fsys.cpp.

References ucommon::fsys::error, ptr, and ucommon::fsys::remapError().

Referenced by ost::DirTree::close(), ost::DirTree::getPath(), ucommon::DirPager::load(), open(), and ~dir().

◆ create()

int ucommon::dir::create ( const char *  path,
unsigned  mode 
)
static

Simple direct method to create a directory.

Parameters
pathof directory to create.
modeof directory.
Returns
error number or 0 on success.

Definition at line 895 of file fsys.cpp.

References ucommon::fsys::remapError().

Referenced by ucommon::shell::path(), and process().

◆ err()

int ucommon::dir::err ( void  ) const
inline

Definition at line 804 of file fsys.h.

References ucommon::fsys::err().

◆ open()

void ucommon::dir::open ( const char *  path)

Open a directory path for reading.

Parameters
pathto open.

Definition at line 909 of file fsys.cpp.

References close(), ucommon::fsys::error, ptr, and ucommon::fsys::remapError().

Referenced by dir(), ost::DirTree::getPath(), ucommon::DirPager::load(), and ost::DirTree::open().

◆ operator bool()

ucommon::dir::operator bool ( ) const
inline

Test if file descriptor is open.

Returns
true if open.

Definition at line 816 of file fsys.h.

◆ operator!()

bool ucommon::dir::operator! ( void  ) const
inline

Test if file descriptor is closed.

Returns
true if closed.

Definition at line 824 of file fsys.h.

◆ read()

ssize_t ucommon::dir::read ( char *  buffer,
size_t  count 
)

Read data from directory.

Parameters
bufferto read into.
countof bytes to read.
Returns
bytes transferred, -1 if error.

Definition at line 736 of file fsys.cpp.

References ptr, and ucommon::String::set().

Referenced by dirpath(), ucommon::DirPager::load(), and scan().

◆ remove()

int ucommon::dir::remove ( const char *  path)
static

Remove an empty directory.

Parameters
pathof directory.
Returns
error number or 0 on success.

Definition at line 1351 of file fsys.cpp.

References ucommon::fsys::error, ucommon::fsys::is_device(), and ucommon::fsys::remapError().

Referenced by scrub().

◆ reset()

void ucommon::dir::reset ( void  )
inline

Definition at line 808 of file fsys.h.

References ucommon::fsys::reset().

Member Data Documentation

◆ ptr

void* ucommon::dir::ptr
private

Definition at line 750 of file fsys.h.

Referenced by close(), dir(), open(), and read().


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