Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:43:28+00:00 2026-05-26T02:43:28+00:00

I have some code that iterates through files in a directory and does useful

  • 0

I have some code that iterates through files in a directory and does useful things with the non-directory files, like so:

namespace bfs = boost::filesystem;
for (bfs::directory_iterator iterDir(m_inPath); 
     bContinue && iterDir!=bfs::directory_iterator(); iterDir++)
{
    std::string filename = iterDir->path().filename().string();
    boost::to_lower(filename);

    if (!bfs::is_directory(*iterDir) && Condition2(filename)) {
        std::ifstream ifFile(iterDir->path().string().c_str());
        DoUsefulThings(iterDir());
    }
}

This works fine in my unit tests, but when I run the full program as a service, my test directories (seemingly erroneously) get past the !bfs::is_directory check and DoUsefulThings‘s ifstream.good() check fails, with an errno of 13.

I tried changing !bfs::is_directory to bfs::is_regular_file (thinking that maybe there was a system condition causing it to be something else), but I got the same results. The is_regular_file condition fails on the directory in my unit test but passes when run as a service.

I also added a try/catch around my if statement to see if it was throwing an exception and verified that it wasn’t (probably could use one anyway, but didn’t help with this).

I considered that the problem could be related to the service’s permissions level, so I changed the properties of the service to log on as the same account that I use to log in to that system. Same result. I’ve dabbled with PerformanceMonitor some as well to try to get some clues there, but I haven’t gleaned much from it yet.

Can someone suggest why this might be happening? Errno=13 == “permission denied”, right? Is there an additional check I need to perform before calling is_directory?

I’m using Windows XP, Visual Studio 2008/C++, version 1.44 of the Boost library, and version 3 of filesystem.

ETA: I added the following to test the directory manually (the direction of the slash marks didn’t make a difference), and is_regular_file behaves as expected:

std::string strDir = "D:/Dir1/Dir2/Dir3/Dir4/Dir5\\Dir6";
if (bfs::is_regular_file(strDir))
    LOG("It's a regular file"); //This does not get executed
else
    LOG("Not a regular file");  //This does

I have log statements printing out both *iterDir and iterDir->path() and they both match the one I put in manually. Does this rule out permissions issues? Will continue testing, as this result doesn’t really make sense to me yet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:43:28+00:00Added an answer on May 26, 2026 at 2:43 am

    Bah. It was a bug in my “Condition2”. Thanks for the help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that iterates through 'Documents' in couchDB for docid in db:
I have some code that pulls database primary keys and iterates through them by
I have some code that iterates over a non-generic IDictionary by first calling the
I have some code that raises PropertyChanged events and I would like to be
I have some code that looks like: template<unsigned int A, unsigned int B> int
I have some code that effectively does this : File file = new File(C:\\Program
So I have some perl code that goes something like: use strict; use XML::XPath;
I have some code that gives a user id to a utility that then
I have some code that uses the shared gateway pattern to implement an inversion
I have some code that generates image of a pie chart. It's a general

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.