当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigVar::write方法代码示例

本文整理汇总了C++中ConfigVar::write方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigVar::write方法的具体用法?C++ ConfigVar::write怎么用?C++ ConfigVar::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigVar的用法示例。


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

示例1: toVar

ConfigVar ConfigReader::toVar() const {
  // write everything to a ConfigVar, then output to disk
  ConfigVar out;
  out.writeInt(vars.size());
  map<string, ConfigVar>::const_iterator it;
  for (it = vars.begin(); it != vars.end(); ++it) {
    out.writeInt(it->first.size());
    out.write((unsigned char *)it->first.data(), it->first.size());
    out.writeInt(it->second.size());
    out.write((unsigned char *)it->second.buffer(), it->second.size());
  }

  return out;
}
开发者ID:ghbolivar,项目名称:encfs4win,代码行数:14,代码来源:ConfigReader.cpp

示例2: load

// read the entire file into a ConfigVar instance and then use that to decode
// into mapped variables.
bool ConfigReader::load(const char *fileName) {
  struct stat_st stbuf;
  memset(&stbuf, 0, sizeof(struct stat_st));
  if (unix::lstat(fileName, &stbuf) != 0) return false;

  int size = stbuf.st_size;

  int fd = unix::open(fileName, O_RDONLY);
  if (fd < 0) return false;

  char *buf = new char[size];

  int res = ::_read(fd, buf, size);
  close(fd);

  if (res != size) {
    rWarning("Partial read of config file, expecting %i bytes, got %i", size,
             res);
    delete[] buf;
    return false;
  }

  ConfigVar in;
  in.write((unsigned char *)buf, size);
  delete[] buf;

  return loadFromVar(in);
}
开发者ID:ghbolivar,项目名称:encfs4win,代码行数:30,代码来源:ConfigReader.cpp

示例3: load

// read the entire file into a ConfigVar instance and then use that to decode
// into mapped variables.
bool ConfigReader::load(const char *fileName) {
  struct stat stbuf;
  memset(&stbuf, 0, sizeof(struct stat));
  if (lstat(fileName, &stbuf) != 0) return false;

  int size = stbuf.st_size;

  int fd = open(fileName, O_RDONLY);
  if (fd < 0) return false;

  char *buf = new char[size];

  int res = ::read(fd, buf, size);
  close(fd);

  if (res != size) {
    RLOG(WARNING) << "Partial read of config file, expecting " << size
                  << " bytes, got " << res;
    delete[] buf;
    return false;
  }

  ConfigVar in;
  in.write((unsigned char *)buf, size);
  delete[] buf;

  return loadFromVar(in);
}
开发者ID:Incognitas,项目名称:encfs,代码行数:30,代码来源:ConfigReader.cpp


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