mirror of
https://github.com/znc/znc.git
synced 2026-08-08 01:43:03 +02:00
Clean up FileUtils.h
This removes some commented out functions and it also removes CFir::Exists() since CFile::IsDir() does exactly the same job (and it uses fewer syscalls for that). git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1042 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
-73
@@ -163,17 +163,6 @@ public:
|
||||
return FillByWildcard(sDir, "*");
|
||||
}
|
||||
|
||||
/*void Sort(CFile::EFileAttr eSortAttr, bool bDesc = false) {
|
||||
m_eSortAttr = eSortAttr;
|
||||
m_bDesc = bDesc;
|
||||
sort(begin(), end(), TPtrCmp<CFile>);
|
||||
}*/
|
||||
|
||||
static bool Exists(const CString& sDir) {
|
||||
CFile cFile(sDir);
|
||||
return (cFile.Exists()) && (cFile.IsDir());
|
||||
}
|
||||
|
||||
/* static bool Create(const CString& sDir, mode_t mode = 0755) {
|
||||
VCCString vSubDirs = sDir.split("[/\\\\]+");
|
||||
CCString sCurDir;
|
||||
@@ -277,68 +266,6 @@ public:
|
||||
CFile::EFileAttr GetSortAttr() { return m_eSortAttr; }
|
||||
bool IsDescending() { return m_bDesc; }
|
||||
|
||||
/* static bool MkDir(const CString & sPath, mode_t iMode, bool bBuildParents = false, bool bApplyModToParents = false) {
|
||||
if (sPath.empty()) {
|
||||
WARN("empty path!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bBuildParents) { // only building target
|
||||
mode_t uMask = umask(0000);
|
||||
int iRet = mkdir(sPath.c_str(), iMode);
|
||||
umask(uMask);
|
||||
|
||||
if (iRet != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VCCString vPath = sPath.TrimRight_n("/").split("/+");
|
||||
|
||||
if (vPath.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sPath[0] == '/');
|
||||
vPath[0] = "/" + vPath[0];
|
||||
|
||||
CCString sCurDir = GetCWD();
|
||||
|
||||
mode_t uMask = 0000;
|
||||
if (bApplyModToParents) {
|
||||
uMask = umask(0000);
|
||||
}
|
||||
|
||||
for (unsigned int a = 0; a < (vPath.size() - 1); a++) {
|
||||
if ((mkdir(vPath[a].c_str(), iMode) != 0) && (errno != EEXIST)) {
|
||||
if (bApplyModToParents) {
|
||||
umask(uMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (chdir(vPath[a].c_str()) != 0) {
|
||||
chdir(sCurDir.c_str());
|
||||
if (bApplyModToParents) {
|
||||
umask(uMask);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bApplyModToParents) {
|
||||
uMask = umask(0000);
|
||||
}
|
||||
|
||||
int iRet = mkdir(vPath[vPath.size() - 1].c_str(), iMode);
|
||||
umask(uMask);
|
||||
chdir(sCurDir.c_str());
|
||||
return (iRet == 0);
|
||||
}*/
|
||||
|
||||
static CString GetCWD() {
|
||||
CString sRet;
|
||||
char * pszCurDir = getcwd(NULL, 0);
|
||||
|
||||
@@ -222,7 +222,7 @@ CString CWebAdminSock::GetSkinDir() {
|
||||
CString sSkinDir = m_pModule->GetModDataDir() + "/skins/"
|
||||
+ m_pModule->GetSkinName() + "/";
|
||||
|
||||
if (CDir::Exists(sSkinDir)) {
|
||||
if (CFile::IsDir(sSkinDir)) {
|
||||
return sSkinDir;
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ bool CWebAdminSock::SettingsPage(CString& sPageRet) {
|
||||
|
||||
CString sDir(GetSkinDir() + "/..");
|
||||
|
||||
if (CDir::Exists(sDir)) {
|
||||
if (CFile::IsDir(sDir)) {
|
||||
CDir Dir(sDir);
|
||||
|
||||
m_Template.AddRow("SkinLoop")["Name"] = "default";
|
||||
|
||||
Reference in New Issue
Block a user