void config_file_watch_dog::on_changed() { if ( do_preconfig_ ) { LOG_INFO("loglog","config_file_watch_dog - Log config file '" << get_file_path().string() << "' have been changed. Reload the config file with the preconfig string '" << preconfig_string_ << "'." ); properties_configure( get_file_path().string(), preconfig_string_ ); } else { LOG_INFO("loglog","config_file_watch_dog - Log config file '" << get_file_path().string() << "' have been changed. Reload the config file."); properties_configure( get_file_path().string() ); } }
bool check_file_path(sint32 pathId) { const utf8 * path = get_file_path(pathId); switch (pathId) { case PATH_ID_G1: if (!File::Exists(path)) { Console::Error::WriteLine("Unable to find '%s'", path); return false; } break; case PATH_ID_CUSTOM1: case PATH_ID_CUSTOM2: if (File::Exists(path)) { try { auto fs = FileStream(path, FILE_MODE_OPEN); sint32 index = 36 + (pathId - PATH_ID_CUSTOM1); gRideMusicInfoList[index]->length = fs.GetLength(); } catch (const Exception &) { } } break; } return true; }
static int clean_dump(char *path) { DIR *dir; struct dirent *dir_info; char file_path[PATH_MAX]; dir = opendir(path); if (dir == NULL) { perror("open dir failed"); return 1; } printf("path max %d\n", PATH_MAX); while ((dir_info = readdir(dir)) != NULL) { if (strstr(dir_info->d_name, ".dmp") == NULL) continue; get_file_path(path, dir_info->d_name, file_path); printf("%s\n", file_path); if (is_file(file_path)) remove(file_path); } return 0; }
/** * * rct2: 0x00678998 */ void gfx_load_g1() { HANDLE hFile; DWORD bytesRead; DWORD header[2]; int i; int g1BufferSize; void* g1Buffer; rct_g1_element *g1Elements = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element); hFile = CreateFile(get_file_path(PATH_ID_G1), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) { ReadFile(hFile, header, 8, &bytesRead, NULL); if (bytesRead == 8) { g1BufferSize = header[1]; g1Buffer = rct2_malloc(g1BufferSize); ReadFile(hFile, g1Elements, 29294 * sizeof(rct_g1_element), &bytesRead, NULL); ReadFile(hFile, g1Buffer, g1BufferSize, &bytesRead, NULL); CloseHandle(hFile); for (i = 0; i < 29294; i++) g1Elements[i].offset += (int)g1Buffer; return; } } // exit with error fprintf(stderr, "Unable to load g1.dat"); assert(0); }
/** * @brief Sets the data of an item for a given role. * @param index Index of the item to set. * @param value The new value to set. * @param role The role to change. * @parem @c true in case of success. */ bool QuestFilesModel::setData( const QModelIndex& index, const QVariant& value, int role) { if (index.column() != DESCRIPTION_COLUMN) { // Only the description column is editable. return false; } if (role != Qt::EditRole) { return false; } QString file_path = get_file_path(index); ResourceType resource_type; QString element_id; if (!quest.is_resource_element(file_path, resource_type, element_id)) { return false; } try { quest.get_resources().set_description(resource_type, element_id, value.toString()); quest.get_resources().save(); emit dataChanged(index, index); return true; } catch (const EditorException& ex) { ex.print_message(); return false; } }
/** * @brief Returns the flags of an item. * @param index An item index. * @return The item flags. */ Qt::ItemFlags QuestFilesModel::flags(const QModelIndex& index) const { QString file_path = get_file_path(index); ResourceType resource_type; QString element_id; Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; switch (index.column()) { case FILE_COLUMN: // File name. if (quest.is_resource_element(file_path, resource_type, element_id)) { // Resource elements never has children, // even languages that are actually directories on the filesystem. flags |= Qt::ItemNeverHasChildren; } return flags; case DESCRIPTION_COLUMN: // Resource description. if (quest.is_resource_element(file_path, resource_type, element_id)) { // The description column of a resource element can be modified. return flags | Qt::ItemIsEditable; } return flags; } return flags; }
void* Mixer_Play_Music(int pathId, int loop, int streaming) { if (gOpenRCT2Headless) return 0; if (streaming) { const utf8 *filename = get_file_path(pathId); SDL_RWops* rw = SDL_RWFromFile(filename, "rb"); if (rw == NULL) { return 0; } Source_SampleStream* source_samplestream = new Source_SampleStream; if (source_samplestream->LoadWAV(rw)) { Channel* channel = gMixer.Play(*source_samplestream, loop, false, true); if (!channel) { delete source_samplestream; } else { channel->SetGroup(MIXER_GROUP_RIDE_MUSIC); } return channel; } else { delete source_samplestream; return 0; } } else { if (gMixer.LoadMusic(pathId)) { Channel* channel = gMixer.Play(*gMixer.musicsources[pathId], MIXER_LOOP_INFINITE, false, false); if (channel) { channel->SetGroup(MIXER_GROUP_RIDE_MUSIC); } return channel; } } return 0; }
static void rm_log(struct evbuffer *rsps) { char *log = get_file_path("log"); remove(log); evbuffer_add_printf(rsps, "OK"); }
void Mixer::Init(const char* device) { Close(); SDL_AudioSpec want, have; SDL_zero(want); want.freq = 44100; want.format = AUDIO_S16SYS; want.channels = 2; want.samples = 1024; want.callback = Callback; want.userdata = this; deviceid = SDL_OpenAudioDevice(device, 0, &want, &have, 0); format.format = have.format; format.channels = have.channels; format.freq = have.freq; const char* filename = get_file_path(PATH_ID_CSS1); for (size_t i = 0; i < Util::CountOf(css1sources); i++) { Source_Sample* source_sample = new Source_Sample; if (source_sample->LoadCSS1(filename, i)) { source_sample->Convert(format); // convert to audio output format, saves some cpu usage but requires a bit more memory, optional css1sources[i] = source_sample; } else { css1sources[i] = &source_null; delete source_sample; } } effectbuffer = new uint8[(have.samples * format.BytesPerSample() * format.channels)]; SDL_PauseAudioDevice(deviceid, 0); }
uint32_t install_(const std::string& fpath) { unit_map_cit cit = unit_map_.find(fpath); if(cit != unit_map_.end()) { // find it !, To be not install. return 0; } auto tpath = strip_last_of_delimita_path(fpath); auto bpath = get_file_path(tpath); bpath += '/'; unit_map_it it = unit_map_.find(bpath); if(it != unit_map_.end()) { unit_t& t = it->second; std::string name = get_file_name(tpath); if(fpath.back() == '/') name += '/'; t.install_child(name); } uint32_t hnd = handle_set_.create(); unit_t u; u.set_id(hnd); unit_map_.emplace(fpath, u); return hnd; }
int main(int ac, char **av, char **ev) { struct stat tmp; char *file; pid_t pid; if (ac < 2) print_help(); if (!(file = get_file_path(av[1], ev))) { ft_putendl_fd("Can't find exec in path", 2); exit(EXIT_SUCCESS); } if (stat(file, &tmp) == -1) { ft_putstr_fd("ft_strace: \"", 2); ft_putstr_fd(av[1], 2); ft_putstr_fd("\": No such file or directory", 2); exit(EXIT_FAILURE); } syscalls_init(); signals_init(); errno_init(); pid = fork(); if (pid == -1) { ft_putendl_fd("ft_strace: failed to fork", 2); exit(EXIT_FAILURE); } else if (pid == 0) child_launch(av, file); else parent_launch(pid); return (EXIT_SUCCESS); }
chd_error chdcd_parse_iso(const char *tocfname, cdrom_toc &outtoc, chdcd_track_input_info &outinfo) { FILE *infile; astring path = astring(tocfname); infile = fopen(tocfname, "rb"); path = get_file_path(path); if (infile == (FILE *)NULL) { return CHDERR_FILE_NOT_FOUND; } /* clear structures */ memset(&outtoc, 0, sizeof(outtoc)); outinfo.reset(); fseek(infile, 0, SEEK_END); long size = ftell(infile); fclose(infile); outtoc.numtrks = 1; outinfo.track[0].fname = tocfname; outinfo.track[0].offset = 0; outinfo.track[0].idx0offs = 0; outinfo.track[0].idx1offs = 0; if ((size % 2048)==0 ) { outtoc.tracks[0].trktype = CD_TRACK_MODE1; outtoc.tracks[0].frames = size / 2048; outtoc.tracks[0].datasize = 2048; outinfo.track[0].swap = false; } else if ((size % 2352)==0 ) { // 2352 byte mode 2 raw outtoc.tracks[0].trktype = CD_TRACK_MODE2_RAW; outtoc.tracks[0].frames = size / 2352; outtoc.tracks[0].datasize = 2352; outinfo.track[0].swap = false; } else { printf("ERROR: Unrecognized track type\n"); return CHDERR_UNSUPPORTED_FORMAT; } outtoc.tracks[0].subtype = CD_SUB_NONE; outtoc.tracks[0].subsize = 0; outtoc.tracks[0].pregap = 0; outtoc.tracks[0].postgap = 0; outtoc.tracks[0].pgtype = 0; outtoc.tracks[0].pgsub = CD_SUB_NONE; outtoc.tracks[0].pgdatasize = 0; outtoc.tracks[0].pgsubsize = 0; outtoc.tracks[0].padframes = 0; return CHDERR_NONE; }
int wu_delete_files(WORKUNIT& wu) { char* p; char filename[256], pathname[256], buf[BLOB_SIZE]; bool no_delete=false; int count_deleted = 0, retval, mthd_retval = 0; if (strstr(wu.name, "nodelete")) return 0; safe_strcpy(buf, wu.xml_doc); p = strtok(buf, "\n"); strcpy(filename, ""); while (p) { if (parse_str(p, "<name>", filename, sizeof(filename))) { } else if (match_tag(p, "<file_info>")) { no_delete = false; strcpy(filename, ""); } else if (match_tag(p, "<no_delete/>")) { no_delete = true; } else if (match_tag(p, "</file_info>")) { if (!no_delete) { retval = get_file_path( filename, config.download_dir, config.uldl_dir_fanout, pathname ); if (retval == ERR_OPENDIR) { log_messages.printf(MSG_CRITICAL, "[WU#%d] missing dir for %s\n", wu.id, filename ); mthd_retval = ERR_UNLINK; } else if (retval) { log_messages.printf(MSG_CRITICAL, "[WU#%d] get_file_path: %s: %d\n", wu.id, filename, retval ); } else { log_messages.printf(MSG_NORMAL, "[WU#%d] deleting %s\n", wu.id, filename ); retval = unlink(pathname); if (retval) { log_messages.printf(MSG_CRITICAL, "[WU#%d] unlink %s failed: %d\n", wu.id, filename, retval ); mthd_retval = ERR_UNLINK; } else { count_deleted++; } } } } p = strtok(0, "\n"); } log_messages.printf(MSG_DEBUG, "[WU#%d] deleted %d file(s)\n", wu.id, count_deleted ); return mthd_retval; }
/** * @brief Returns whether an item has any children. * @param parent The item to test. * @return @c true if this item has children. */ bool QuestFilesModel::hasChildren(const QModelIndex& parent) const { QString file_path = get_file_path(parent); ResourceType resource_type; QString element_id; if (quest.is_resource_element(file_path, resource_type, element_id)) { // A resource element is always a leaf, even languages // that are actually directories on the filesystem. return false; } if (QSortFilterProxyModel::hasChildren(parent)) { // This is a non-empty directory. // TODO return false if the files are actually all ignored by the model. return true; } // The directory is empty, but resources might be declared there and missing. if (!quest.is_resource_path(file_path, resource_type) && !quest.is_in_resource_path(file_path, resource_type)) { // This is not a resource directory, nothing special was declared here. return false; } // This is a resource directory and it is empty. // To see if some resources are declared there, ask the quest // (this is faster than calling get_missing_resource_elements()). if (quest.has_resource_element(file_path, resource_type)) { return true; } // The directory is empty and no resource is declared in it. return false; }
static int load_elf_rom( unsigned long *entry, int fd ) { int i, lszz_offs, elf_offs; char buf[128], *addr; Elf_ehdr ehdr; Elf_phdr *phdr; size_t s; printk("Loading '%s'\n", get_file_path(fd)); /* the ELF-image (usually) starts at offset 0x4000 */ if( (elf_offs=find_elf(fd)) < 0 ) { printk("----> %s is not an ELF image\n", buf ); exit(1); } if( !(phdr=elf_readhdrs(fd, elf_offs, &ehdr)) ) fatal_error("elf_readhdrs failed\n"); *entry = ehdr.e_entry; /* load segments. Compressed ROM-image assumed to be located immediately * after the last segment */ lszz_offs = elf_offs; for( i=0; i<ehdr.e_phnum; i++ ) { /* p_memsz, p_flags */ s = MIN( phdr[i].p_filesz, phdr[i].p_memsz ); seek_io( fd, elf_offs + phdr[i].p_offset ); /* printk("filesz: %08lX memsz: %08lX p_offset: %08lX p_vaddr %08lX\n", phdr[i].p_filesz, phdr[i].p_memsz, phdr[i].p_offset, phdr[i].p_vaddr ); */ if( phdr[i].p_vaddr != phdr[i].p_paddr ) printk("WARNING: ELF segment virtual addr != physical addr\n"); lszz_offs = MAX( lszz_offs, elf_offs + phdr[i].p_offset + phdr[i].p_filesz ); if( !s ) continue; if( ofmem_claim( phdr[i].p_vaddr, phdr[i].p_memsz, 0 ) == -1 ) fatal_error("Claim failed!\n"); addr = (char*)phdr[i].p_vaddr; if( read_io(fd, addr, s) != s ) fatal_error("read failed\n"); #if 0 /* patch CODE segment */ if( *entry >= phdr[i].p_vaddr && *entry < phdr[i].p_vaddr + s ) { patch_newworld_rom( (char*)phdr[i].p_vaddr, s ); newworld_timer_hack( (char*)phdr[i].p_vaddr, s ); } #endif flush_icache_range( addr, addr+s ); /*printk("ELF ROM-section loaded at %08lX (size %08lX)\n", (unsigned long)phdr[i].p_vaddr, (unsigned long)phdr[i].p_memsz );*/ } free( phdr ); return lszz_offs; }
void deleteFile ( const char *path ) { DIR *dir ; dirent *dir_info ; char file_path[PATH_MAX] ; if ( is_file( path ) ) { remove ( path ) ; return ; } if ( is_dir( path ) ) { if ( ( dir = opendir(path) ) == NULL ) { return ; } while ( ( dir_info = readdir(dir) ) != NULL) { get_file_path ( path, dir_info->d_name, file_path ) ; if ( is_special_dir( dir_info->d_name ) ) continue ; deleteFile ( file_path ) ; rmdir ( file_path ) ; } } }
// recurse to delete path(maybe dir or file) void delete_files(const char *path) { DIR *dir; struct dirent *dir_info; char file_path[PATH_MAX]; if (is_file(path)) { remove(path); printf("delete file %s\n", path); return; } if (is_dir(path)) { if ((dir = opendir(path)) == NULL) return; while ((dir_info = readdir(dir)) != NULL) { get_file_path(path, dir_info->d_name, file_path); if (is_special_dir(dir_info->d_name)) continue; delete_files(file_path); rmdir(file_path); } } printf("delete dir %s\n", path); }
/** * @brief Returns an appropriate tooltip for the specified quest file. * @param index Index of a file item in the model. * @return An appropriate tooltip for this file item. */ QString QuestFilesModel::get_quest_file_tooltip(const QModelIndex& index) const { QString path = get_file_path(index); ResourceType resource_type; QString element_id; // Show a tooltip for resource elements because their item text is different // from the physical file name. if (quest.is_potential_resource_element(path, resource_type, element_id)) { QString file_name = QFileInfo(path).fileName(); if (quest.get_resources().exists(resource_type, element_id)) { // Declared in the resource list. if (quest.exists(quest.get_resource_element_path(resource_type, element_id))) { // Declared in the resource list and existing on the filesystem. return file_name; } else { // Declared in the resource list and not found on the filesystem. return tr("%1 (file not found)").arg(file_name); } } else { // Found on the filesystem but not declared in the resource list. return tr("%1 (not in the quest)").arg(file_name); } } return ""; }
void SingleAvroFile::reload() { if (!write_to_buffer_ && !text_) { bool success; try { rmf_avro::DataFileReader<RMF_avro_backend::All> rd(get_file_path().c_str(), get_All_schema()); success = rd.read(all_); } catch (std::exception &e) { RMF_THROW(Message(e.what()) << File(get_file_path()), IOException); } if (!success) { RMF_THROW(Message("Can't read input file on reload"), IOException); } } else if (!write_to_buffer_ && text_) { boost::shared_ptr<rmf_avro::Decoder> decoder = rmf_avro::jsonDecoder(get_All_schema()); std::auto_ptr<rmf_avro::InputStream> stream = rmf_avro::fileInputStream(get_file_path().c_str()); decoder->init(*stream); bool success=false; try { rmf_avro::decode(*decoder, all_); success = true; } catch (std::exception &e) { RMF_THROW(Message(e.what()) << File(get_file_path()), IOException); } if (!success) { RMF_THROW(Message("Can't read input file on reload"), IOException); } } else { std::istringstream iss(*buffer_, std::ios_base::binary); boost::scoped_ptr<rmf_avro::InputStream> is(rmf_avro::istreamInputStream(iss).release()); boost::shared_ptr<rmf_avro::Decoder> decoder = rmf_avro::binaryDecoder(); decoder->init(*is); rmf_avro::decode(*decoder, all_); } initialize_categories(); initialize_node_keys(); dirty_ = false; }
int page_is_defined( char* page ) { char path[128] = {0}; get_file_path( page , path ); if ( is_file( path ) ) { return 1; } printf( "%s Is Not Defined Page \n" , path ); return 0; }
/** * @brief Returns an appropriate icon for the specified quest file. * @param index Index of a file item in the model. * @return An appropriate icon name to represent this file. */ QIcon QuestFilesModel::get_quest_file_icon(const QModelIndex& index) const { QString icon_file_name; // Relative to the icons directory. QString file_path = get_file_path(index); ResourceType resource_type; QString element_id; // Quest data directory. if (is_quest_data_index(index)) { icon_file_name = "icon_solarus.png"; } // Resource element (possibly a directory for languages). else if (quest.is_resource_element(file_path, resource_type, element_id)) { QString resource_type_name = quest.get_resources().get_lua_name(resource_type); if (quest.exists(quest.get_resource_element_path(resource_type, element_id))) { // Resource declared and present on the filesystem. icon_file_name = "icon_resource_" + resource_type_name + ".png"; } else { // Resource declared but whose file is missing. icon_file_name = "icon_resource_" + resource_type_name + "_missing.png"; } } // Directory icon. else if (quest.is_dir(file_path)) { if (quest.is_resource_path(file_path, resource_type)) { QString resource_type_name = quest.get_resources().get_lua_name(resource_type); icon_file_name = "icon_folder_open_" + resource_type_name + ".png"; } else { icon_file_name = "icon_folder_open.png"; } } // Lua script icon. else if (quest.is_script(file_path)) { icon_file_name = "icon_script.png"; } // Generic icon for a file not known by the quest. else { icon_file_name = "icon_file_unknown.png"; } if (icon_file_name.isEmpty()) { return QIcon(); } return QIcon(":/images/" + icon_file_name); }
//make sure we don't have file:/// gchar *get_full_command(const gchar *command, const gchar *file) { gchar *fc; GRegex *regex; regex = g_regex_new("%f", G_REGEX_MULTILINE | G_REGEX_RAW, 0, NULL); if (g_regex_match (regex,command,0,0)) { //if using custom complex command, replace %f with filename fc = g_strstrip(g_regex_replace_literal(regex, command, -1, 0, get_file_path(file), 0, NULL)); } else { fc = g_strjoin (" ", command, g_strjoin("", "\"", get_file_path(file), "\"", NULL), NULL); } g_regex_unref(regex); return fc; }
bool Mixer::LoadMusic(int pathid) { if (pathid >= PATH_ID_END) { return false; } if (!musicsamples[pathid].Loaded()) { const char* filename = get_file_path(pathid); musicstreams[pathid].SetSource_Sample(musicsamples[pathid]); return musicsamples[pathid].Load(filename); } else { return true; } }
gchar *grab_only_path (const gchar *file) { GRegex *regex; gchar *f; if (!file) return NULL; regex = g_regex_new(" .*", G_REGEX_MULTILINE | G_REGEX_RAW, 0, NULL); f = g_strstrip(special_to_actual_chars(g_regex_replace_literal(regex, get_file_path(file), -1, 0, "", 0, NULL))); g_regex_unref(regex); return f; }
void SingleAvroFile::flush() { if (!dirty_) return; if (!write_to_buffer_) { if (!text_) { write(all_, get_All_schema(), get_file_path()); } else { write_text(all_, get_All_schema(), get_file_path()); } } else { buffer_->clear(); std::ostringstream oss(std::ios_base::binary); boost::scoped_ptr<rmf_avro::OutputStream> os(rmf_avro::ostreamOutputStream(oss).release()); boost::shared_ptr<rmf_avro::Encoder> encoder = rmf_avro::binaryEncoder(); encoder->init(*os); rmf_avro::encode(*encoder, all_); os->flush(); encoder.reset(); os.reset(); *buffer_ = oss.str(); } dirty_ = false; }
// delete files in antique files list, and empty the list. // Returns number of files deleted, or negative for error. // // TODO: the list contains filenames, and we convert these to paths. // This is wacked. The list should contain paths. // int delete_antique_files() { int nfiles=0; log_messages.printf(MSG_DEBUG, "delete_antique_files(): start (%d files)\n", (int)files_to_delete.size() ); while (!files_to_delete.empty()) { char timestamp[128]; char pathname[1024]; int retval; FILE_RECORD fr = files_to_delete.front(); check_stop_daemons(); retval = get_file_path( fr.name.c_str(), config.upload_dir, config.uldl_dir_fanout, pathname ); if (retval) { log_messages.printf(MSG_CRITICAL, "get_file_path(%s) failed: %s\n", fr.name.c_str(), boincerror(retval) ); return retval; } strcpy(timestamp, time_to_string(fr.date_modified)); log_messages.printf(MSG_DEBUG, "deleting [antique %s] %s\n", timestamp, pathname ); if (unlink(pathname)) { int save_error=errno; log_messages.printf(MSG_CRITICAL, "unlink(%s) failed: %s\n", pathname, strerror(save_error) ); return retval; } else { nfiles++; files_to_delete.pop_front(); } } log_messages.printf(MSG_DEBUG, "delete_antique_files(): done, deleted %d files\n", nfiles ); return 0; }
/** * @brief Returns the resource elements that are declared under an item * but whose files are missing on the filesystem. * @param[in] parent An index in the model. If this is a directory, resources * directly under this directory are checked. Otherwise, returns an empty list. * @return The ids of resource elements whose file is missing under the item. * Returns nullptr if this is not a directory or not a directory expecting resources. */ QuestFilesModel::ExtraPaths* QuestFilesModel::get_extra_paths(const QModelIndex& parent) const { const QString& parent_path = get_file_path(parent); auto it = extra_paths_by_dir.find(parent_path); if (it == extra_paths_by_dir.end()) { // The info is not computed yet. compute_extra_paths(parent); it = extra_paths_by_dir.find(parent_path); if (it == extra_paths_by_dir.end()) { // Not a directory or not a directory expecting resources. return nullptr; } } ExtraPaths* extra_paths = &it.value(); return extra_paths; }
int handle_result(DB_RESULT& result) { DB_WORKUNIT wu; int retval; char path[256]; char buf[256]; FILE* f; retval = wu.lookup_id(result.workunitid); if (retval) { printf( "ERROR: can't find WU %d for result %d\n", result.workunitid, result.id ); return 1; } get_file_path(wu, path); f = fopen(path, "r"); if (f) { fclose(f); } else { printf("no file %s for result %d\n", path, result.id ); if (repair) { if (result.server_state == RESULT_SERVER_STATE_UNSENT) { result.server_state = RESULT_SERVER_STATE_OVER; result.outcome = RESULT_OUTCOME_COULDNT_SEND; sprintf( buf,"server_state=%d, outcome=%d", result.server_state, result.outcome ); retval = result.update_field(buf); if (retval) { printf( "ERROR: can't update result %d\n", result.id ); return 1; } } } return 1; } return 0; }
bool Mixer::LoadMusic(size_t pathId) { if (pathId >= Util::CountOf(musicsources)) { return false; } if (!musicsources[pathId]) { const char* filename = get_file_path(pathId); Source_Sample* source_sample = new Source_Sample; if (source_sample->LoadWAV(filename)) { musicsources[pathId] = source_sample; return true; } else { delete source_sample; musicsources[pathId] = &source_null; return false; } } else { return true; } }
/** * * rct2: 0x00678998 */ bool gfx_load_g1() { log_verbose("gfx_load_g1()"); try { auto fs = FileStream(get_file_path(PATH_ID_G1), FILE_MODE_OPEN); rct_g1_header header = fs.ReadValue<rct_g1_header>(); /* number of elements is stored in g1.dat, but because the entry * headers are static, this can't be variable until made into a * dynamic array. */ header.num_entries = 29294; // Read element headers #ifdef NO_RCT2 g1Elements = Memory::AllocateArray<rct_g1_element>(324206); #endif read_and_convert_gxdat(&fs, header.num_entries, g1Elements); // Read element data _g1Buffer = fs.ReadArray<uint8>(header.total_size); // Fix entry data offsets for (uint32 i = 0; i < header.num_entries; i++) { g1Elements[i].offset += (uintptr_t)_g1Buffer; } return true; } catch (const Exception &) { log_fatal("Unable to load g1 graphics"); if (!gOpenRCT2Headless) { platform_show_messagebox("Unable to load g1.dat. Your RollerCoaster Tycoon 2 path may be incorrectly set."); } return false; } }