Logo
~Sockets~
~Examples~
~Contact~


Utility::Path Class Reference

#include <Utility.h>

List of all members.


Public Member Functions

 Path (const std::string &)
const std::string & GetPath () const
const std::string & GetFilename () const
const std::string & GetExtension () const

Private Attributes

std::string m_path
std::string m_file
std::string m_ext

Detailed Description

Definition at line 110 of file Utility.h.


Constructor & Destructor Documentation

Utility::Path::Path ( const std::string &  _str  ) 

Definition at line 1234 of file Utility.cpp.

References m_ext, m_file, and m_path.

01235 {
01236         std::string str = _str;
01237         for (size_t i = 0; i < str.size(); ++i)
01238         {
01239 #ifdef _WIN32
01240                 if (str[i] == '/')
01241                         str[i] = '\\';
01242 #else
01243                 if (str[i] == '\\')
01244                         str[i] = '/';
01245 #endif
01246         }
01247 #ifndef _WIN32
01248         struct stat st;
01249         stat(str.c_str(), &st);
01250         if (S_ISDIR(st.st_mode))
01251         {
01252                 m_path = str;
01253                 return;
01254         }
01255 #endif
01256         size_t x = 0;
01257         for (size_t i = 0; i < str.size(); ++i)
01258                 if (str[i] == '/' || str[i] == '\\')
01259                         x = i + 1;
01260         m_path = str.substr(0, x);
01261         m_file = str.substr(x);
01262         for (size_t i = 0; i < m_file.size(); ++i)
01263                 if (m_file[i] == '.')
01264                         m_ext = m_file.substr(i + 1);
01265 }


Member Function Documentation

const std::string& Utility::Path::GetPath (  )  const [inline]

Definition at line 115 of file Utility.h.

Referenced by Utility::ChangeDirectory().

00115 { return m_path; }

const std::string& Utility::Path::GetFilename (  )  const [inline]

Definition at line 116 of file Utility.h.

00116 { return m_file; }

const std::string& Utility::Path::GetExtension (  )  const [inline]

Definition at line 117 of file Utility.h.

00117 { return m_ext; }


Member Data Documentation

std::string Utility::Path::m_path [private]

Definition at line 120 of file Utility.h.

Referenced by Path().

std::string Utility::Path::m_file [private]

Definition at line 121 of file Utility.h.

Referenced by Path().

std::string Utility::Path::m_ext [private]

Definition at line 122 of file Utility.h.

Referenced by Path().


The documentation for this class was generated from the following files:
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4