NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Private Types | List of all members
CDir Class Reference

Search Toolkit Book for CDir

CDir –. More...

#include <corelib/ncbifile.hpp>

+ Inheritance diagram for CDir:
+ Collaboration diagram for CDir:

Public Types

enum  EGetEntriesFlags {
  fIgnoreRecursive = (1<<1), fCreateObjects = (1<<2), fNoCase = (1<<3), fIgnorePath = (1<<4),
  fThrowOnError = (1<<5), eAllEntries = 0, eIgnoreRecursive = fIgnoreRecursive
}
 Flags for GetEntries() More...
 
enum  ECreateFlags {
  fCreate_Default = 0, fCreate_PermByUmask = (1 << 1), fCreate_PermAsParent = (1 << 2), fCreate_ErrorIfExists = (1 << 3),
  fCreate_UpdateIfExists = (1 << 4)
}
 Flags for Create()/CreatePath() More...
 
typedef AutoPtr< CDirEntryTEntry
 Define a list of pointers to directory entries. More...
 
typedef list< TEntryTEntries
 
typedef int TGetEntriesFlags
 Binary OR of "EGetEntriesFlags". More...
 
typedef TGetEntriesFlags EGetEntriesMode
 
typedef unsigned int TCreateFlags
 Binary OR of "ECreateFlags". More...
 
- Public Types inherited from CDirEntry
enum  EIfEmptyPath { eIfEmptyPath_Empty, eIfEmptyPath_Current }
 What GetDir() should return if the dir entry does not contains path. More...
 
enum  ERelativeToWhat { eRelativeToCwd, eRelativeToExe }
 How to interpret relative paths. More...
 
enum  ECopyFlags {
  fCF_Overwrite = (1 << 1), fCF_Update = (1 << 2) | fCF_Overwrite, fCF_Backup = (1 << 3) | fCF_Overwrite, fCF_Safe = (1 << 4) | fCF_Overwrite,
  fCF_TopDirOnly = (1 << 6), fCF_EqualTypes = (1 << 7), fCF_FollowLinks = (1 << 8), fCF_Verify = (1 << 9),
  fCF_PreserveOwner = (1 << 10), fCF_PreservePerm = (1 << 11), fCF_PreserveTime = (1 << 12), fCF_PreserveAll = fCF_PreserveOwner | fCF_PreservePerm | fCF_PreserveTime,
  fCF_Recursive = (1 << 14), fCF_SkipUnsupported = (1 << 15), fCF_Default = fCF_Recursive | fCF_FollowLinks
}
 Copy flags. More...
 
enum  ERenameFlags {
  fRF_Overwrite = (1 << 1), fRF_Update = (1 << 2) | fCF_Overwrite, fRF_Backup = (1 << 3) | fCF_Overwrite, fRF_EqualTypes = (1 << 4),
  fRF_FollowLinks = (1 << 5), fRF_Default = 0
}
 Rename flags. More...
 
enum  EBackupMode { eBackup_Copy = (1 << 1), eBackup_Rename = (1 << 2), eBackup_Default = eBackup_Copy }
 Backup modes. More...
 
enum  EProcessingFlags {
  fEntry = (1 << 0), fDir_Self = fEntry, fDir_Files = (1 << 1), fDir_Subdirs = (1 << 2),
  fDir_Recursive = (1 << 3), fDir_All = fDir_Self + fDir_Files + fDir_Subdirs, fIgnoreMissing = (1 << 4), eOnlyEmpty = fDir_Self,
  eEntryOnly = fDir_Self, eTopDirOnly = fDir_Self | fDir_Files, eNonRecursive = fDir_All, eRecursive = fDir_All | fDir_Recursive,
  eRecursiveIgnoreMissing = eRecursive | fIgnoreMissing
}
 Entries processing flags. More...
 
enum  EType {
  eFile = 0, eDir, ePipe, eLink,
  eSymLink = eLink, eSocket, eDoor, eBlockSpecial,
  eCharSpecial, eUnknown
}
 Directory entry type. More...
 
enum  EIfAbsent { eIfAbsent_Throw, eIfAbsent_Newer, eIfAbsent_NotNewer }
 What IsNewer() should do if the dir entry does not exist or is not accessible. More...
 
enum  EIfAbsent2 {
  fHasThisNoPath_Newer = (1 << 0), fHasThisNoPath_NotNewer = (1 << 1), fNoThisHasPath_Newer = (1 << 2), fNoThisHasPath_NotNewer = (1 << 3),
  fNoThisNoPath_Newer = (1 << 4), fNoThisNoPath_NotNewer = (1 << 5)
}
 What path version of IsNewer() should do if the dir entry or specified path does not exist or is not accessible. More...
 
enum  EMode {
  fExecute = 1, fWrite = 2, fRead = 4, fDefault = 8,
  fDefaultDirUser = fRead | fExecute | fWrite, fDefaultDirGroup = fRead | fExecute, fDefaultDirOther = fRead | fExecute, fDefaultUser = fRead | fWrite,
  fDefaultGroup = fRead, fDefaultOther = fRead
}
 Directory entry access permissions. More...
 
enum  ESpecialModeBits { fSticky = 1, fSetGID = 2, fSetUID = 4 }
 
enum  EModeRelative { fModeAdd = 16, fModeRemove = 32, fModeNoChange = 64 }
 Relative permissions change modes. More...
 
enum  EModeStringFormat { eModeFormat_Octal, eModeFormat_Symbolic, eModeFormat_List, eModeFormat_Default = eModeFormat_Octal }
 Permission mode string format. More...
 
enum  ETmpFileCreationMode { eTmpFileCreate, eTmpFileGetName }
 Temporary file creation mode. More...
 
enum  ETextBinary { eText, eBinary }
 What type of temporary file to create. More...
 
enum  EAllowRead { eAllowRead, eWriteOnly }
 Which operations to allow on temporary file. More...
 
typedef unsigned int TCopyFlags
 Binary OR of "ECopyFlags". More...
 
typedef unsigned int TRenameFlags
 Binary OR of "ERenameFlags". More...
 
typedef unsigned int TProcessingFlags
 Binary OR of "EProcessingFlags". More...
 
typedef TProcessingFlags TRemoveFlags
 Flags based on TProcessingFlags. More...
 
typedef TProcessingFlags TSetModeFlags
 
typedef TRemoveFlags EDirRemoveMode
 Directory remove mode. More...
 
typedef int TIfAbsent2
 Binary OR of "EIfAbsent2". More...
 
typedef unsigned int TMode
 Bitwise OR of "EMode". More...
 
typedef unsigned int TSpecialModeBits
 Bitwise OR of ESpecialModeBits. More...
 

Public Member Functions

 CDir (void)
 Default constructor. More...
 
 CDir (const string &dirname)
 Constructor using specified directory name. More...
 
 CDir (const CDirEntry &dir)
 Copy constructor. More...
 
virtual ~CDir (void)
 Destructor. More...
 
virtual EType GetObjectType (void) const
 Get a type of constructed object. More...
 
virtual bool Exists (void) const
 Check if directory "dirname" exists. More...
 
TEntries GetEntries (const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const
 Get directory entries based on the specified "mask". More...
 
TEntries GetEntries (const vector< string > &masks, TGetEntriesFlags flags=0) const
 Get directory entries based on the specified set of "masks". More...
 
TEntries GetEntries (const CMask &masks, TGetEntriesFlags flags=0) const
 Get directory entries based on the specified set of "masks". More...
 
TEntriesGetEntriesPtr (const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const
 Get directory entries based on the specified "mask". More...
 
TEntriesGetEntriesPtr (const vector< string > &masks, TGetEntriesFlags flags=0) const
 Get directory entries based on the specified set of "masks". More...
 
TEntriesGetEntriesPtr (const CMask &masks, TGetEntriesFlags flags=0) const
 Get directory entries based on the specified set of "masks". More...
 
TEntries GetEntries (const string &mask, EGetEntriesMode mode, NStr::ECase use_case) const
 
TEntries GetEntries (const vector< string > &masks, EGetEntriesMode mode, NStr::ECase use_case) const
 
TEntries GetEntries (const CMask &masks, EGetEntriesMode mode, NStr::ECase use_case) const
 
TEntriesGetEntriesPtr (const string &mask, EGetEntriesMode mode, NStr::ECase use_case) const
 
TEntriesGetEntriesPtr (const vector< string > &masks, EGetEntriesMode mode, NStr::ECase use_case) const
 
TEntriesGetEntriesPtr (const CMask &masks, EGetEntriesMode mode, NStr::ECase use_case) const
 
bool Create (TCreateFlags flags=fCreate_Default) const
 Create the directory using "dirname" passed in the constructor. More...
 
bool CreatePath (TCreateFlags flags=fCreate_Default) const
 Create the directory path recursively possibly more than one at a time. More...
 
virtual bool Copy (const string &new_path, TCopyFlags flags=fCF_Default, size_t buf_size=0) const
 Copy directory. More...
 
virtual bool Remove (TRemoveFlags flags=eRecursive) const
 Delete existing directory. More...
 
virtual bool SetMode (TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0, TSetModeFlags flags=eEntryOnly) const
 Set permission mode(s) for a directory. More...
 
- Public Member Functions inherited from CDirEntry
 CDirEntry (void)
 Default constructor. More...
 
 CDirEntry (const string &path)
 Constructor using specified path string. More...
 
 CDirEntry (const CDirEntry &other)
 Copy constructor. More...
 
virtual ~CDirEntry (void)
 Destructor. More...
 
const stringGetPath (void) const
 Get entry path. More...
 
void Reset (const string &path)
 Reset path string. More...
 
CDirEntryoperator= (const CDirEntry &other)
 Assignment operator. More...
 
string GetDir (EIfEmptyPath mode=eIfEmptyPath_Current) const
 Get the directory component for this directory entry. More...
 
string GetName (void) const
 Get the base entry name with extension (if any). More...
 
string GetBase (void) const
 Get the base entry name without extension. More...
 
string GetExt (void) const
 Get extension name. More...
 
bool CopyToDir (const string &dir, TCopyFlags flags=fCF_Default, size_t buf_size=0) const
 Copy the entry to a specified directory. More...
 
bool Rename (const string &new_path, TRenameFlags flags=fRF_Default)
 Rename entry. More...
 
bool MoveToDir (const string &dir, TCopyFlags flags=fRF_Default)
 Move the entry to a specified directory. More...
 
bool Backup (const string &suffix=kEmptyStr, EBackupMode mode=eBackup_Default, TCopyFlags copyflags=fCF_Default, size_t copybufsize=0)
 Backup an entry. More...
 
bool Stat (struct SStat *buffer, EFollowLinks follow_links=eIgnoreLinks) const
 Get status information on a dir entry. More...
 
EType GetType (EFollowLinks follow=eIgnoreLinks) const
 Get a type of a directory entry. More...
 
bool IsFile (EFollowLinks follow=eFollowLinks) const
 Check whether a directory entry is a file. More...
 
bool IsDir (EFollowLinks follow=eFollowLinks) const
 Check whether a directory entry is a directory. More...
 
bool IsLink (void) const
 Check whether a directory entry is a symbolic link (alias). More...
 
string LookupLink (void) const
 Get an entry name that a link points to. More...
 
void DereferenceLink (ENormalizePath normalize=eNormalizePath)
 Dereference a link. More...
 
void DereferencePath (void)
 Dereference a path. More...
 
bool GetTime (CTime *modification, CTime *last_access=0, CTime *creation=0) const
 Get time stamp(s) of a directory entry. More...
 
bool GetTimeT (time_t *modification, time_t *last_access=0, time_t *creation=0) const
 Get time stamp(s) of a directory entry (time_t version). More...
 
bool SetTime (const CTime *modification=0, const CTime *last_access=0, const CTime *creation=0) const
 Set time stamp(s) of a directory entry. More...
 
bool SetTimeT (const time_t *modification=0, const time_t *last_access=0, const time_t *creation=0) const
 Set time stamp(s) of a directory entry (time_t version). More...
 
bool IsNewer (time_t tm, EIfAbsent if_absent) const
 Check if the current entry is newer than a specified date/time. More...
 
bool IsNewer (const CTime &tm, EIfAbsent if_absent) const
 Check if the current entry is newer than a specified date/time. More...
 
bool IsNewer (const string &path, TIfAbsent2 if_absent) const
 Check if the current entry is newer than some other. More...
 
bool IsIdentical (const string &entry_name, EFollowLinks follow_links=eIgnoreLinks) const
 Check if the current entry and the given entry_name are identical. More...
 
bool GetOwner (string *owner, string *group=0, EFollowLinks follow=eFollowLinks, unsigned int *uid=0, unsigned int *gid=0) const
 Get an entry owner. More...
 
bool SetOwner (const string &owner, const string &group=kEmptyStr, EFollowLinks follow=eFollowLinks, unsigned int *uid=0, unsigned int *gid=0) const
 Set an entry owner and/or group. More...
 
bool GetMode (TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0) const
 Get permission mode(s) of a directory entry. More...
 
virtual void SetDefaultMode (EType entry_type, TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0)
 Set default mode(s) for this entry only. More...
 
bool CheckAccess (TMode access_mode) const
 Check access rights. More...
 

Static Public Member Functions

static string GetHome (void)
 Get user "home" directory. More...
 
static string GetTmpDir (void)
 Get temporary directory. More...
 
static string GetAppTmpDir (void)
 Get temporary directory name for application. More...
 
static string GetCwd (void)
 Get the current working directory. More...
 
static bool SetCwd (const string &dir)
 Change the current working directory. More...
 
- Static Public Member Functions inherited from CDirEntry
static void SplitPath (const string &path, string *dir=0, string *base=0, string *ext=0)
 Split a path string into its basic components. More...
 
static void SplitPathEx (const string &path, string *disk=0, string *dir=0, string *base=0, string *ext=0)
 Split a path string into its basic components. More...
 
static string MakePath (const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)
 Assemble a path from basic components. More...
 
static char GetPathSeparator (void)
 Get path separator symbol specific for the current platform. More...
 
static bool IsPathSeparator (const char c)
 Check whether a character "c" is a path separator symbol specific for the current platform. More...
 
static string AddTrailingPathSeparator (const string &path)
 Add trailing path separator, if needed. More...
 
static string DeleteTrailingPathSeparator (const string &path)
 Delete trailing path separator, if any. More...
 
static string ConvertToOSPath (const string &path)
 Convert relative "path" on any OS to the current OS-dependent relative path. More...
 
static bool IsAbsolutePath (const string &path)
 Check if a "path" is absolute for the current OS. More...
 
static bool IsAbsolutePathEx (const string &path)
 Check if the "path" is absolute for any OS. More...
 
static string GetNearestExistingParentDir (const string &path)
 Given a path, gets the closest parent directory which actually exists. More...
 
static string CreateRelativePath (const string &path_from, const string &path_to)
 Create a relative path between two points in the file system specified by their absolute paths. More...
 
static string CreateAbsolutePath (const string &path, ERelativeToWhat rtw=eRelativeToCwd)
 Get an absolute path from some, possibly relative, path. More...
 
static string CreateAbsolutePath (const string &path, const string &rtw)
 Get an absolute path from some, possibly relative, path. More...
 
static string ConcatPath (const string &first, const string &second)
 Concatenate two parts of the path for the current OS. More...
 
static string ConcatPathEx (const string &first, const string &second)
 Concatenate two parts of the path for any OS. More...
 
static string NormalizePath (const string &path, EFollowLinks follow_links=eIgnoreLinks)
 Normalize a path. More...
 
static bool MatchesMask (const string &name, const string &mask, NStr::ECase use_case=NStr::eCase)
 Match a "name" against a simple filename "mask". More...
 
static bool MatchesMask (const string &name, const vector< string > &masks, NStr::ECase use_case=NStr::eCase)
 Match a "name" against a set of "masks" Note that any name match to empty vector of masks. More...
 
static bool MatchesMask (const string &name, const CMask &mask, NStr::ECase use_case=NStr::eCase)
 Match a "name" against a set of "masks" Note that any name match to empty set of masks. More...
 
static const char * GetBackupSuffix (void)
 Get backup suffix. More...
 
static void SetBackupSuffix (const char *suffix)
 Set backup suffix. More...
 
static CDirEntryCreateObject (EType type, const string &path=kEmptyStr)
 Construct a directory entry object of a specified type. More...
 
static EType GetType (const TNcbiSys_stat &st)
 Get a type of a directory entry by status information. More...
 
static void SetDefaultModeGlobal (EType entry_type, TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0)
 Set default permission modes globally for all CDirEntry objects. More...
 
static mode_t MakeModeT (TMode user_mode, TMode group_mode, TMode other_mode, TSpecialModeBits special)
 Construct mode_t value from permission modes. More...
 
static void ModeFromModeT (mode_t mode, TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0)
 Convert mode_t to permission mode(s). More...
 
static string ModeToString (TMode user_mode, TMode group_mode, TMode other_mode, TSpecialModeBits special, EModeStringFormat format=eModeFormat_Default)
 Convert permission modes to string representation using one of predefined formats. More...
 
static bool StringToMode (const CTempString &mode, TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0)
 Convert string (in one of predefined formats, detects automatically) to permission mode(s). More...
 
static void GetUmask (TMode *user_mode, TMode *group_mode=0, TMode *other_mode=0, TSpecialModeBits *special=0)
 Get file/directory mode creation mask. More...
 
static void SetUmask (TMode user_mode, TMode group_mode=fDefault, TMode other_mode=fDefault, TSpecialModeBits special=0)
 Set file/directory mode creation mask. More...
 
static string GetTmpName (ETmpFileCreationMode mode=eTmpFileGetName)
 Get temporary file name. More...
 
static string GetTmpNameEx (const string &dir=kEmptyStr, const string &prefix=kEmptyStr, ETmpFileCreationMode mode=eTmpFileGetName)
 Get temporary file name. More...
 
static fstream * CreateTmpFile (const string &filename=kEmptyStr, ETextBinary text_binary=eBinary, EAllowRead allow_read=eAllowRead)
 Create temporary file and return pointer to corresponding stream. More...
 
static fstream * CreateTmpFileEx (const string &dir=".", const string &prefix=kEmptyStr, ETextBinary text_binary=eBinary, EAllowRead allow_read=eAllowRead)
 Create temporary file and return pointer to corresponding stream. More...
 

Private Types

typedef CDirEntry CParent
 CDirEntry is the parent class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDirEntry
void GetDefaultMode (TMode *user_mode, TMode *group_mode, TMode *other_mode, TSpecialModeBits *special) const
 Get the default mode. More...
 
mode_t GetDefaultModeT (void) const
 
- Static Protected Member Functions inherited from CDirEntry
static void GetDefaultModeGlobal (EType entry_type, TMode *user_mode, TMode *group_mode, TMode *other_mode, TSpecialModeBits *special)
 Get the default global mode. More...
 

Detailed Description

CDir –.

Define class to work with directories.

Definition at line 1665 of file ncbifile.hpp.

Member Typedef Documentation

typedef CDirEntry CDir::CParent
private

CDirEntry is the parent class.

Definition at line 1667 of file ncbifile.hpp.

Definition at line 1848 of file ncbifile.hpp.

typedef unsigned int CDir::TCreateFlags

Binary OR of "ECreateFlags".

Definition at line 1902 of file ncbifile.hpp.

typedef list< TEntry > CDir::TEntries

Definition at line 1721 of file ncbifile.hpp.

Define a list of pointers to directory entries.

Definition at line 1720 of file ncbifile.hpp.

Binary OR of "EGetEntriesFlags".

Definition at line 1750 of file ncbifile.hpp.

Constructor & Destructor Documentation

CDir::CDir ( void  )
inline

Default constructor.

Definition at line 3986 of file ncbifile.hpp.

References CDirEntry::eDir, CDirEntry::fDefault, and CDirEntry::SetDefaultMode().

CDir::CDir ( const string dirname)
inline

Constructor using specified directory name.

Definition at line 3992 of file ncbifile.hpp.

References CDirEntry::eDir, CDirEntry::fDefault, and CDirEntry::SetDefaultMode().

CDir::CDir ( const CDirEntry dir)
inline

Copy constructor.

Definition at line 3998 of file ncbifile.hpp.

CDir::~CDir ( void  )
virtual

Destructor.

Definition at line 3671 of file ncbifile.cpp.

Member Function Documentation

bool CDir::Copy ( const string new_path,
TCopyFlags  flags = fCF_Default,
size_t  buf_size = 0 
) const
virtual
bool CDir::Create ( TCreateFlags  flags = fCreate_Default) const
bool CDir::CreatePath ( TCreateFlags  flags = fCreate_Default) const
bool CDir::Exists ( void  ) const
inlinevirtual

Check if directory "dirname" exists.

Note
CDirEntry::Exists() could be faster on some platforms, if you don't need to check that entry is a directory.

Reimplemented from CDirEntry.

Definition at line 4004 of file ncbifile.hpp.

References CDirEntry::IsDir().

Referenced by BDB_CreateEnv(), CAlignSort::CAlignSort(), CFileDBEngine::CFileDBEngine(), CGeneFileUtils::CheckDirExistence(), CFileDBEngine::CreateBlob(), CProjBulderApp::CreateCheckList(), CreateConfigurableFile(), CAgpFastaComparator::CTmpSeqVecStorage::CTmpSeqVecStorage(), CFileDBEngine::DropDB(), CFileDBEngine::GetCommands(), CFileDBEngine::HasBlob(), CSeqTestApplication::Init(), CInputStreamSource::InitFilesInDirSubtree(), CDBAPI_Cache::Open(), CBDB_Volumes::Open(), CSQLITE3_Cache::Open(), CBDB_ExtBlobStore< TBV >::Open(), CBDB_Cache::Open(), CAgpConverter::OutputOneFileForEach(), CProjBulderApp::ParseArguments(), CRepConfig::ProcessArgs(), CFileObsolete::Remove(), CRunTestApplication::Run(), CReadIndexSpeedApp::Run(), CConcatSeqEntriesApplication::Run(), CProteinMatchApp::Run(), CGffDeconcatApp::Run(), CTAbleValApp::Run(), CTbl2AsnApp::Run(), CPrimeCacheApplication::Run(), CRepConfAsndisc::Run(), s_CollectRelPathes(), s_CreateDirectories(), s_CreateThirdPartyLibsInstallMakefile(), s_EnsureDirExist(), CBDB_Env::SetLogDir(), SetLogFile(), CSplitCacheApp::SetupCache(), STmpDirGuard::STmpDirGuard(), TraverseAndRunTestCases(), CQueueDataBase::x_AppendDumpLinkedSections(), CQueueDataBase::x_BackupDump(), CQueueDataBase::x_CheckOpenPreconditions(), CQueueDataBase::x_CreateSpaceReserveFile(), CQueueDataBase::x_Dump(), CQueueDataBase::x_Open(), CDiscRepApp::x_ParseDirectory(), CQueueDataBase::x_ReadDumpQueueDesrc(), CQueueDataBase::x_RemoveBDBFiles(), CQueueDataBase::x_RemoveDump(), CRemoteAppRequest::x_RemoveWDir(), CDataLoadersUtil::x_SetupASNCacheDataLoader(), and CBDB_Cache::x_TruncateDB().

string CDir::GetAppTmpDir ( void  )
static

Get temporary directory name for application.

Return temporary directory name specified in the application's registry file or via environment. Registry file: [NCBI] TmpDir = ... Environment variable: NCBI_CONFIG__NCBI__TmpDir

If not specified, return GetTmpDir().

See also
GetTmpDir

Definition at line 3635 of file ncbifile.cpp.

References GetTmpDir(), NCBI, NCBI_PARAM_TYPE, and tmp.

Referenced by CFileIO::CreateTemporary().

string CDir::GetCwd ( void  )
static
CDir::TEntries CDir::GetEntries ( const string mask = kEmptyStr,
TGetEntriesFlags  flags = 0 
) const
CDir::TEntries CDir::GetEntries ( const vector< string > &  masks,
TGetEntriesFlags  flags = 0 
) const

Get directory entries based on the specified set of "masks".

Parameters
masksUse to select only entries that match this set of masks.
flagsFlags defines behavior and which entries to return.
Returns
A list containing all directory entries. Return empty list on error.
Note
Use fThrowOnError to avoid getting empty list on error and throwing an exception instead.

Definition at line 3810 of file ncbifile.cpp.

References auto_ptr< X >::get().

CDir::TEntries CDir::GetEntries ( const CMask masks,
TGetEntriesFlags  flags = 0 
) const

Get directory entries based on the specified set of "masks".

Parameters
maskUse to select only entries that match this set of masks.
flagsFlags defines behavior and which entries to return.
Returns
A list containing all directory entries. Return empty list on error.
Note
Use fThrowOnError to avoid getting empty list on error and throwing an exception instead.

Definition at line 3894 of file ncbifile.cpp.

References auto_ptr< X >::get().

CDir::TEntries CDir::GetEntries ( const string mask,
EGetEntriesMode  mode,
NStr::ECase  use_case 
) const
inline
Deprecated:
Use other variant of of GetEntries() instead.

Definition at line 4010 of file ncbifile.hpp.

References NStr::eNocase, fNoCase, and GetEntries().

CDir::TEntries CDir::GetEntries ( const vector< string > &  masks,
EGetEntriesMode  mode,
NStr::ECase  use_case 
) const
inline
Deprecated:
Use other variant of of GetEntries() instead.

Definition at line 4019 of file ncbifile.hpp.

References NStr::eNocase, fNoCase, and GetEntries().

CDir::TEntries CDir::GetEntries ( const CMask masks,
EGetEntriesMode  mode,
NStr::ECase  use_case 
) const
inline
Deprecated:
Use other variant of of GetEntries() instead.

Definition at line 4028 of file ncbifile.hpp.

References NStr::eNocase, fNoCase, and GetEntries().

CDir::TEntries * CDir::GetEntriesPtr ( const string mask = kEmptyStr,
TGetEntriesFlags  flags = 0 
) const

Get directory entries based on the specified "mask".

This methods are faster on big directories than GetEntries().

Parameters
maskUse to select only entries that match this mask. Do not use file mask if set to "kEmptyStr".
flagsFlags defines behavior and which entries to return.
Returns
A pointer to list of directory entries. NULL in the case of error.
Note
Do not forget to release allocated memory using return pointer.

Definition at line 3799 of file ncbifile.cpp.

References CMask::Add().

Referenced by Copy(), FindFilesInDir(), GetEntriesPtr(), SGridWorkerNodeImpl::OfflineRun(), CTAbleValApp::ProcessOneDirectory(), and CTbl2AsnApp::ProcessOneDirectory().

CDir::TEntries * CDir::GetEntriesPtr ( const vector< string > &  masks,
TGetEntriesFlags  flags = 0 
) const

Get directory entries based on the specified set of "masks".

This methods are faster on big directories than GetEntries().

Parameters
maskUse to select only entries that match this set of masks.
flagsFlags defines behavior and which entries to return.
Returns
A pointer to list of directory entries. NULL in the case of error.
Note
Do not forget to release allocated memory using return pointer.

Definition at line 3818 of file ncbifile.cpp.

References _T_CSTRING, _T_XCSTRING, CDirEntry::AddTrailingPathSeparator(), DIR_CURRENT, NStr::eCase, CDirEntry::eFile, NStr::eNocase, F_ISSET, CDirEntry::GetPath(), NWinHook::HANDLE(), IS_RECURSIVE_ENTRY, ITERATE, kEmptyStr, mask, CDirEntry::MatchesMask(), NCBI_THROW, NULL, s_AddEntry(), s_SetFindFileError(), and string.

CDir::TEntries * CDir::GetEntriesPtr ( const CMask masks,
TGetEntriesFlags  flags = 0 
) const

Get directory entries based on the specified set of "masks".

This methods are faster on big directories than GetEntries().

Parameters
maskUse to select only entries that match this set of masks.
flagsFlags defines behavior and which entries to return.
Returns
A pointer to list of directory entries. NULL in the case of error.
Note
Do not forget to release allocated memory using return pointer.

Definition at line 3902 of file ncbifile.cpp.

References _T_CSTRING, _T_XCSTRING, CDirEntry::AddTrailingPathSeparator(), DIR_CURRENT, NStr::eCase, CDirEntry::eFile, NStr::eNocase, F_ISSET, CDirEntry::GetPath(), NWinHook::HANDLE(), IS_RECURSIVE_ENTRY, CMask::Match(), NCBI_THROW, NULL, s_AddEntry(), and s_SetFindFileError().

CDir::TEntries * CDir::GetEntriesPtr ( const string mask,
EGetEntriesMode  mode,
NStr::ECase  use_case 
) const
inline
Deprecated:
Use other variant of of GetEntries() instead.

Definition at line 4037 of file ncbifile.hpp.

References NStr::eNocase, fNoCase, and GetEntriesPtr().

CDir::TEntries * CDir::GetEntriesPtr ( const vector< string > &  masks,
EGetEntriesMode  mode,
NStr::ECase  use_case 
) const
inline
Deprecated:
Use other variant of of GetEntries() instead.

Definition at line 4046 of file ncbifile.hpp.

References NStr::eNocase, fNoCase, and GetEntriesPtr().

CDir::TEntries * CDir::GetEntriesPtr ( const CMask masks,
EGetEntriesMode  mode,
NStr::ECase  use_case 
) const
inline
Deprecated:
Use other variant of of GetEntries() instead.

Definition at line 4055 of file ncbifile.hpp.

References NStr::eNocase, fNoCase, and GetEntriesPtr().

string CDir::GetHome ( void  )
static
virtual EType CDir::GetObjectType ( void  ) const
inlinevirtual

Get a type of constructed object.

Reimplemented from CDirEntry.

Definition at line 1683 of file ncbifile.hpp.

References CDirEntry::eDir.

string CDir::GetTmpDir ( void  )
static

Get temporary directory.

Return temporary directory name specified by OS via environment variables.

See also
GetAppTmpDir

Definition at line 3599 of file ncbifile.cpp.

References _T_CSTRING, _TX, GetHome(), NcbiSys_getenv, and tmp.

Referenced by CPIDGuard::CPIDGuard(), GetAppTmpDir(), and CAgpFastaComparator::CTmpSeqVecStorage::x_GetTmpDir().

bool CDir::Remove ( TRemoveFlags  flags = eRecursive) const
virtual

Delete existing directory.

Parameters
flagsDirectory processing flags. Some popular sets of flags combined together and listed below:
  • eOnlyEmpty directory can be removed only if it is empty;
  • eTopDirOnly remove all files in the top directory only, no any subdirectory or files in it;
  • eNonRecursive same as eTopDirOnly, but removes also empty subdirectories in the top directory only;
  • eRecursive remove all files in directory and all its subdirectories;
  • eRecursiveIgnoreMissing same as eRecursive, but do not report an error for missed entries.
Returns
TRUE if operation successful; FALSE otherwise.
See also
CDirEntry::Remove, EProcessingFlags

Reimplemented from CDirEntry.

Definition at line 4254 of file ncbifile.cpp.

References _ASSERT, _T_XCSTRING, eIgnoreLinks, CDirEntry::eOnlyEmpty, errno, f(), CDirEntry::fDir_All, CDirEntry::fDir_Recursive, CDirEntry::fDir_Self, CDirEntry::fDir_Subdirs, CDirEntry::fEntry, CDirEntry::fIgnoreMissing, CDirEntry::fModeAdd, CDirEntry::fModeNoChange, CDirEntry::fWrite, auto_ptr< X >::get(), CDirEntry::GetPath(), CDirEntry::GetPathSeparator(), CDirEntry::IsDir(), ITERATE, LOG_ERROR_AND_RETURN_ERRNO, NcbiSys_rmdir, CDirEntry::Remove(), and CDirEntry::SetMode().

Referenced by BDB_CreateEnv(), Copy(), CFileDBEngine::DropDB(), CBDB_Cache::Open(), CDirEntry::Remove(), CSeqAnnotSplicerApp::Run(), CQueueDataBase::x_Open(), CQueueDataBase::x_RemoveDump(), CRemoteAppRequest::x_RemoveWDir(), and STmpDirGuard::~STmpDirGuard().

bool CDir::SetCwd ( const string dir)
static

Change the current working directory.

Definition at line 3658 of file ncbifile.cpp.

References _T_XCSTRING, LOG_ERROR_AND_RETURN_ERRNO, and NcbiSys_chdir.

bool CDir::SetMode ( TMode  user_mode,
TMode  group_mode = fDefault,
TMode  other_mode = fDefault,
TSpecialModeBits  special = 0,
TSetModeFlags  flags = eEntryOnly 
) const
virtual

Set permission mode(s) for a directory.

Permissions are set as specified by the passed values for user_mode, group_mode and other_mode. This method rewrites each user/group/other/special permission by default.

Note
Adding one of the EModeRelative flags to mode change default behavior that replace modes with passed values and allow for relative mode change for any of user/group/other/special. It is possible to keep it as is, or add/remove some permission modes specified in parameters.
Passing "fDefault" will cause the corresponding mode to be taken and set from its default setting.
Parameters
flagsDirectory processing flags. Some popular sets of flags combined together and listed below:
  • eEntryOnly change modes for the directory entry itself;
  • eTopDirOnly change modes for all files in the top directory only, no for any subdirectory or files in it;
  • eNonRecursive change modes for all entries in the top directory only, including subdirectory entries, but do not for any files in them;
  • eRecursive change modes for all files and subdirectories recursively;
  • eRecursiveIgnoreMissing same as eRecursive, but do not report an error for missed entries.
Returns
TRUE if permissions successfully set for all entries; FALSE, otherwise.
See also
SetMode, SetDefaultMode, SetDefaultModeGlobal, EMode, EModeRelative, EProcessingFlags

Reimplemented from CDirEntry.

Definition at line 4335 of file ncbifile.cpp.

References _ASSERT, CDirEntry::eEntryOnly, eIgnoreLinks, f(), CDirEntry::fDir_All, CDirEntry::fDir_Recursive, CDirEntry::fDir_Self, CDirEntry::fDir_Subdirs, CDirEntry::fEntry, auto_ptr< X >::get(), CDirEntry::GetPath(), CDirEntry::GetPathSeparator(), CDirEntry::IsDir(), ITERATE, LOG_ERROR_AND_RETURN_ERRNO, and CDirEntry::SetMode().

Referenced by Copy(), and CDirEntry::SetMode().


The documentation for this class was generated from the following files:
Modified on Sat Apr 22 17:05:30 2017 by modify_doxy.py rev. 533848