开发者

Qt ,C++ - Adding QDIR::Filters to directories and files

I am trying to retrieve the files and directories in Qt using the QDir Filter. Based on the user input from the command line I plan to set the appropriate filters and retrieve the corresponding files.

User Input Eg: ./Retrieve -d C:/Sample -h

would retrieve me all the files including hidden files in the directory C:/Sample. I plan to give a host of other options like

-h (for hidden files开发者_运维百科) -r (for readonly files) -s (for system files)

currently my code is something like

QDir::entryList(QDir::Dirs |QDir::NoDotAndDotDot | QDir::Hidden)

If I want to fetch even the system files I need to add just the Qdir::system filter . How can I append this to the existing filters I would have already mentioned. My question is How do I add these filters to the QDir function entry List by having simple online code but build up the filters by looking at the user input?


It's a three step process:

  1. Define the flags that are the same regardless of user input, call it filters or something.
  2. Iterate over the command line arguments and, when certain arguments are found, do a logical-OR of the appropriate QDir::Filter flag with filters
  3. Keep going until all the cmdline arguments are dealt with.

filters now has all the filters the user requested.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜