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

C++ FreeFile函数代码示例

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

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



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

示例1: FreeFile

bool TSFrameReader::SetFile(string filePath) {
	FreeFile();
	_freeFile = true;
	_pFile = GetFile(filePath, 4 * 1024 * 1024);
	if (_pFile == NULL) {
		FATAL("Unable to open file %s", STR(filePath));
		return false;
	}
	if (!DetermineChunkSize()) {
		FATAL("Unable to determine chunk size");
		FreeFile();
		return false;
	}

	SetChunkSize(_chunkSize);
	if (!_pFile->SeekTo(_chunkSizeDetectionCount)) {
		FATAL("Unable to seek to the beginning of file");
		FreeFile();
		return false;
	}
	_eof = _pFile->IsEOF();

	_defaultBlockSize = ((1024 * 1024 * 2) / _chunkSize) * _chunkSize;

	return true;
}
开发者ID:9aa5,项目名称:crtmpserver,代码行数:26,代码来源:tsframereader.cpp


示例2: pg_record_shmem_shutdown

/* Dumps the histogram data into a file (with a md5 hash of the contents at the beginning). */
static
void pg_record_shmem_shutdown(int code, Datum arg) {
    
    FILE * file;
    
    /* do we need to write the queries? */
    if (query_buffer->next == 0) {
        return;
    }
    
    prepare_file(log_file, query_buffer, query_buffer->next);
    
    file = AllocateFile(log_file->curr_filename, PG_BINARY_A);
    if (file == NULL)
        goto error;
    
    /* now write the actual shared segment */
    if (fwrite(query_buffer->buffer, query_buffer->next, 1, file) != 1)
       goto error;
    
    FreeFile(file);
    
    return;

error:
    ereport(LOG,
            (errcode_for_file_access(),
             errmsg("could not write query buffer to the file \"%s\": %m",
                    log_file->curr_filename)));
    if (file)
        FreeFile(file);
    
}
开发者ID:tvondra,项目名称:query_recorder,代码行数:34,代码来源:record.c


示例3: buffer_write

/* Dumps the histogram data into a file (with a md5 hash of the contents at the beginning). */
static
void buffer_write() {
    
    FILE * file;
    
    prepare_file(log_file, query_buffer, query_buffer->next);
    
    file = AllocateFile(log_file->curr_filename, PG_BINARY_A);
    if (file == NULL)
        goto error;
    
    /* now write the actual shared segment */
    if (fwrite(query_buffer->buffer, query_buffer->next, 1, file) != 1)
        goto error;
    
    FreeFile(file);
    
    return;

error:
    ereport(LOG,
            (errcode_for_file_access(),
             errmsg("could not write query histogram file \"%s\": %m",
                    log_file->curr_filename)));
    if (file)
        FreeFile(file);
    
}
开发者ID:tvondra,项目名称:query_recorder,代码行数:29,代码来源:record.c


示例4: pgss_shmem_shutdown

/*
 * shmem_shutdown hook: Dump statistics into file.
 *
 * Note: we don't bother with acquiring lock, because there should be no
 * other processes running when this is called.
 */
static void
pgss_shmem_shutdown(int code, Datum arg)
{
	FILE	   *file;
	HASH_SEQ_STATUS hash_seq;
	int32		num_entries;
	pgssEntry  *entry;

	/* Don't try to dump during a crash. */
	if (code)
		return;

	/* Safety check ... shouldn't get here unless shmem is set up. */
	if (!pgss || !pgss_hash)
		return;

	/* Don't dump if told not to. */
	if (!pgss_save)
		return;

	file = AllocateFile(PGSS_DUMP_FILE, PG_BINARY_W);
	if (file == NULL)
		goto error;

	if (fwrite(&PGSS_FILE_HEADER, sizeof(uint32), 1, file) != 1)
		goto error;
	num_entries = hash_get_num_entries(pgss_hash);
	if (fwrite(&num_entries, sizeof(int32), 1, file) != 1)
		goto error;

	hash_seq_init(&hash_seq, pgss_hash);
	while ((entry = hash_seq_search(&hash_seq)) != NULL)
	{
		int			len = entry->key.query_len;

		if (fwrite(entry, offsetof(pgssEntry, mutex), 1, file) != 1 ||
			fwrite(entry->query, 1, len, file) != len)
			goto error;
	}

	if (FreeFile(file))
	{
		file = NULL;
		goto error;
	}

	return;

error:
	ereport(LOG,
			(errcode_for_file_access(),
			 errmsg("could not write pg_stat_statement file \"%s\": %m",
					PGSS_DUMP_FILE)));
	if (file)
		FreeFile(file);
	unlink(PGSS_DUMP_FILE);
}
开发者ID:HBPSP8Repo,项目名称:NoDB,代码行数:63,代码来源:pg_stat_statements.c


示例5: utl_file_fcopy

/*
 * CREATE FUNCTION utl_file.fcopy(
 *     src_location		text,
 *     src_filename		text,
 *     dest_location	text,
 *     dest_filename	text,
 *     start_line		integer DEFAULT NULL
 *     end_line			integer DEFAULT NULL)
 */
Datum
utl_file_fcopy(PG_FUNCTION_ARGS)
{
	char	   *srcpath;
	char	   *dstpath;
	int			start_line;
	int			end_line;
	FILE	   *srcfile;
	FILE	   *dstfile;

	NOT_NULL_ARG(0);
	NOT_NULL_ARG(1);
	NOT_NULL_ARG(2);
	NOT_NULL_ARG(3);

	srcpath = get_safe_path(PG_GETARG_TEXT_P(0), PG_GETARG_TEXT_P(1));
	dstpath = get_safe_path(PG_GETARG_TEXT_P(2), PG_GETARG_TEXT_P(3));

	start_line = PG_GETARG_IF_EXISTS(4, INT32, 1);
	if (start_line <= 0)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				errmsg("start_line must be positive (%d passed)", start_line)));

	end_line = PG_GETARG_IF_EXISTS(5, INT32, INT_MAX);
	if (end_line <= 0)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				errmsg("end_line must be positive (%d passed)", end_line)));

	srcfile = AllocateFile(srcpath, "rt");
	if (srcfile == NULL)
	{
		/* failed to open src file. */
		IO_EXCEPTION();
	}

	dstfile = AllocateFile(dstpath, "wt");
	if (dstfile == NULL)
	{
		/* failed to open dst file. */
		fclose(srcfile);
		IO_EXCEPTION();
	}

	if (copy_text_file(srcfile, dstfile, start_line, end_line))
		IO_EXCEPTION();

	FreeFile(srcfile);
	FreeFile(dstfile);

	PG_RETURN_VOID();
}
开发者ID:50wu,项目名称:gpdb,代码行数:62,代码来源:file.c


示例6: ReaderClose

/**
 * @brief clean up Reader structure.
 */
int64
ReaderClose(Reader *rd, bool onError)
{
	int64	skip = 0;

	if (rd == NULL)
		return 0;

	/* Close and release members. */
	if (rd->parser)
		skip = ParserTerm(rd->parser);

	CheckerTerm(&rd->checker);

	if (!onError)
	{
		if (rd->parse_fp != NULL && FreeFile(rd->parse_fp) < 0)
			ereport(WARNING,
					(errcode_for_file_access(),
					 errmsg("could not close parse bad file \"%s\": %m",
							rd->parse_badfile)));
		if (rd->infile != NULL)
			pfree(rd->infile);
		if (rd->logfile != NULL)
			pfree(rd->logfile);
		if (rd->parse_badfile != NULL)
			pfree(rd->parse_badfile);

		pfree(rd);
	}

	return skip;
}
开发者ID:gatehouse,项目名称:pg_bulkload,代码行数:36,代码来源:reader.c


示例7: tsearch_readline_end

/*
 * Close down after reading a file with tsearch_readline()
 */
void
tsearch_readline_end(tsearch_readline_state *stp)
{
	FreeFile(stp->fp);
	/* Pop the error context stack */
	error_context_stack = stp->cb.previous;
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:10,代码来源:ts_locale.c


示例8: FreeFile

//------------------------------------------------------
int FrameSeq::Load(AnsiString filename)
{
   FreeFile();
   try {File=new TFileStream(filename,fmOpenRead|fmShareExclusive);}
   catch(...) {return 1;}
   File->Seek(0,soFromBeginning);
   Header=new __int8[4100];
   File->Read(Header,4100);
   File->Seek(108,soFromBeginning);
   short int datatype;
   File->Read(&datatype,2);
   if(datatype == 0) return 2; //FLOATING POINT intensity format is not supported
   DatLength=datatype>1?2:4;
   File->Seek(1446,soFromBeginning);
   int NFramestemp=0,XDimtemp=0,YDimtemp=0;
   File->Read(&NFramestemp,4);
   File->Seek(42,soFromBeginning);
   File->Read(&XDimtemp,2);
   File->Seek(656,soFromBeginning);
   File->Read(&YDimtemp,2);
   if( (NFramestemp<1)||(NFramestemp>MaxFrames)||(!datatype)||(XDimtemp<1)
     ||(XDimtemp>MaxDim)||(YDimtemp<1)||(YDimtemp>MaxDim) )
   {
      delete File; File=NULL;
      return 1;
   }
   NFrames=NFramestemp;
   XDim=XDimtemp; YDim=YDimtemp;
   CurFrame=new Frame(XDim,YDim);
//   LoadFrame(1);
   return 0;
};
开发者ID:mirzov,项目名称:BrightStat,代码行数:33,代码来源:FrameSeq.cpp


示例9: XLogArchiveNotify

/*
 * XLogArchiveNotify
 *
 * Create an archive notification file
 *
 * The name of the notification file is the message that will be picked up
 * by the archiver, e.g. we write 0000000100000001000000C6.ready
 * and the archiver then knows to archive XLOGDIR/0000000100000001000000C6,
 * then when complete, rename it to 0000000100000001000000C6.done
 */
void
XLogArchiveNotify(const char *xlog)
{
	char		archiveStatusPath[MAXPGPATH];
	FILE	   *fd;

	/* insert an otherwise empty file called <XLOG>.ready */
	StatusFilePath(archiveStatusPath, xlog, ".ready");
	fd = AllocateFile(archiveStatusPath, "w");
	if (fd == NULL)
	{
		ereport(LOG,
				(errcode_for_file_access(),
				 errmsg("could not create archive status file \"%s\": %m",
						archiveStatusPath)));
		return;
	}
	if (FreeFile(fd))
	{
		ereport(LOG,
				(errcode_for_file_access(),
				 errmsg("could not write archive status file \"%s\": %m",
						archiveStatusPath)));
		return;
	}

	/* Notify archiver that it's got something to do */
	if (IsUnderPostmaster)
		SendPostmasterSignal(PMSIGNAL_WAKEN_ARCHIVER);
}
开发者ID:JiannengSun,项目名称:postgres,代码行数:40,代码来源:xlogarchive.c


示例10: FindMyDatabase

/*
 * FindMyDatabase -- get the critical info needed to locate my database
 *
 * Find the named database in pg_database, return its database OID and the
 * OID of its default tablespace.  Return TRUE if found, FALSE if not.
 *
 * Since we are not yet up and running as a backend, we cannot look directly
 * at pg_database (we can't obtain locks nor participate in transactions).
 * So to get the info we need before starting up, we must look at the "flat
 * file" copy of pg_database that is helpfully maintained by flatfiles.c.
 * This is subject to various race conditions, so after we have the
 * transaction infrastructure started, we have to recheck the information;
 * see InitPostgres.
 */
static bool
FindMyDatabase(const char *name, Oid *db_id, Oid *db_tablespace)
{
    bool		result = false;
    char	   *filename;
    FILE	   *db_file;
    char		thisname[NAMEDATALEN];
    TransactionId db_frozenxid;

    filename = database_getflatfilename();
    db_file = AllocateFile(filename, "r");
    if (db_file == NULL)
        ereport(FATAL,
                (errcode_for_file_access(),
                 errmsg("could not open file \"%s\": %m", filename)));

    while (read_pg_database_line(db_file, thisname, db_id,
                                 db_tablespace, &db_frozenxid))
    {
        if (strcmp(thisname, name) == 0)
        {
            result = true;
            break;
        }
    }

    FreeFile(db_file);
    pfree(filename);

    return result;
}
开发者ID:RuchikaGupta,项目名称:fa12,代码行数:45,代码来源:postinit.c


示例11: pg_backup_start_time

/*
 * Returns start time of an online exclusive backup.
 *
 * When there's no exclusive backup in progress, the function
 * returns NULL.
 */
Datum
pg_backup_start_time(PG_FUNCTION_ARGS)
{
	Datum		xtime;
	FILE	   *lfp;
	char		fline[MAXPGPATH];
	char		backup_start_time[30];

	/*
	 * See if label file is present
	 */
	lfp = AllocateFile(BACKUP_LABEL_FILE, "r");
	if (lfp == NULL)
	{
		if (errno != ENOENT)
			ereport(ERROR,
					(errcode_for_file_access(),
					 errmsg("could not read file \"%s\": %m",
							BACKUP_LABEL_FILE)));
		PG_RETURN_NULL();
	}

	/*
	 * Parse the file to find the START TIME line.
	 */
	backup_start_time[0] = '\0';
	while (fgets(fline, sizeof(fline), lfp) != NULL)
	{
		if (sscanf(fline, "START TIME: %25[^\n]\n", backup_start_time) == 1)
			break;
	}

	/* Check for a read error. */
	if (ferror(lfp))
		ereport(ERROR,
				(errcode_for_file_access(),
			   errmsg("could not read file \"%s\": %m", BACKUP_LABEL_FILE)));

	/* Close the backup label file. */
	if (FreeFile(lfp))
		ereport(ERROR,
				(errcode_for_file_access(),
			  errmsg("could not close file \"%s\": %m", BACKUP_LABEL_FILE)));

	if (strlen(backup_start_time) == 0)
		ereport(ERROR,
				(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
				 errmsg("invalid data in file \"%s\"", BACKUP_LABEL_FILE)));

	/*
	 * Convert the time string read from file to TimestampTz form.
	 */
	xtime = DirectFunctionCall3(timestamptz_in,
								CStringGetDatum(backup_start_time),
								ObjectIdGetDatum(InvalidOid),
								Int32GetDatum(-1));

	PG_RETURN_DATUM(xtime);
}
开发者ID:Gordiychuk,项目名称:postgres,代码行数:65,代码来源:xlogfuncs.c


示例12: pg_read_file

/*
 * Read a section of a file, returning it as text
 */
Datum
pg_read_file(PG_FUNCTION_ARGS)
{
	text	   *filename_t = PG_GETARG_TEXT_P(0);
	int64		seek_offset = PG_GETARG_INT64(1);
	int64		bytes_to_read = PG_GETARG_INT64(2);
	char	   *buf;
	size_t		nbytes;
	FILE	   *file;
	char	   *filename;

	if (!superuser())
		ereport(ERROR,
				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
				 (errmsg("must be superuser to read files"))));

	filename = convert_and_check_filename(filename_t);

	if ((file = AllocateFile(filename, PG_BINARY_R)) == NULL)
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not open file \"%s\" for reading: %m",
						filename)));

	if (fseeko(file, (off_t) seek_offset,
			   (seek_offset >= 0) ? SEEK_SET : SEEK_END) != 0)
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not seek in file \"%s\": %m", filename)));

	if (bytes_to_read < 0)
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("requested length cannot be negative")));

	/* not sure why anyone thought that int64 length was a good idea */
	if (bytes_to_read > (MaxAllocSize - VARHDRSZ))
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("requested length too large")));

	buf = palloc((Size) bytes_to_read + VARHDRSZ);

	nbytes = fread(VARDATA(buf), 1, (size_t) bytes_to_read, file);

	if (ferror(file))
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not read file \"%s\": %m", filename)));

	SET_VARSIZE(buf, nbytes + VARHDRSZ);

	FreeFile(file);
	pfree(filename);

	PG_RETURN_TEXT_P(buf);
}
开发者ID:karthijrk,项目名称:gpdb,代码行数:60,代码来源:genfile.c


示例13: read_binary_file

/*
 * Read a section of a file, returning it as bytea
 *
 * Caller is responsible for all permissions checking.
 *
 * We read the whole of the file when bytes_to_read is negative.
 */
bytea *
read_binary_file(const char *filename, int64 seek_offset, int64 bytes_to_read)
{
	bytea	   *buf;
	size_t		nbytes;
	FILE	   *file;

	if (bytes_to_read < 0)
	{
		if (seek_offset < 0)
			bytes_to_read = -seek_offset;
		else
		{
			struct stat fst;

			if (stat(filename, &fst) < 0)
				ereport(ERROR,
						(errcode_for_file_access(),
						 errmsg("could not stat file \"%s\": %m", filename)));

			bytes_to_read = fst.st_size - seek_offset;
		}
	}

	/* not sure why anyone thought that int64 length was a good idea */
	if (bytes_to_read > (MaxAllocSize - VARHDRSZ))
		ereport(ERROR,
				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
				 errmsg("requested length too large")));

	if ((file = AllocateFile(filename, PG_BINARY_R)) == NULL)
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not open file \"%s\" for reading: %m",
						filename)));

	if (fseeko(file, (off_t) seek_offset,
			   (seek_offset >= 0) ? SEEK_SET : SEEK_END) != 0)
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not seek in file \"%s\": %m", filename)));

	buf = (bytea *) palloc((Size) bytes_to_read + VARHDRSZ);

	nbytes = fread(VARDATA(buf), 1, (size_t) bytes_to_read, file);

	if (ferror(file))
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not read file \"%s\": %m", filename)));

	SET_VARSIZE(buf, nbytes + VARHDRSZ);

	FreeFile(file);

	return buf;
}
开发者ID:BioBD,项目名称:Hypothetical_Indexes,代码行数:64,代码来源:genfile.c


示例14: load_dh_file

/*
 *	Load precomputed DH parameters.
 *
 *	To prevent "downgrade" attacks, we perform a number of checks
 *	to verify that the DBA-generated DH parameters file contains
 *	what we expect it to contain.
 */
static DH  *
load_dh_file(char *filename, bool isServerStart)
{
	FILE	   *fp;
	DH		   *dh = NULL;
	int			codes;

	/* attempt to open file.  It's not an error if it doesn't exist. */
	if ((fp = AllocateFile(filename, "r")) == NULL)
	{
		ereport(isServerStart ? FATAL : LOG,
				(errcode_for_file_access(),
				 errmsg("could not open DH parameters file \"%s\": %m",
						filename)));
		return NULL;
	}

	dh = PEM_read_DHparams(fp, NULL, NULL, NULL);
	FreeFile(fp);

	if (dh == NULL)
	{
		ereport(isServerStart ? FATAL : LOG,
				(errcode(ERRCODE_CONFIG_FILE_ERROR),
				 errmsg("could not load DH parameters file: %s",
						SSLerrmessage(ERR_get_error()))));
		return NULL;
	}

	/* make sure the DH parameters are usable */
	if (DH_check(dh, &codes) == 0)
	{
		ereport(isServerStart ? FATAL : LOG,
				(errcode(ERRCODE_CONFIG_FILE_ERROR),
				 errmsg("invalid DH parameters: %s",
						SSLerrmessage(ERR_get_error()))));
		return NULL;
	}
	if (codes & DH_CHECK_P_NOT_PRIME)
	{
		ereport(isServerStart ? FATAL : LOG,
				(errcode(ERRCODE_CONFIG_FILE_ERROR),
				 errmsg("invalid DH parameters: p is not prime")));
		return NULL;
	}
	if ((codes & DH_NOT_SUITABLE_GENERATOR) &&
		(codes & DH_CHECK_P_NOT_SAFE_PRIME))
	{
		ereport(isServerStart ? FATAL : LOG,
				(errcode(ERRCODE_CONFIG_FILE_ERROR),
				 errmsg("invalid DH parameters: neither suitable generator or safe prime")));
		return NULL;
	}

	return dh;
}
开发者ID:adityavs,项目名称:postgres,代码行数:63,代码来源:be-secure-openssl.c


示例15: FileSourceClose

static void
FileSourceClose(FileSource *self)
{
	if (self->fd != NULL && FreeFile(self->fd) < 0)
	{
		ereport(WARNING, (errcode_for_file_access(),
			errmsg("could not close source file: %m")));
	}
	pfree(self);
}
开发者ID:bwtakacy,项目名称:prev_pg_bulkload_repo,代码行数:10,代码来源:source.c


示例16: set_short_version

/*
 * write out the PG_VERSION file in the specified directory
 */
static void
set_short_version(const char *path)
{
	char	   *short_version;
	bool		gotdot = false;
	int			end;
	char	   *fullname;
	FILE	   *version_file;

	/* Construct short version string (should match initdb.c) */
	short_version = pstrdup(PG_VERSION);

	for (end = 0; short_version[end] != '\0'; end++)
	{
		if (short_version[end] == '.')
		{
			Assert(end != 0);
			if (gotdot)
				break;
			else
				gotdot = true;
		}
		else if (short_version[end] < '0' || short_version[end] > '9')
		{
			/* gone past digits and dots */
			break;
		}
	}
	Assert(end > 0 && short_version[end - 1] != '.' && gotdot);
	short_version[end] = '\0';

	/* Now write the file */
	fullname = palloc(strlen(path) + 11 + 1);
	sprintf(fullname, "%s/PG_VERSION", path);
	version_file = AllocateFile(fullname, PG_BINARY_W);
	if (version_file == NULL)
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not write to file \"%s\": %m",
						fullname)));
	fprintf(version_file, "%s\n", short_version);
	if (FreeFile(version_file))
		ereport(ERROR,
				(errcode_for_file_access(),
				 errmsg("could not write to file \"%s\": %m",
						fullname)));

	pfree(fullname);
	pfree(short_version);
}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:53,代码来源:tablespace.c


示例17: DoNames

int DoNames(int state) {
	int wnum = (int)CurrentWorld;
	int lnum = (int)CurrentLevel;
	
	// Skip the title screen
	// and only process the code if the State is set to 1
	// (the screen has been initialised)
	if (state == 1 && lnum != STAGE_TITLE) {
		// grab the CRSIN object
		Actor *ptr = FindActorByType(CRSIN, 0);
		
		// FIX !!!!!
		
		if (ptr != 0) {
			void *worldObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_WorldName");
			void *levelObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_LevelName");
			if (worldObj == 0 || levelObj == 0) return state;
			
			/*char *file = RetrieveFileFromArc(ARC_TABLE, "Mario", "newer/names.bin");
			char *worldname = file + (wnum * 0x40);
			char *levelname = file + 0x280 + (wnum * 0xA80) + (lnum * 0x40);*/
			FileHandle fh;
			void *info = LoadFile(&fh, "/NewerRes/LevelInfo.bin");
			
			LevelInfo_Prepare(&fh);
			LevelInfo_Entry *entry = LevelInfo_SearchSlot(info, wnum, lnum);
			char *worldname = LevelInfo_GetName(info, entry);
			char *levelname = "";
			
			void *vtable = *((void**)levelObj);
			void *funcaddr = *((void**)((u32)vtable+0x7C));
			int (*SetString)(void*, unsigned short*, unsigned short);
			SetString = (int(*)(void*, unsigned short*, unsigned short))funcaddr;
			
			unsigned short wbuffer[0x40], lbuffer[0x40];
			for (int i = 0; i < 0x40; i++) {
				wbuffer[i] = (unsigned short)worldname[i];
				lbuffer[i] = (unsigned short)levelname[i];
			}
			
			SetString(worldObj, wbuffer, 0);
			SetString(levelObj, lbuffer, 0);
			
			FreeFile(&fh);
		}
	} else {
	}
	
	return state;
}
开发者ID:InfosHack,项目名称:NewerSMBW,代码行数:50,代码来源:levelnames.cpp


示例18: LoggerClose

void
LoggerClose(void)
{
	if (logger.fp != NULL && FreeFile(logger.fp) < 0)
		ereport(WARNING,
				(errcode_for_file_access(),
				 errmsg("could not close loader log file \"%s\": %m",
						logger.logfile)));

	if (logger.logfile != NULL)
		pfree(logger.logfile);

	memset(&logger, 0, sizeof(logger));
}
开发者ID:Komzpa,项目名称:pg_bulkload,代码行数:14,代码来源:logger.c


示例19: query_write

/* Dumps the histogram data into a file (with a md5 hash of the contents at the beginning). */
static
void query_write(double duration, const char * query, int len, const char * header, int hlen) {
    
    FILE * file;
    
    /* write the buffer first */
    buffer_write();
    
    /* now write the query */
    prepare_file(log_file, query_buffer, hlen + len);
    
    file = AllocateFile(log_file->curr_filename, PG_BINARY_A);
    if (file == NULL)
        goto error;
    
    /* now write the actual shared segment */
    if (fwrite(header, hlen, 1, file) != 1)
       goto error;
    
    /* now write the actual shared segment */
    if (fwrite(query, len, 1, file) != 1)
       goto error;
    
    FreeFile(file);
    
    return;

error:
    ereport(LOG,
            (errcode_for_file_access(),
             errmsg("could not write query to the file \"%s\": %m",
                    log_file->curr_filename)));
    if (file)
        FreeFile(file);
    
}
开发者ID:tvondra,项目名称:query_recorder,代码行数:37,代码来源:record.c


示例20: ErrorLogWrite

/*
 * Write into the error log file.  This opens the file every time,
 * so that we can keep it simple to deal with concurrent write.
 */
static void
ErrorLogWrite(CdbSreh *cdbsreh)
{
	HeapTuple	tuple;
	char		filename[MAXPGPATH];
	FILE	   *fp;
	pg_crc32	crc;

	Assert(OidIsValid(cdbsreh->relid));
	ErrorLogFileName(filename, MyDatabaseId, cdbsreh->relid);
	tuple = FormErrorTuple(cdbsreh);

	INIT_CRC32C(crc);
	COMP_CRC32C(crc, tuple->t_data, tuple->t_len);
	FIN_CRC32C(crc);

	LWLockAcquire(ErrorLogLock, LW_EXCLUSIVE);
	fp = AllocateFile(filename, "a");
	if (!fp)
	{
		mkdir(ErrorLogDir, S_IRWXU);

		fp = AllocateFile(filename, "a");
	}
	if (!fp)
		ereport(ERROR,
				(errmsg("could not open \"%s\": %m", filename)));

	/*
	 * format:
	 *     0-4: length
	 *     5-8: crc
	 *     9-n: tuple data
	 */
	if (fwrite(&tuple->t_len, 1, sizeof(tuple->t_len), fp) != sizeof(tuple->t_len))
		elog(ERROR, "could not write tuple length: %m");
	if (fwrite(&crc, 1, sizeof(pg_crc32), fp) != sizeof(pg_crc32))
		elog(ERROR, "could not write checksum: %m");
	if (fwrite(tuple->t_data, 1, tuple->t_len, fp) != tuple->t_len)
		elog(ERROR, "could not write tuple data: %m");

	FreeFile(fp);
	LWLockRelease(ErrorLogLock);

	heap_freetuple(tuple);
}
开发者ID:LJoNe,项目名称:gpdb,代码行数:50,代码来源:cdbsreh.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FreeImage_Allocate函数代码示例发布时间:2022-05-30
下一篇:
C++ FreeDir函数代码示例发布时间: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