1

我正在用 c/c++ 设计一个快速文件读取程序,它将按照存储(创建)的顺序检索目录中的每个文件。我使用 SFML 和 BOOST,但我的程序只会以随机顺序返回文件。我想这与文件的 b-tree 排序有关吗?如何让 BOOST 按创建顺序返回文件?

这是代码的相关部分:

#include <string>
#include <iostream>
#include <boost/filesystem.hpp>
#include "SFML/Graphics.hpp"
using std::cout;
using namespace boost::filesystem;
using namespace std;
....
path p (argv[1]);
....
for (directory_entry& x : directory_iterator(p)){
  ....
  fullPathName = x.path().string();
  filename = x.path().filename().string();
  stem = x.path().stem().string();  
  seqnum = stem.substr(4,5);
  extn = x.path().extension().string();

  cout << fullPathName << ", " << filename << ", " << stem << ", " <<
    seqnum << ", " << extn <<'\n'; 
}

这是一个示例输出:

../takes/test/snap00179.png, snap00179.png, snap00179, 00179, .png ../takes/test/snap00321.png, snap00321.png, snap00321, 00321, .png ../takes/test/snap00094 .png, snap00094.png, snap00094, 00094, .png ../takes/test/snap00121.png, snap00121.png, snap00121, 00121, .png ../takes/test/snap00026.png, snap00026.png, snap00026 , 00026, .png ../takes/test/snap00024.png, snap00024.png, snap00024, 00024, .png ../takes/test/snap00155.png, snap00155.png, snap00155, 00155, .png ../需要/测试/snap00065.png, snap00065.png, snap00065, 00065, .png ../takes/test/snap00015.png, snap00015.png, snap00015, 00015, .png ../takes/test/snap00075.png, snap00075.png、snap00075、00075、.png ../takes/test/snap00017.png、snap00017.png、snap00017、00017、.png

4

0 回答 0