📄 warsvrdirlist.cpp
字号:
#include "StdAfx.h"#include "WarSvrDirList.h" // class implemented#ifndef WAR_LOG_H# include "WarLog.h"#endif#ifndef WAR_SVR_PROTOCOL_H# include "WarSvrProtocol.h"#endif#ifndef WAR_FSYS_H# include "WarFsys.h"#endifusing namespace std;/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarSvrDirList::WarSvrDirList(const war_uint32_t flags, const WarSvrProtocol& currentServer, bool doVerifyForList) : WarDirList(flags), mrCurrentServer(currentServer), mDoVerifyForList(doVerifyForList){}//============================= OPERATORS ====================================//============================= OPERATIONS ===================================void WarSvrDirList::Create(war_ccstr_t dirPath) throw (WarException){ // Resolve the path war_svrpath_t dir_path_buf; mrCurrentServer.ResolvPath(dirPath, mResolvedPath); // Check permissions if (mDoVerifyForList) mResolvedPath.VerifyList(); // Add patterns to the pattern-list if they exist. if (mFlags & DIRF_TRY_SAFE_PATTERNS) { bool found_pattern =false; for(war_svrpath_ccstr_t p = mResolvedPath.GetAlias().GetPath() ; *p ; p++) { if ((*p == '?') || (*p == '*') || (*p == '[')) found_pattern = true; else if (war_svrpath_t::IsSlash(*p)) { if (found_pattern) WarThrow(WarError(WAR_ERR_INVALID_PATH), NULL); } } if (found_pattern) { dir_path_buf = mResolvedPath.GetAlias().GetPathname(); mPatternList.push_front(mResolvedPath.GetAlias().GetFilename()); Create(WarUtf8(dir_path_buf.GetPath()).GetUtf8().c_str()); return; } } // Set the relative path war_svrpath_ccstr_t my_cwd = mrCurrentServer.GetCwd().GetAlias().GetPath(), p = my_cwd; war_svrpath_ccstr_t my_path = mResolvedPath.GetAlias().GetPath(), pp = my_path; while(*p && (*p == *pp)) { ++pp; ++p; } if (*p) { while((p > my_cwd) && !war_svrpath_t::IsSlash(*p)) { --p; --pp; } } if (pp) mRelativePath << WAR_CDIR << pp; else mRelativePath = mResolvedPath.GetAlias().GetPath(); // Handle file WarFileDriver::driver_ptr_t driver_ptr = WarFileEngine::GetEngine().GetDriver( mResolvedPath.GetUrl().GetDriverName().c_str()); war_stat_t st; try { driver_ptr->WarStat(mResolvedPath.GetUrl(), st); } catch(WarException& ex) { if (ex.LocalError() == WAR_FERR_NO_SUCH_PATH) throw ex; } if ((st.st_mode & S_IFREG) == S_IFREG) { if (!IsFileExcluded(mResolvedPath.GetAlias().GetFilename().GetPath())) AddFile(mResolvedPath.GetAlias().GetFilename().GetPath(), &st); return; } // Handle directory // Add mount points from the server properties! AddMountPoints(mResolvedPath); // Scan the physical directory try { ScanDir(mResolvedPath.GetUrl()); } catch(WarException& e) { // Empty dirs are ok. if (e.LocalError() != WAR_FERR_NO_SUCH_PATH) throw e; }}void WarSvrDirList::AddMountPoints(const WarSvrPath& SvrPath) throw (WarException){ const WarSvrProperties& my_properties = mrCurrentServer.GetProperties(); // Find the paths that origin to the selected path for(WarSvrProperties::path_set_t::const_iterator P = my_properties.mPaths.begin() ; P != my_properties.mPaths.end() ; P++) { const WarSvrPath& my_path = *P; if (my_path.IsPartOfPath(SvrPath.GetAlias())) { war_svrpath_ccstr_t p = my_path.GetAlias().GetPath() + SvrPath.GetAlias().GetLength(); if (my_path.GetAlias().IsSlash(*p)) ++p; war_svrpath_t my_fragment; while(*p && !my_path.GetAlias().IsSlash(*p)) my_fragment << *p++; if (my_path.GetAlias().IsSlash(*p)) ++p; /* If the path is just a node on a virtual path to a lower level, we can ignore it. *pp will be == 0 if this is a complete virtual node. */ if ((0 == *p) && !my_fragment.IsEmpty()) { war_stat_t my_stat; try { WarFsysStat(my_path.GetUrl(), my_stat); } catch(WarException& e) { WarLog warn_log(WARLOG_WARNINGS, "WarSvrDirList::AddMountPoints()"); if (warn_log) { warn_log << "Failed to stat mount-point directory \"" << my_path << "\". Reason: " << e.Explain() << war_endl; } continue; } if (IsFileExcluded(my_path.GetAlias().GetFilename().GetPath())) continue; AddFile(my_path.GetAlias().GetFilename().GetPath(), &my_stat); /*if (my_path.GetPerms() & HIDE_ALL) { pNew->m_Type = WarDirListNode::FT_HIDDEN_VDIR; m_CntHidden++; } else if (pNew->m_NameLen > m_LongestName) m_LongestName = pNew->m_NameLen; */ } } }}//============================= ACCESS ===================================//============================= INQUIRY ===================================/////////////////////////////// PROTECTED ////////////////////////////////////////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -