Loading...
Searching...
No Matches
directory.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: directory.h,v 1.29.16.1 2007/03/25 21:25:38 oliver Exp $
//
#ifndef BALL_SYSTEM_DIRECTORY_H
#define BALL_SYSTEM_DIRECTORY_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifndef BALL_CONCEPT_PROCESSOR_H
# include <BALL/CONCEPT/processor.h>
#endif
#ifndef BALL_DATATYPE_STRING_H
# include <BALL/DATATYPE/string.h>
#endif
#ifndef BALL_SYSTEM_FILESYSTEM_H
# include <BALL/SYSTEM/fileSystem.h>
#endif
#ifdef BALL_HAS_DIRENT_H
# include <dirent.h>
#endif
#ifdef BALL_HAS_UNISTD_H
# include <unistd.h>
#endif
#ifdef BALL_HAS_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef BALL_HAS_DIRECT_H
# include <direct.h>
#endif
#include <cstdio>
#ifdef BALL_COMPILER_MSVC
#define WINDOWS_LEAN_AND_MEAN
#include <windows.h>
#define mode_t int
#endif
namespace BALL
{
class BALL_EXPORT Directory
{
#ifndef BALL_OS_WINDOWS
# define INVALID_HANDLE_VALUE 0
#endif
public:
static const Size MAX_PATH_LENGTH;
Directory();
Directory(const String& directory_path, bool set_current = false);
Directory(const Directory& directory);
~Directory();
void clear();
void destroy();
bool set(const String& directory_path, bool set_current = false);
void set(const Directory& directory);
Directory& operator = (const Directory& directory);
void get(Directory& directory) const;
const String& getPath() const;
bool rename(String old_path, String new_path);
bool renameTo(String new_path);
bool setCurrent(String directory_path);
bool setCurrent();
bool create(String path, const mode_t& mode = 0777);
bool remove(String old_path);
bool remove();
bool getFirstEntry(String& entry);
bool getNextEntry(String& entry);
Size countItems();
Size countFiles();
Size countDirectories();
bool find(const String& filename, String& filepath);
bool has(const String& item);
bool isValid() const;
bool isCurrent() const;
bool isEmpty();
bool operator == (const Directory& directory) const;
bool operator != (const Directory& directory) const;
static String getUserHomeDir();
static bool changeToUserHomeDir();
private:
//_wrapper function around getcwd to handle different naming conventions in different OS
String getcwd_();
//_wrapper function around chdir to handle different naming conventions in different OS
int chdir_(const String& new_dir);
//_switch to this dir
void synchronize_();
//_switch back to the working directory
bool desynchronize_(bool result = true);
#ifdef BALL_COMPILER_MSVC
HANDLE dirent_;
HANDLE dir_;
#else
DIR* dir_;
dirent* dirent_;
#endif
String directory_path_;
String backup_path_;
};
# ifndef BALL_NO_INLINE_FUNCTIONS
# include <BALL/SYSTEM/directory.iC>
# endif
} // namespace BALL
#endif // BALL_SYSTEM_DIRECTORY_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::Directory::MAX_PATH_LENGTH
static const Size MAX_PATH_LENGTH
Definition directory.h:66
BALL::Directory::changeToUserHomeDir
static bool changeToUserHomeDir()
Goto the home directory of the current user.
BALL::Directory::setCurrent
bool setCurrent()
BALL::Directory::countFiles
Size countFiles()
BALL::Directory::countItems
Size countItems()
BALL::Directory::getNextEntry
bool getNextEntry(String &entry)
BALL::Directory::destroy
void destroy()
BALL::Directory::Directory
Directory(const Directory &directory)
BALL::Directory::getFirstEntry
bool getFirstEntry(String &entry)
BALL::Directory::clear
void clear()
BALL::Directory::countDirectories
Size countDirectories()
BALL::Directory::~Directory
~Directory()
BALL::Directory::Directory
Directory()
BALL::Directory::setCurrent
bool setCurrent(String directory_path)
BALL::Directory::find
bool find(const String &filename, String &filepath)
BALL::Directory::Directory
Directory(const String &directory_path, bool set_current=false)
BALL::Directory::rename
bool rename(String old_path, String new_path)
BALL::Directory::renameTo
bool renameTo(String new_path)
BALL::Directory::remove
bool remove(String old_path)
BALL::Directory::set
void set(const Directory &directory)
BALL::Directory::has
bool has(const String &item)
BALL::Directory::isValid
bool isValid() const
BALL::Directory::getPath
const String & getPath() const
BALL::Directory::create
bool create(String path, const mode_t &mode=0777)
BALL::Directory::isEmpty
bool isEmpty()
BALL::Directory::get
void get(Directory &directory) const
BALL::Directory::set
bool set(const String &directory_path, bool set_current=false)
BALL::Directory::remove
bool remove()
BALL::Directory::isCurrent
bool isCurrent() const
BALL::Directory::getUserHomeDir
static String getUserHomeDir()
Get the home directory of the current user.
BALL::String
Definition string.h:57
common.h
fileSystem.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
processor.h
string.h