Skip to content

Can not iterate through directory entries on Android #72

@alexeikh

Description

@alexeikh

Prerequisites

  • Android device with Android OS below 6.0, for example Samsung Galaxy S6 with Android 5.0.2. The issue should be reproducible on Android Emulator as well.
  • Android NDK with enabled Unified Headers, for example version r16b
  • Compiler: Clang (shouldn't be important)
  • STL: GNU STL (shouldn't be important)
  • Selected (minimum) Android API level: 14 (shouldn't be important)

How to reproduce

Compile the following sample code as Android executable.

#include <boost/filesystem.hpp>
#include <iostream>

int main() {
    namespace fs = boost::filesystem;

    fs::directory_iterator iter("/data/local/tmp");
    for (const fs::path& p: iter)
        std::cout << "Directory entry found: " << p.c_str() << std::endl;

    return 0;
}

Copy the resulting executable to the device and run it:

adb push libs/armeabi-v7a/sample-cmdline-app /data/local/tmp/
adb shell /data/local/tmp/sample-cmdline-app

Expected behavior

All directory entries are listed, for example:

Directory entry found: /data/local/tmp/sample-cmdline-app
Directory entry found: /data/local/tmp/some-another-file.txt

Actual behavior

boost::filesystem::filesystem_error is thrown on the second iteration of the loop:

Directory entry found: /data/local/tmp/sample-cmdline-app
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::directory_iterator::operator++: Function not implemented: "/data/local/tmp"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions