From 9db44ab1fe5fe09cc325bb22b5d7b4335f908ac9 Mon Sep 17 00:00:00 2001 From: prozacx Date: Fri, 1 Jul 2005 18:50:53 +0000 Subject: [PATCH] Added SetFileName() git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@401 726aef4b-f618-498e-8847-2d620e286838 --- FileUtils.cpp | 28 ++++++++++++++-------------- FileUtils.h | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/FileUtils.cpp b/FileUtils.cpp index d3f09f30..bf9cfd4f 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -1,20 +1,7 @@ #include "FileUtils.h" CFile::CFile(const CString& sLongName) { - m_sLongName = sLongName; - m_iFD = -1; - - m_sShortName = sLongName; - - // @todo shouldn't this be Right() and RightChomp() ?! - while (m_sShortName.Left(1) == "/") { - m_sShortName.LeftChomp(); - } - - CString::size_type uPos = m_sShortName.rfind('/'); - if (uPos != CString::npos) { - m_sShortName = m_sShortName.substr(uPos +1); - } + SetFileName(sLongName); } CFile::~CFile() { @@ -23,6 +10,19 @@ CFile::~CFile() { } } +void CFile::SetFileName(const CString& sLongName) { + m_sLongName = sLongName; + m_iFD = -1; + + m_sShortName = sLongName; + m_sShortName.RightTrim("/"); + + CString::size_type uPos = m_sShortName.rfind('/'); + if (uPos != CString::npos) { + m_sShortName = m_sShortName.substr(uPos +1); + } +} + bool CFile::IsReg(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_REGULAR, bUseLstat); } bool CFile::IsDir(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_DIRECTORY, bUseLstat); } bool CFile::IsChr(const CString& sLongName, bool bUseLstat) { return CFile::FType(sLongName, FT_CHARACTER, bUseLstat); } diff --git a/FileUtils.h b/FileUtils.h index ec70b88f..0e27674c 100644 --- a/FileUtils.h +++ b/FileUtils.h @@ -33,6 +33,7 @@ public: FT_SOCK }; + void SetFileName(const CString& sLongName); static bool IsReg(const CString& sLongName, bool bUseLstat = false); static bool IsDir(const CString& sLongName, bool bUseLstat = false); static bool IsChr(const CString& sLongName, bool bUseLstat = false);