• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pathExists函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pathExists函数的典型用法代码示例。如果您正苦于以下问题:C++ pathExists函数的具体用法?C++ pathExists怎么用?C++ pathExists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pathExists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pathExists

bool pathExists(std::string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
    // if start == end, maze is solved
    if (sr == er && sc == ec)
        return true;

    // marked as visited
    maze[sr][sc] = 'A';

    //NORTH
    if ((sr > 0) && (maze[sr-1][sc] == '.'))
        if (pathExists(maze, nRows, nCols, sr-1, sc, er, ec))
            return true;

    //EAST
    if ((sc < nCols-1) && (maze[sr][sc+1] == '.'))
        if (pathExists(maze, nRows, nCols, sr, sc+1, er, ec))
            return true;

    //SOUTH
    if ((sr < nRows-1) && (maze[sr+1][sc] == '.'))
        if (pathExists(maze, nRows, nCols, sr+1, sc, er, ec))
            return true;

    //WEST
    if ((sr < nCols-1) && (maze[sr][sc-1] == '.'))
        if (pathExists(maze, nRows, nCols, sr, sc-1, er, ec))
            return true;

    return false;
}
开发者ID:wenlongx,项目名称:UCLA_CS,代码行数:31,代码来源:maze.cpp


示例2: path

void MachOLinkingContext::addFrameworkSearchDir(StringRef fwPath,
        bool isSystemPath) {
    bool pathAdded = false;

    // -syslibroot only used with to absolute framework search paths.
    if (fwPath.startswith("/")) {
        for (auto syslibRoot : _syslibRoots) {
            SmallString<256> path(syslibRoot);
            llvm::sys::path::append(path, fwPath);
            if (pathExists(path)) {
                _frameworkDirs.push_back(path.str().copy(_allocator));
                pathAdded = true;
            }
        }
    }
    // If fwPath found in any -syslibroot, then done.
    if (pathAdded)
        return;

    // If only one -syslibroot, system paths not in that SDK are suppressed.
    if (isSystemPath && (_syslibRoots.size() == 1))
        return;

    // Only use raw fwPath if that directory exists.
    if (pathExists(fwPath))
        _frameworkDirs.push_back(fwPath);
}
开发者ID:lamproae,项目名称:lld,代码行数:27,代码来源:MachOLinkingContext.cpp


示例3: make_error_code

ErrorOr<StringRef>
MachOLinkingContext::searchDirForLibrary(StringRef path,
                                         StringRef libName) const {
  SmallString<256> fullPath;
  if (libName.endswith(".o")) {
    // A request ending in .o is special: just search for the file directly.
    fullPath.assign(path);
    llvm::sys::path::append(fullPath, libName);
    if (pathExists(fullPath))
      return fullPath.str().copy(_allocator);
    return make_error_code(llvm::errc::no_such_file_or_directory);
  }

  // Search for dynamic library
  fullPath.assign(path);
  llvm::sys::path::append(fullPath, Twine("lib") + libName + ".dylib");
  if (pathExists(fullPath))
    return fullPath.str().copy(_allocator);

  // If not, try for a static library
  fullPath.assign(path);
  llvm::sys::path::append(fullPath, Twine("lib") + libName + ".a");
  if (pathExists(fullPath))
    return fullPath.str().copy(_allocator);

  return make_error_code(llvm::errc::no_such_file_or_directory);
}
开发者ID:compnerd,项目名称:lld,代码行数:27,代码来源:MachOLinkingContext.cpp


示例4: searchLibrary

MachODylibFile* MachOLinkingContext::findIndirectDylib(StringRef path) {
    // See if already loaded.
    auto pos = _pathToDylibMap.find(path);
    if (pos != _pathToDylibMap.end())
        return pos->second;

    // Search -L paths if of the form "libXXX.dylib"
    std::pair<StringRef, StringRef> split = path.rsplit('/');
    StringRef leafName = split.second;
    if (leafName.startswith("lib") && leafName.endswith(".dylib")) {
        // FIXME: Need to enhance searchLibrary() to only look for .dylib
        auto libPath = searchLibrary(leafName);
        if (!libPath.getError()) {
            return loadIndirectDylib(libPath.get());
        }
    }

    // Try full path with sysroot.
    for (StringRef sysPath : _syslibRoots) {
        SmallString<256> fullPath;
        fullPath.assign(sysPath);
        llvm::sys::path::append(fullPath, path);
        if (pathExists(fullPath))
            return loadIndirectDylib(fullPath);
    }

    // Try full path.
    if (pathExists(path)) {
        return loadIndirectDylib(path);
    }

    return nullptr;
}
开发者ID:lamproae,项目名称:lld,代码行数:33,代码来源:MachOLinkingContext.cpp


示例5: _path

    std::string ToolchainItem::colorStr(std::string const& _var) const
    {
      if (!library()) return std::string();

      if (!valid())
      {
        std::string _path(std::string("invalid_") + _var);
        if (!pathExists(_path))
        { 
          return (_var != "light") ? "#e74c3c" : "#6b2018"; 
        } else
        {
          return library()->config().get<std::string>(tbd::ConfigPath("colorset") / tbd::ConfigPath(_path));
        }
      }

      auto& _cfg = library()->config();
      tbd::ConfigPath _toolsetId(elementId().toolset().str());
      tbd::ConfigPath _typeId(elementId().typeId().str());
      tbd::ConfigPath _path = _toolsetId / _typeId / tbd::ConfigPath(_var);

      std::cout << _path.dump() << std::endl;
      if (pathExists(_path.dump()))
      {
        return _cfg.get<std::string>(ConfigPath("colorset") /_path);
      } 
      _path =  _toolsetId / tbd::ConfigPath(_var); 
      if (pathExists(_path.dump()))
      {
        return _cfg.get<std::string>(ConfigPath("colorset") /_path);
      }
      return (_var != "light") ? "#405959" : "#9ed8db"; 
    }
开发者ID:WilstonOreo,项目名称:Tomo,代码行数:33,代码来源:ToolchainItem.cpp


示例6: THROW_EXCEPTION

//============================================================================
// FUNCTION : SPELLutils::fileCopy
//============================================================================
void SPELLutils::copyFile( const std::string& sourcePath, const std::string& targetPath )
{
	if (!pathExists(sourcePath))
	{
		THROW_EXCEPTION("Cannot copy file", "File not found: " + sourcePath, SPELL_ERROR_FILESYSTEM);
	}
	if (!pathExists( basePath( targetPath )))
	{
		THROW_EXCEPTION("Cannot copy file", "Target directory not found: " + basePath(targetPath), SPELL_ERROR_FILESYSTEM);
	}
	std::ifstream infile( sourcePath.c_str() , std::ios_base::binary);
	std::ofstream outfile( targetPath.c_str(), std::ios_base::binary);
	outfile << infile.rdbuf();
	outfile.flush();
	outfile.close();
}
开发者ID:Spacecraft-Code,项目名称:SPELL,代码行数:19,代码来源:SPELLutils.C


示例7: throw

/**
 * Depending on the operating system, kicks off the generation of the class
 * and library paths. Returns these as a pair.
 * 
 * @return The classpath and library path to use when starting the JVM
 */
pair<string,string> Runtime::generatePaths() throw( HLA::RTIinternalError )
{
	// Check for the presence of RTI_HOME
	// RTI_HOME *has* to be set. No two ways about it. Fail out if this isn't the case.
	// We make all inferences about path locations based off it, give it to us!
	char *rtihome = getenv( "RTI_HOME" );
	if( !rtihome )
	{
		logger->fatal( "RTI_HOME not set: this is *REQUIRED* to point to your Portico directory" );
		throw HLA::RTIinternalError( "RTI_HOME not set: this *must* point to your Portico directory" );
	}
	else
	{
		// check to make sure it is set to a valid location
		if( pathExists(string(rtihome)) == false )
		{
			logger->fatal( "RTI_HOME doesn't exist: this is *REQUIRED* to point to your Portico directory" );
			logger->fatal( "RTI_HOME set to [%s]", rtihome );
			throw HLA::RTIinternalError( "RTI_HOME set to directory that doesn't exist" );
		}
	}

	// Get the class and library paths depending on the platform in use
	#ifdef _WIN32
		return generateWinPath( string(rtihome) );
	#else
		return generateUnixPath( string(rtihome) );
	#endif
}
开发者ID:alvabai,项目名称:portico,代码行数:35,代码来源:Runtime.cpp


示例8: readFile

Status readFile(const boost::filesystem::path& path, std::string& content) {
  auto path_exists = pathExists(path);
  if (!path_exists.ok()) {
    return path_exists;
  }

  int statusCode = 0;
  std::string statusMessage = "OK";
  std::stringstream buffer;

  fs::ifstream file_h(path);
  if (file_h.is_open()) {
    buffer << file_h.rdbuf();

    if (file_h.bad()) {
      statusCode = 1;
      statusMessage = "Could not read file";
    } else 
      content.assign(std::move(buffer.str()));
      
  } else {
    statusCode = 1;
    statusMessage = "Could not open file for reading";
  }
  return Status(statusCode, statusMessage);
}
开发者ID:LlsDimple,项目名称:osquery,代码行数:26,代码来源:filesystem.cpp


示例9: createPidFile

Status createPidFile() {
  // check if pidfile exists
  auto exists = pathExists(FLAGS_pidfile);
  if (exists.ok()) {
    // if it exists, check if that pid is running.
    std::string content;
    auto read_status = readFile(FLAGS_pidfile, content);
    if (!read_status.ok()) {
      return Status(1, "Could not read pidfile: " + read_status.toString());
    }

    auto stale_status = checkStalePid(content);
    if (!stale_status.ok()) {
      return stale_status;
    }
  }

  // Now the pidfile is either the wrong pid or the pid is not running.
  try {
    boost::filesystem::remove(FLAGS_pidfile);
  } catch (boost::filesystem::filesystem_error& e) {
    // Unable to remove old pidfile.
    LOG(WARNING) << "Unable to remove the osqueryd pidfile";
  }

  // If no pidfile exists or the existing pid was stale, write, log, and run.
  auto pid = boost::lexical_cast<std::string>(getpid());
  LOG(INFO) << "Writing osqueryd pid (" << pid << ") to " << FLAGS_pidfile;
  auto status = writeTextFile(FLAGS_pidfile, pid, 0644);
  return status;
}
开发者ID:aalness,项目名称:osquery,代码行数:31,代码来源:system.cpp


示例10: createPidFile

Status createPidFile() {
  // check if pidfile exists
  auto pidfile_path = fs::path(FLAGS_pidfile).make_preferred();

  if (pathExists(pidfile_path).ok()) {
    // if it exists, check if that pid is running.
    std::string content;
    auto read_status = readFile(pidfile_path, content, true);
    if (!read_status.ok()) {
      return Status(1, "Could not read pidfile: " + read_status.toString());
    }

    auto stale_status = checkStalePid(content);
    if (!stale_status.ok()) {
      return stale_status;
    }
  }

  // Now the pidfile is either the wrong pid or the pid is not running.
  try {
    boost::filesystem::remove(pidfile_path);
  } catch (const boost::filesystem::filesystem_error& /* e */) {
    // Unable to remove old pidfile.
    LOG(WARNING) << "Unable to remove the osqueryd pidfile";
  }

  // If no pidfile exists or the existing pid was stale, write, log, and run.
  auto pid = boost::lexical_cast<std::string>(
      PlatformProcess::getCurrentProcess()->pid());
  VLOG(1) << "Writing osqueryd pid (" << pid << ") to "
          << pidfile_path.string();
  auto status = writeTextFile(pidfile_path, pid, 0644);
  return status;
}
开发者ID:friedbutter,项目名称:osquery,代码行数:34,代码来源:system.cpp


示例11: SetUp

 void SetUp() {
   socket_path = kTestManagerSocket + std::to_string(rand());
   remove(socket_path);
   if (pathExists(socket_path).ok()) {
     throw std::domain_error("Cannot test sockets: " + socket_path);
   }
 }
开发者ID:dotnetstation,项目名称:osquery,代码行数:7,代码来源:extensions_tests.cpp


示例12: genBrowserPlugin

void genBrowserPlugin(const std::string& uid,
                      const std::string& path,
                      QueryData& results,
                      bool is_disabled = false) {
  Row r;
  pt::ptree tree;

  r["uid"] = uid;
  auto info_path = path + "/Contents/Info.plist";
  // Ensure that what we're processing is actually a plug-in.
  if (!pathExists(info_path)) {
    return;
  }
  if (osquery::parsePlist(info_path, tree).ok()) {
    // Plugin did not include an Info.plist, or it was invalid
    for (const auto& it : kBrowserPluginKeys) {
      r[it.second] = tree.get(it.first, "");

      // Convert bool-types to an integer.
      jsonBoolAsInt(r[it.second]);
    }
  }

  if (r.count("native") == 0 || r.at("native").size() == 0) {
    // The default case for native execution is false.
    r["native"] = "0";
  }
  r["path"] = path;
  r["disabled"] = (is_disabled) ? "1" : "0";
  results.push_back(std::move(r));
}
开发者ID:ArchieBitcoin,项目名称:osquery,代码行数:31,代码来源:browser_plugins.cpp


示例13: genSafariExtensions

QueryData genSafariExtensions(QueryContext& context) {
  QueryData results;

  // Iterate over each user
  auto users = usersFromContext(context);
  for (const auto& row : users) {
    if (row.count("uid") > 0 && row.count("directory") > 0) {
      auto dir = fs::path(row.at("directory")) / kSafariExtensionsPath;
      // Check that an extensions directory exists.
      if (!pathExists(dir).ok()) {
        continue;
      }

      // Glob the extension files.
      std::vector<std::string> paths;
      if (!resolveFilePattern(dir / kSafariExtensionsPattern, paths).ok()) {
        continue;
      }

      for (const auto& extension_path : paths) {
        genSafariExtension(row.at("uid"), extension_path, results);
      }
    }
  }

  return results;
}
开发者ID:ArchieBitcoin,项目名称:osquery,代码行数:27,代码来源:browser_plugins.cpp


示例14: genSuidBinsFromPath

void genSuidBinsFromPath(const std::string& path, QueryData& results) {
  if (!pathExists(path).ok()) {
    // Creating an iterator on a missing path will except.
    return;
  }

  auto it = fs::recursive_directory_iterator(fs::path(path));
  fs::recursive_directory_iterator end;
  while (it != end) {
    fs::path path = *it;
    try {
      // Do not traverse symlinked directories.
      if (fs::is_directory(path) && fs::is_symlink(path)) {
        it.no_push();
      }

      int perms = it.status().permissions();
      if (isSuidBin(path, perms)) {
        // Only emit suid bins.
        genBin(path, perms, results);
      }

      ++it;
    } catch (fs::filesystem_error& e) {
      VLOG(1) << "Cannot read binary from " << path;
      it.no_push();
      // Try to recover, otherwise break.
      try { ++it; } catch(fs::filesystem_error& e) { break; }
    }
  }
}
开发者ID:151706061,项目名称:osquery,代码行数:31,代码来源:suid_bin.cpp


示例15: getBluetoothSharingStatus

int getBluetoothSharingStatus() {
  auto users = SQL::selectAllFrom("users");
  for (const auto& row : users) {
    if (row.count("uid") > 0 && row.count("directory") > 0) {
      auto dir = fs::path(row.at("directory")) / kRemoteBluetoothSharingPath;
      if (!pathExists(dir).ok()) {
        continue;
      }
      std::vector<std::string> paths;
      if (!resolveFilePattern(dir / kRemoteBluetoothSharingPattern, paths)
               .ok()) {
        continue;
      }

      for (const auto& bluetoothSharing_path : paths) {
        auto bluetoothSharingStatus =
            SQL::selectAllFrom("plist", "path", EQUALS, bluetoothSharing_path);
        if (bluetoothSharingStatus.empty()) {
          continue;
        }
        for (const auto& r : bluetoothSharingStatus) {
          if (r.find("key") == row.end() || row.find("value") == r.end()) {
            continue;
          }
          if (r.at("key") == "PrefKeyServicesEnabled" &&
              r.at("value") == INTEGER(1)) {
            return 1;
          }
        }
      }
    }
  }
  return 0;
}
开发者ID:FritzX6,项目名称:osquery,代码行数:34,代码来源:sharing_preferences.cpp


示例16: deleteFile

//============================================================================
// FUNCTION:    SPELLutils::deleteFile
//============================================================================
void SPELLutils::deleteFile( const std::string& file )
{
	if (pathExists(file) && isFile(file))
	{
		::remove( file.c_str() );
	}
}
开发者ID:Spacecraft-Code,项目名称:SPELL,代码行数:10,代码来源:SPELLutils.C


示例17: makeInputDefFileIfNotExist

void makeInputDefFileIfNotExist( void )
{
	char *path = INPUTDEF_PATH;
	if ( ! pathExists( path ) ) {
		FILE *fp = fopen( path, "w" );
		if ( fp ) {	
			fputs( "\
# MV input definitions.\n\
# http://mv.dinglisch.net/userguide.html#id\n\
#\n\
TPS(FR) e l f  0 otv-fr 8 epg .dat otid:2e18h-1:0:1:5dd:2e18:b0:820000:0:0:0:\n\
EnigmaCache c u f 0 - 0 - - -\n\
SavedCache s u f 7200 ec-save 5 epg .dat -\n\
NordicTEAM e l r -7200 nordicteam 7 tv- .dat http://mv.nordicteam.com/\n\
Dinglisch(EU) e l r 0 dinglisch-eu 3 tv- .dat http://mv.dinglisch.net/data/e\n\
KULICHIKI e u r -18000 kul-rus 2 kul_ .dat http://www.twinline.net/tv/\n\
Wolf(NL) x u r 0 wolf-nl 4 tv- .xmltv http://wolf.xs4all.nl/xmltv/\n\
MyXMLTV x u f 0 myxmltv 4 tv .xmltv -\n", fp );

// WARNING: if you change MyXMLTV name, need to change
// the warning text in inputdefreader.cpp too

			fclose( fp );
		}
		else {
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:25,代码来源:inputdefreader.cpp


示例18: SetUp

 void SetUp() {
   socket_path = kTestWorkingDirectory + "test.em" + std::to_string(rand());
   remove(socket_path);
   if (pathExists(socket_path).ok()) {
     throw std::domain_error("Cannot test sockets: " + socket_path);
   }
 }
开发者ID:CHERRISHGRY,项目名称:osquery,代码行数:7,代码来源:extensions_tests.cpp


示例19: extractUdifChecksum

std::string DiskArbitrationEventPublisher::extractUdifChecksum(
    const std::string& path_str) {
  fs::path path = path_str;
  if (!pathExists(path).ok() || !isReadable(path).ok()) {
    return "";
  }

  boost::system::error_code ec;
  if (!fs::is_regular_file(path, ec) || ec.value() != errc::success) {
    return "";
  }

  // The koly trailer (footer) is 512 bytes
  // http://newosxbook.com/DMG.html
  if (fs::file_size(path) < 512) {
    return "";
  }

  std::ifstream dmg_file(path_str, std::ios::binary);
  if (dmg_file.is_open()) {
    dmg_file.seekg(-512L, std::ios::end);

    char* buffer = new char[4];
    dmg_file.read(buffer, 4);
    std::string koly_signature;
    koly_signature.assign(buffer, 4);
    delete[] buffer;

    // check for valid signature
    if (koly_signature != "koly") {
      dmg_file.close();
      return "";
    }

    uint32_t checksum_size;
    dmg_file.seekg(-156L, std::ios::end);
    dmg_file.read((char*)&checksum_size, sizeof(checksum_size));
    // checksum_size is in big endian and we need to byte swap
    checksum_size = CFSwapInt32(checksum_size);

    dmg_file.seekg(-152L, std::ios::end); // checksum offset
    unsigned char* u_buffer = new unsigned char[checksum_size];
    dmg_file.read((char*)u_buffer, checksum_size);
    // we don't want to byte swap checksum as disk utility/hdiutil doesn't
    std::stringstream checksum;
    for (size_t i = 0; i < checksum_size; i++) {
      if (u_buffer[i] != 0) {
        checksum << std::setw(2) << std::hex << std::uppercase
                 << (unsigned int)u_buffer[i];
      }
    }
    delete[] u_buffer;
    dmg_file.close();
    return checksum.str();
  }
  return "";
}
开发者ID:PoppySeedPlehzr,项目名称:osquery,代码行数:57,代码来源:diskarbitration.cpp


示例20: pathExists

bool pathExists(string maze[], int nRows, int nCols, int sr, int sc, int er, int ec)
{
	if (sr == er && sc == ec)
		return true;

	maze[sr][sc] = 'o';

	if (maze[sr - 1][sc] == '.') //North
		if (pathExists(maze, nRows, nCols, sr - 1, sc, er, ec) == true) return true;
	if (maze[sr][sc + 1] == '.') //East
		if (pathExists(maze, nRows, nCols, sr, sc + 1, er, ec) == true) return true;
	if (maze[sr + 1][sc] == '.') //South
		if (pathExists(maze, nRows, nCols, sr + 1, sc, er, ec) == true) return true;
	if (maze[sr][sc - 1] == '.') //West
		if (pathExists(maze, nRows, nCols, sr, sc - 1, er, ec) == true) return true;
	
	return false;
}
开发者ID:Srikanth8,项目名称:CS32,代码行数:18,代码来源:maze.cpp



注:本文中的pathExists函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pathName函数代码示例发布时间:2022-05-30
下一篇:
C++ path函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap