贝贝花花包包店,精品555皮具,钱夹,皮夹

字体:  

跨平台目录遍历问题

qiying668 发表于: 2008-3-25 11:17 来源: ACE 开发者

最新需要实现跨平台目录遍历的功能,在windows下可以使用FindFirstFileEx、FindNextFile等函数,ACE提供的opendir_emulation、readdir_emulation函数族与Windows的FindFirstFileEx、FindNextFile功能是一致的;但是据说在ACE的4.3版本都还没有支持目录遍历跨平台的封装,我现在用的是ACE5.6版,不知道这个版本是否实现了目录遍历跨平台的封装,麻烦高人指点!
另外,谁由跨平台的目录遍历的代码,能否共享出来看看啊,谢谢

最新回复

qiying668 at 2008-3-27 14:06:41
竟然没有一个人会的?
qiying668 at 2008-3-27 18:23:43
顶起来
真的没人了么?
peakzhang at 2008-3-28 18:13:11
自己去查看一下代码就知道了。除非用过,否则大家没法回答这类问题啊。
qiying668 at 2008-4-02 10:22:34
csfreebird at 2008-9-26 23:36:27
#pragma once
#include <boost/filesystem/operations.hpp>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;
using namespace boost;

class FileHelper
{
public:
        static bool findFile(filesystem::path const& dirPath,std::string const& fileName,filesystem::path & pathFound )
        {
                if ( !exists( dirPath ) )
                        return false;
                filesystem::directory_iterator end_itr; // default construction yields past-the-end
                for (filesystem::directory_iterator itr( dirPath );itr != end_itr;++itr )
                {
                        if (filesystem::is_directory(itr->status()) )
                        {
                                if (findFile( itr->path(), fileName, pathFound ) )
                                        return true;
                        }
                        else if ( itr->path().leaf() == fileName ) // see below
                        {
                                pathFound = itr->path();
                                return true;
                        }
                }
                return false;
        }