📄 wardirfmtunixls.h
字号:
/** */#ifndef WAR_DIRFMT_UNIX_LS_H#define WAR_DIRFMT_UNIX_LS_H/* SYSTEM INCLUDES */#ifndef WAR_INCLUDED_LIMITS_H# define WAR_INCLUDED_LIMITS_H# include <limits.h>#endif/* PROJECT INCLUDES */#ifndef WAR_SVR_DIRLIST_H# include "WarSvrDirList.h"#endif#ifndef WAR_GETOPT_H# include "WarGetopt.h"#endif#ifndef WAR_ESCAPE_STR_H# include "WarEscapeStr.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********/#ifndef INODE_DIGITS# define INODE_DIGITS 7#endif#ifndef S_IRUSR# define S_IRWXU 00700 // mask for user (file owner) permissions# define S_IRUSR 00400 //user has read permission# define S_IWUSR 00200 //user has write permission# define S_IXUSR 00100 //user has execute permission# define S_IRWXG 00070 //mask for group permissions# define S_IRGRP 00040 //group has read permission# define S_IWGRP 00020 //group has write permission# define S_IXGRP 00010 //group has execute permission# define S_IRWXO 00007 //mask for permissions for others (not in group)# define S_IROTH 00004 //others have read permission# define S_IWOTH 00002 //others have write permisson# define S_IXOTH 00001 //others have execute permission# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)#endif // S_IRUSR#ifndef S_ISSOCK# define S_ISSOCK(a) (0)#endif#ifndef S_ISDOOR# define S_ISDOOR(a) (0)#endif#define WAR_ISREG(a) (a.mType == WarDirListNode::FT_NORMAL)#define WAR_ISDIR(a) (a.mType == WarDirListNode::FT_DIR)#define WAR_ISLNK(a) (a.mType == WarDirListNode::FT_LINK)#define WAR_ISFIFO(a) (a.mType == WarDirListNode::FT_SPECIAL)#define WAR_ISSOCK(a) S_ISSOCK(a.mMode)#define WAR_ISDOOR(a) S_ISDOOR(a.mMode)/****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplustemplate <class outputT>class WarDirfmtUnixLs : public WarFileEnums{public: typedef std::list<std::string> seq_file_list_t; typedef std::list<std::string> ignore_patterns_t; /// enum format { /// -l (el) LONG_FORMAT, /// -1 (one) ONE_PER_LINE, /// -C MANY_PER_LINE, /// -x HORIZONTAL, /// -m WITH_COMMAS }; /// enum sort_type { /// -U SORT_NONE, /// default SORT_NAME, /// -X SORT_EXTENSION, /// -t SORT_TIME, /// -S SORT_SIZE, /// -v SORT_VERSION }; /// enum time_type { /// default TIME_MTIME, /// -c TIME_CTIME, /// -u TIME_ATIME }; enum indicator_style { /// --indicator-style=none IS_NONE, /// -F, --indicator-style=classify IS_CLASSIFY, /// -p, --indicator-style=file-type IS_FILE_TYPE }; // LIFECYCLE /** Constructor */ WarDirfmtUnixLs(); /// virtual ~WarDirfmtUnixLs(); // OPERATORS //* Interface to \Ref{WarDirListing}. */ outputT& List (outputT& Out, const WarSvrDirList& Dir); /** Parse a unix 'ls' command line. */ void ParseArgs(int argc, char **argv, seq_file_list_t& List); /** Outputs to mErrorMessage and throws */ void Usage() throw (WarException); // OPERATIONS void InvalidPath(const std::string& path); // ACCESS // INQUIRY /// Export flags to WarSvrDirListing int ExportFlags(); void ExportExcludelist(WarDirList::patterns_t& excludeList); /**@name Options, normally set via arguments to ParseArgs() Since some arguments applies for the scannig process as well, they may have to be passed on to \Ref{WarDirList} before the directory is scanned. */ //@{ /// bool mDoPrintBlockSize; /// bool mDoPrintInodes; /// print for each node bool mDoPrintBlockSizeAll; /// bool mDoNumericIds; /// bool mDoHideGroup; /// bool mDoFullTime; /// bool mDoAllFiles; /// bool mDoReallyAllFiles; /// bool mDoRecursive; /// bool mDoPrintDirName; /// bool mDoImmediateDirs; /// bool mDoQmarkFunnyChars; /// bool mDoReverseSort; /// bool mDoTraceLinks; /// format mListFormat; /// sort_type mSortBy; /// time_type mTimeType; /// indicator_style mIndicatorStyle; /// ignore_patterns_t mIgnorePatterns; /// Keeps the sequence used to terminate a line char mEndOfLine[4]; /// int mOutputBlockSize; /// bool mDoQuoteNames; //@} /// Returns error information if Usage() is called, or \Ref{List} fails. std::string mErrorMessage; protected: const WarDirList *mpDir;private: //template <class outputT> void DoNameSort(outputT& Out, const WarDirList& Dir); void DoOtherSort(outputT& Out, const WarDirList& Dir); void OutNode(outputT& Out, const WarDirListNode& Node); void OutShort(outputT& Out, const WarDirListNode& Node); void OutNameAndStuff(outputT& Out, const WarDirListNode& Node); void OutQuotedName(outputT& Out, const WarDirListNode& Node); void OutLong(outputT& Out, const WarDirListNode& Node); void OutLength(outputT& Out, const WarDirListNode& Node); void OutHumanDigit(outputT& Out, const war_flen_t value, size_t colWidth); void OutInode(outputT& Out, const WarDirListNode& Node); void OutBlocksize(outputT& Out, const WarDirListNode& Node); void OutLinks(outputT& Out, const WarDirListNode& Node); void OutMode(outputT& Out, const WarDirListNode& Node); void OutDate(outputT& Out, const WarDirListNode& Node);};/* INLINE METHODS *//* EXTERNAL REFERENCES */#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif /* WAR_DIRFMT_UNIX_LS_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -