Public Member Functions | Static Private Attributes | Friends

cmn_Path Class Reference
[G_new_group]

#include <cmn_Path.h>

List of all members.

Public Member Functions

 cmn_Path ()
 cmn_Path (const char *a_path)
 cmn_Path (const string &a_path)
 cmn_Path (const cmn_Path &a_path)
virtual ~cmn_Path ()
void operator= (const string &s)
void operator+= (const string &s)
void operator= (const char *s)
void operator+= (const char *s)
cmn_Path UpPath () const
void Split (const UInt32_t a_level, cmn_Path &a_left, cmn_Path &a_right) const
 Split the path into left and right from the path seperator at at a specified level.
string GetFileName () const
void OnlyFileName ()
bool IsEmpty () const
void HostPathSeparator ()
 change path separator regarding to host usage unix-win win-unix
bool IsAbsolute () const
cmn_Path GetAbsolutePathName (void) const
void RemoveTrailingPathSeparator ()
bool Contains (const cmn_Path &a_path) const
bool IsPathOnMountPoint (const cmn_Path &a_mountPoint) const

Static Private Attributes

static const string m_pathSeparatorStr = string(1, PATH_SEPARATOR)
static const char m_wrongPathSeparatorChar = WRONG_PATH_SEPARATOR

Friends

cmn_Path IVD_CMN_DECL_d operator+ (const cmn_Path &, const string &s)
cmn_Path IVD_CMN_DECL_d operator+ (const cmn_Path &, const char *s)

Detailed Description

Definition at line 53 of file cmn_Path.h.


Constructor & Destructor Documentation

cmn_Path::cmn_Path (  )  [inline]

Definition at line 56 of file cmn_Path.h.

Referenced by GetAbsolutePathName(), Split(), and UpPath().

: string() {};

Here is the caller graph for this function:

cmn_Path::cmn_Path ( const char *  a_path  ) 

Definition at line 68 of file cmn_Path.cpp.

                                      : string (a_path) {
// fix bug 587    CheckPathSeparator();
}

cmn_Path::cmn_Path ( const string &  a_path  ) 

Definition at line 72 of file cmn_Path.cpp.

                                       : string (a_path) {
// fix bug 587    CheckPathSeparator();
}

cmn_Path::cmn_Path ( const cmn_Path a_path  )  [inline]

Definition at line 59 of file cmn_Path.h.

: string (a_path) {};

cmn_Path::~cmn_Path (  )  [virtual]

Definition at line 76 of file cmn_Path.cpp.

                    {
    // Empty
}


Member Function Documentation

bool cmn_Path::Contains ( const cmn_Path a_path  )  const

Definition at line 286 of file cmn_Path.cpp.

References cmn_StrLowerCase(), file, ie_INVALID_ARG, IsAbsolute(), ivd_Error, and PATH_SEPARATOR.

Referenced by ClientConf_t::GetCollocationId(), and ClientConf_t::GetHostnameAndPort().

                                                    {

    if (a_path.IsAbsolute() != this->IsAbsolute()) {
        throw ivd_Error(ie_INVALID_ARG, "One path is absolute, the other is not.");
    }

    if (this->length() < a_path.length()) {
        return false;
    }

    // Is path separator on correct place
    if (  (this->length() == a_path.length())
        ||(this->at(a_path.length()) == PATH_SEPARATOR)) {
        cmn_Path file(*this);
        cmn_Path dir(a_path);
#if TGT_OS_windows
        cmn_StrLowerCase(file);
        cmn_StrLowerCase(dir);
#endif
        if (file.compare(0, dir.length(), dir) == 0) {
            return true;
        }
    }
    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

cmn_Path cmn_Path::GetAbsolutePathName ( void   )  const

Definition at line 230 of file cmn_Path.cpp.

References cmn_GetCurrentDir(), cmn_LocaleToUTF8(), cmn_Path(), IsAbsolute(), and PATH_SEPARATOR.

Referenced by _tmain(), FileName2IPCFileList(), FileName2IPCStringList(), InputFile2IPCFileList(), ivd_AccessFsAttr(), api_Partition::LocalPath2HSM(), and mif_CfgRep::Upload().

                                                 {
    if (IsAbsolute()) {
        return (*this);
    }
    else {
        if (   length() > 1
            && at(0) == '.'
            && at(1) == PATH_SEPARATOR) {
            return cmn_Path(cmn_LocaleToUTF8(cmn_GetCurrentDir())) + substr(2);
        }
        else {
            return cmn_Path(cmn_LocaleToUTF8(cmn_GetCurrentDir())) + (*this);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string cmn_Path::GetFileName (  )  const
void cmn_Path::HostPathSeparator (  ) 

change path separator regarding to host usage unix-win win-unix

Definition at line 80 of file cmn_Path.cpp.

References m_pathSeparatorStr, and m_wrongPathSeparatorChar.

Referenced by fsc_FileExpiration::GetExpirationAge(), ClientConf_t::Init(), fsc_FileExpiration::SetExpirationAge(), and val_Path::Validate().

                                 {

    string::size_type pos = string::find(m_wrongPathSeparatorChar);
    while (pos != string::npos) {
        replace(pos, 1, m_pathSeparatorStr);
        pos = rfind(m_wrongPathSeparatorChar);
    }
}

Here is the caller graph for this function:

bool cmn_Path::IsAbsolute (  )  const

Definition at line 220 of file cmn_Path.cpp.

References PATH_SEPARATOR.

Referenced by _tmain(), cmn_FileNameToLong(), Contains(), GetAbsolutePathName(), IsPathOnMountPoint(), main(), Restore(), and log_Debugger::SetFileName().

                                {

    if ((length() != 0) && (at(0) == PATH_SEPARATOR)) {
        return true;
    }
    else {
        return false;
    }
}

Here is the caller graph for this function:

bool cmn_Path::IsEmpty (  )  const [inline]

Definition at line 85 of file cmn_Path.h.

Referenced by bea_FRIThread::bea_FRIThread().

                                {
        return length() == 0;
    }

Here is the caller graph for this function:

bool cmn_Path::IsPathOnMountPoint ( const cmn_Path a_mountPoint  )  const

Definition at line 312 of file cmn_Path.cpp.

References cmn_StrLowerCase(), dbg_DETAIL, ie_INVALID_ARG, IsAbsolute(), ivd_Error, log_DBG_m, log_FUNC_m, RemoveTrailingPathSeparator(), and UpPath().

Referenced by i_ManagementInterface_i::SetCollocationInfo(), and i_ManagementInterface_i::SetHl7Info().

                                                                    {
    log_FUNC_m(IsPathOnMountPoint);

    if (a_mountPoint.IsAbsolute() != this->IsAbsolute()) {
        throw ivd_Error(ie_INVALID_ARG, "One path is absolute, the other is not.");
    }

    if (this->length() < a_mountPoint.length()) {
        return false;
    }

    cmn_Path dir(*this);
    cmn_Path mountPoint(a_mountPoint);
    dir.RemoveTrailingPathSeparator();
    mountPoint.RemoveTrailingPathSeparator();

#if TGT_OS_windows
    cmn_StrLowerCase(dir);
    cmn_StrLowerCase(mountPoint);
#endif

    // request on mountpoint
    if (dir.compare(mountPoint) == 0) {
        log_DBG_m(dbg_DETAIL, "Request on mountPoint.");
        return false;
    }

    if (dir.UpPath().compare(mountPoint) == 0) {
        return true;
    }

    return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cmn_Path::OnlyFileName (  ) 

Definition at line 204 of file cmn_Path.cpp.

References PATH_SEPARATOR.

Referenced by mif_CfgRep::SetLastRevNum().

                            {
    size_t pos = find_last_of(PATH_SEPARATOR);
    if (pos != string::npos) {
        pos ++;
        *this = substr(pos);
    }
}

Here is the caller graph for this function:

void cmn_Path::operator+= ( const char *  s  ) 

Definition at line 141 of file cmn_Path.cpp.

References PATH_SEPARATOR.

                                       {

    if (  (length() == 0)
       || (at(length() - 1) != PATH_SEPARATOR)) {
        string::append(1, PATH_SEPARATOR);
        string::append(s);
    }
    else {
        string::append(s);
    }

    return ;
}

void cmn_Path::operator+= ( const string &  s  ) 

Definition at line 94 of file cmn_Path.cpp.

References PATH_SEPARATOR.

                                         {

    if (  (length() == 0)
       || (at(length() - 1) != PATH_SEPARATOR)) {
        string::operator+=(PATH_SEPARATOR);
        string::operator+=(s);
    }
    else {
        string::operator+=(s);
    }

    return ;
}

void cmn_Path::operator= ( const string &  s  ) 

Definition at line 89 of file cmn_Path.cpp.

                                          {
    string::operator=(s);
    return;
}

void cmn_Path::operator= ( const char *  s  ) 

Definition at line 136 of file cmn_Path.cpp.

                                       {
    string::assign(s);
    return;
}

void cmn_Path::RemoveTrailingPathSeparator (  ) 
void cmn_Path::Split ( const UInt32_t  a_level,
cmn_Path a_left,
cmn_Path a_right 
) const

Split the path into left and right from the path seperator at at a specified level.

level=0 is the first occurance of the path seperator (usualy root) example: cmn_Path p("/A/B/C/D"); p.Split(2, left, right) will have in left "/A/B" and in right="C/D"

Definition at line 181 of file cmn_Path.cpp.

References cmn_Path(), and PATH_SEPARATOR.

Referenced by hsm_FileHeader::GetGidCidInfo().

                                                                                      {

    string::size_type pos(0);
    pos=this->find(PATH_SEPARATOR);
    for (UInt32_t i = 0; i < a_level; i++){
        if (pos == string::npos) {
            a_right = cmn_Path("");
            a_left = cmn_Path("");
            return;
        }
        pos=this->find(PATH_SEPARATOR, pos+1);
    }
    a_left = this->substr(0,pos); //left from seperator
    a_right = this->substr(pos+1); //right from seperator
}

Here is the call graph for this function:

Here is the caller graph for this function:

cmn_Path cmn_Path::UpPath (  )  const

Definition at line 171 of file cmn_Path.cpp.

References cmn_Path(), and PATH_SEPARATOR.

Referenced by cmn_CreatePathNoException(), cmn_IsMounted(), hsm_IVDFSRecoverer::CreateParentDir(), fsc_MedVolReader::fsc_MedVolReader(), fsc_MedVolWriter::fsc_MedVolWriter(), hsm_HL7CacheFile::HandleCoruptedFile(), hsmGetDirFH(), hsmGetFH(), IsPathOnMountPoint(), ivd_GetMountPoint(), i_HSM_i::MigrateByAPI(), log_Debugger::On(), hsm_FileHeader::QueueHL7Message(), Restore(), UnpackFile(), and blk_DiskBufferWriter::Write().

                                {
    string::size_type pos = find_last_of(PATH_SEPARATOR, length());
    if (pos == string::npos) {
        return cmn_Path("");
    }
    else {
        return cmn_Path(substr(0, pos));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

cmn_Path IVD_CMN_DECL_d operator+ ( const cmn_Path path,
const string &  s 
) [friend]

Definition at line 109 of file cmn_Path.cpp.

                                                          {

    if (path.length() == 0) {
        return s;
    }
    if (s.length() == 0) {
        return path;
    }

    string str(path);
    if (path.at(path.length() - 1) != PATH_SEPARATOR) {
        if (s.at(0) == PATH_SEPARATOR) {
            return str += s;
        }
        else {
            return (str += cmn_Path::m_pathSeparatorStr) += s;
        }
    }
    else {
        if (s.at(0) == PATH_SEPARATOR) {
            str.resize(str.length() - 1);
        }
        return str += s;
    }
}

cmn_Path IVD_CMN_DECL_d operator+ ( const cmn_Path path,
const char *  s 
) [friend]

Definition at line 156 of file cmn_Path.cpp.

                                                        {

    if (path.length() == 0) {
        return cmn_Path(s);
    };

    string str(path);
    if (path.at(path.length() - 1) != PATH_SEPARATOR) {
        return (str += cmn_Path::m_pathSeparatorStr) += s;
    }
    else {
        return str += s;
    }
}


Member Data Documentation

const string cmn_Path::m_pathSeparatorStr = string(1, PATH_SEPARATOR) [static, private]

Definition at line 107 of file cmn_Path.h.

Referenced by HostPathSeparator(), and operator+().

const char cmn_Path::m_wrongPathSeparatorChar = WRONG_PATH_SEPARATOR [static, private]

Definition at line 108 of file cmn_Path.h.

Referenced by HostPathSeparator().


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