📄 warsvrdirlisting.h
字号:
/** This is the glue that combines the directory listing classes with output-formatting, and enables recursive listings.*/#ifndef WAR_SVR_DIR_LISTING_H#define WAR_SVR_DIR_LISTING_H/* SYSTEM INCLUDES *//* PROJECT INCLUDES */#ifndef WAR_SVR_DIRLIST_H# include "WarSvrDirList.h"#endif#ifndef WAR_DIRFMT_UNIX_LS_H# include "WarDirfmtUnixLs.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplustemplate <class fmtT, class outputT>class WarSvrDirListing : public WarFileEnums{public: typedef std::list<std::string> pathlist_t; typedef std::set<std::string> pathset_t; // LIFECYCLE /** Constructor @param fmtIface Formatting class. */ WarSvrDirListing(fmtT& fmtIface, outputT& outIface, const war_uint32_t flags, const WarSvrProtocol& currentServer) : mFlags(flags), mrCurrentServer(currentServer), mrFmtIface(fmtIface), mrOutIface(outIface) { // Inherit flags mFlags |= mrFmtIface.ExportFlags(); } // OPERATORS // OPERATIONS void Create(war_ccstr_t dirPath) { size_t recurse_level = 0; if (mFlags & DIRF_RECURSIVE) { if (!mrCurrentServer.GetBoolOption("ftpd_RECURSIVE")) WarThrow(WarError(WAR_FERR_RECURSIVE_LISTINGS_FORBIDDEN), NULL); } if (dirPath) Push(dirPath); for(; !mPendingPaths.empty(); Pop(), recurse_level++) { { WarSvrDirList my_list(mFlags, mrCurrentServer); mrFmtIface.ExportExcludelist(my_list.mExcludeList); if (recurse_level) mFlags &= ~DIRF_TRY_SAFE_PATTERNS; // Only the first time! try { my_list.Create(mPendingPaths.front().c_str()); } catch(WarException& e) { if (e.LocalError() == WAR_ERR_INVALID_PATH) throw e; if (e.LocalError() == WAR_FERR_NO_SUCH_PATH) mrFmtIface.InvalidPath(mPendingPaths.front()); continue; } mrFmtIface.List(mrOutIface, my_list); if (mFlags & DIRF_RECURSIVE) { for(WarSvrDirList::nodelist_t::const_iterator P = my_list.mList.begin() ; P != my_list.mList.end() ; P++) { if (WarDirListNode::FT_DIR == P->Data().mType) { war_ccstr_t p = P->Data().mName; if ((p[0] == '.') && (!p[1] || ((p[1] == '.') && !p[2]))) { continue; } WarPath<char> my_path; my_path << my_list.GetSvrPath().GetAlias().GetPath() << WAR_SLASH << p; Push(my_path.GetPath()); } } } } } } void Push(war_ccstr_t dirPath) { pathset_t::const_iterator P = mBlacklist.find(std::string(dirPath)); if (P == mBlacklist.end()) mPendingPaths.push_back(dirPath); } void Pop() { if (!mPendingPaths.empty()) { mBlacklist.insert(mPendingPaths.front()); mPendingPaths.pop_front(); } } // ACCESS // INQUIRY protected: war_uint32_t mFlags; const WarSvrProtocol& mrCurrentServer; fmtT& mrFmtIface; outputT& mrOutIface; pathlist_t mPendingPaths; // Paths to process pathset_t mBlacklist; // Paths we ignore. Processed // paths end up here to prevent infinite loopsprivate:};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_SVR_DIR_LISTING_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -