Пример #1
0
int fstat(int fd,struct stat* buf)
{
	int err;
	struct Stat theStat;

	err=SysStatFd(fd,&theStat);

	if (err)
	{
		errno=-err;
		return -1;
	}

	CopyStat(buf,&theStat);

	return 0;
}
Пример #2
0
int stat(const char* file_name, struct stat* buf)
{
	int err;
	struct Stat theStat;

	err=SysStat(file_name,&theStat, -1);

	if (err)
	{
		errno=-err;
		return -1;
	}

	CopyStat(buf,&theStat);

	return 0;
}
Пример #3
0
static BROTLI_BOOL CloseFiles(Context* context, BROTLI_BOOL success) {
  BROTLI_BOOL is_ok = BROTLI_TRUE;
  if (!context->test_integrity && context->fout) {
    if (!success && context->current_output_path) {
      unlink(context->current_output_path);
    }
    if (fclose(context->fout) != 0) {
      if (success) {
        fprintf(stderr, "fclose failed [%s]: %s\n",
                PrintablePath(context->current_output_path), strerror(errno));
      }
      is_ok = BROTLI_FALSE;
    }

    /* TOCTOU violation, but otherwise it is impossible to set file times. */
    if (success && is_ok && context->copy_stat) {
      CopyStat(context->current_input_path, context->current_output_path);
    }
  }

  if (context->fin) {
    if (fclose(context->fin) != 0) {
      if (is_ok) {
        fprintf(stderr, "fclose failed [%s]: %s\n",
                PrintablePath(context->current_input_path), strerror(errno));
      }
      is_ok = BROTLI_FALSE;
    }
  }
  if (success && context->junk_source && context->current_input_path) {
    unlink(context->current_input_path);
  }

  context->fin = NULL;
  context->fout = NULL;

  return is_ok;
}