Ignore:
Timestamp:
Apr 28, 2018, 4:35:04 PM (13 months ago)
Author:
cameron
Message:

Handling of file system errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/grep/grep_engine.cpp

    r5998 r5999  
    583583//  differently based on the engine type.
    584584
     585bool canMMap(const std::string & fileName) {
     586    if (fileName == "-") return false;
     587    namespace fs = boost::filesystem;
     588    fs::path p(fileName);
     589    boost::system::error_code errc;
     590    fs::file_status s = fs::status(p, errc);
     591    return !errc && is_regular_file(s);
     592}
     593
     594
    585595uint64_t GrepEngine::doGrep(const std::string & fileName, std::ostringstream & strm) {
    586596    typedef uint64_t (*GrepFunctionType)(bool useMMap, int32_t fileDescriptor, intptr_t callback_addr);
    587     using namespace boost::filesystem;
    588     path p(fileName);
    589     bool useMMap = mPreferMMap;
    590     if (p == "-") useMMap = false;
    591     if (!is_regular_file(p)) useMMap = false;
     597    bool useMMap = mPreferMMap && canMMap(fileName);
    592598
    593599    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
     
    634640uint64_t EmitMatchesEngine::doGrep(const std::string & fileName, std::ostringstream & strm) {
    635641    typedef uint64_t (*GrepFunctionType)(bool useMMap, int32_t fileDescriptor, intptr_t accum_addr);
    636     using namespace boost::filesystem;
    637     path p(fileName);
    638     bool useMMap = mPreferMMap;
    639     if (p == "-") useMMap = false;
    640     if (!is_regular_file(p)) useMMap = false;
     642    bool useMMap = mPreferMMap && canMMap(fileName);
    641643    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
    642644    int32_t fileDescriptor = openFile(fileName, strm);
Note: See TracChangeset for help on using the changeset viewer.