12/28/2016

File exist check code



bool fileExists(const char* path)
{
  FILE* file;
  bool exists;

  file = fileOpen(path, "r");
  exists = file != 0;

  if (file)
    fclose(file);

  return exists;
}

FILE* fileOpen(const char* path, const char* mode)
{
  char path_[PATH_MAX];

  assert(path);

  resolvePath(path_, sizeof(path_), path);

  FILE* fp;
  fopen_s(&fp, path_, mode);
  return fp;
}

No comments:

Post a Comment