本文整理汇总了C++中OpenedFile::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ OpenedFile::Close方法的具体用法?C++ OpenedFile::Close怎么用?C++ OpenedFile::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenedFile
的用法示例。
在下文中一共展示了OpenedFile::Close方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stop_replay
void stop_replay(
void)
{
if (replay.game_is_being_replayed)
{
assert(replay.valid);
replay.game_is_being_replayed= false;
if (replay.resource_data)
{
delete []replay.resource_data;
replay.resource_data= NULL;
}
else
{
FilmFile.Close();
assert(replay.fsread_buffer);
delete []replay.fsread_buffer;
}
#ifdef DEBUG_REPLAY
close_stream_file();
#endif
}
/* Unecessary, because reset_player_queues calls this. */
replay.valid= false;
}
示例2: physics_file_is_m1
bool physics_file_is_m1(void)
{
bool m1_physics = false;
// check for M1 physics
OpenedFile PhysicsFile;
short SavedType, SavedError = get_game_error(&SavedType);
if (PhysicsFileSpec.Open(PhysicsFile))
{
uint32 tag = SDL_ReadBE32(PhysicsFile.GetRWops());
switch (tag)
{
case M1_MONSTER_PHYSICS_TAG:
case M1_EFFECTS_PHYSICS_TAG:
case M1_PROJECTILE_PHYSICS_TAG:
case M1_PHYSICS_PHYSICS_TAG:
case M1_WEAPONS_PHYSICS_TAG:
m1_physics = true;
break;
default:
break;
}
PhysicsFile.Close();
}
set_game_error(SavedType, SavedError);
return m1_physics;
}
示例3: rewind_recording
void rewind_recording(
void)
{
if(replay.game_is_being_recorded)
{
/* This is unnecessary, because it is called from reset_player_queues, */
/* which is always called from revert_game */
/*
FilmFile.SetLength(sizeof(recording_header));
FilmFile.SetPosition(sizeof(recording_header));
*/
// Alternative that does not use "SetLength", but instead creates and re-creates the file.
FilmFile.SetPosition(0);
byte Header[SIZEOF_recording_header];
FilmFile.Read(SIZEOF_recording_header,Header);
FilmFile.Close();
FilmFileSpec.Delete();
FilmFileSpec.Create(_typecode_film);
FilmFileSpec.Open(FilmFile,true);
FilmFile.Write(SIZEOF_recording_header,Header);
// Use the packed length here!!!
replay.header.length= SIZEOF_recording_header;
}
}
示例4: stop_recording
void stop_recording(
void)
{
if (replay.game_is_being_recorded)
{
replay.game_is_being_recorded = false;
short player_index;
int32 total_length;
assert(replay.valid);
for (player_index= 0; player_index<dynamic_world->player_count; player_index++)
{
save_recording_queue_chunk(player_index);
}
/* Rewrite the header, since it has the new length */
FilmFile.SetPosition(0);
byte Header[SIZEOF_recording_header];
pack_recording_header(Header,&replay.header,1);
// ZZZ: removing code that does stuff from assert() argument. BUT...
// should we really be asserting on this anyway? I mean, the write could fail
// in 'normal operation' too, not just when we screwed something up in writing the program?
bool successfulWrite = FilmFile.Write(SIZEOF_recording_header,Header);
assert(successfulWrite);
FilmFile.GetLength(total_length);
assert(total_length==replay.header.length);
FilmFile.Close();
}
replay.valid= false;
}
示例5: remove_input_controller
static void remove_input_controller(
void)
{
remove_timer_task(input_task);
if (replay.game_is_being_recorded)
{
stop_recording();
}
else if (replay.game_is_being_replayed)
{
if (replay.resource_data)
{
delete []replay.resource_data;
replay.resource_data= NULL;
replay.resource_data_size= 0l;
replay.film_resource_offset= NONE;
}
else
{
FilmFile.Close();
}
}
replay.valid= false;
}
示例6: setup_for_replay_from_file
bool setup_for_replay_from_file(
FileSpecifier& File,
uint32 map_checksum,
bool prompt_to_export)
{
bool successful= false;
(void)(map_checksum);
FilmFileSpec = File;
if (FilmFileSpec.Open(FilmFile))
{
replay.valid= true;
replay.have_read_last_chunk = false;
replay.game_is_being_replayed = true;
assert(!replay.resource_data);
replay.resource_data= NULL;
replay.resource_data_size= 0l;
replay.film_resource_offset= NONE;
byte Header[SIZEOF_recording_header];
FilmFile.Read(SIZEOF_recording_header,Header);
unpack_recording_header(Header,&replay.header,1);
replay.header.game_information.cheat_flags = _allow_crosshair | _allow_tunnel_vision | _allow_behindview | _allow_overlay_map;
/* Set to the mapfile this replay came from.. */
if(use_map_file(replay.header.map_checksum))
{
replay.fsread_buffer= new char[DISK_CACHE_SIZE];
assert(replay.fsread_buffer);
replay.location_in_cache= NULL;
replay.bytes_in_cache= 0;
replay.replay_speed= 1;
#ifdef DEBUG_REPLAY
open_stream_file();
#endif
if (prompt_to_export)
Movie::instance()->PromptForRecording();
successful= true;
} else {
/* Tell them that this map wasn't found. They lose. */
alert_user(infoError, strERRORS, cantFindReplayMap, 0);
replay.valid= false;
replay.game_is_being_replayed= false;
FilmFile.Close();
}
}
return successful;
}
示例7: calculate_crc_for_file
/* -------------- Entry Point ----------- */
uint32 calculate_crc_for_file(FileSpecifier& File)
{
uint32 crc = 0;
OpenedFile OFile;
if (File.Open(OFile))
{
crc= calculate_crc_for_opened_file(OFile);
OFile.Close();
}
return crc;
}
示例8: Open
// Open data file
bool FileSpecifier::Open(OpenedFile &OFile, bool Writable)
{
OFile.Close();
SDL_RWops *f;
#ifdef __MACOS__
if (!Writable)
f = OFile.f = open_fork_from_existing_path(GetPath(), false);
else
#endif
{
#ifdef HAVE_ZZIP
if (!Writable)
{
f = OFile.f = SDL_RWFromZZIP(unix_path_separators(GetPath()).c_str(), "rb");
}
else
#endif
f = OFile.f = SDL_RWFromFile(GetPath(), Writable ? "wb+" : "rb");
}
err = f ? 0 : errno;
if (f == NULL) {
set_game_error(systemError, err);
return false;
}
if (Writable)
return true;
// Transparently handle AppleSingle and MacBinary files on reading
int32 offset, data_length, rsrc_length;
if (is_applesingle(f, false, offset, data_length)) {
OFile.is_forked = true;
OFile.fork_offset = offset;
OFile.fork_length = data_length;
SDL_RWseek(f, offset, SEEK_SET);
return true;
} else if (is_macbinary(f, data_length, rsrc_length)) {
OFile.is_forked = true;
OFile.fork_offset = 128;
OFile.fork_length = data_length;
SDL_RWseek(f, 128, SEEK_SET);
return true;
}
SDL_RWseek(f, 0, SEEK_SET);
return true;
}