static quik_err_t get_load_paths(path_t **kernel, path_t **initrd, char **params) { quik_err_t err; char *kernel_spec = NULL; char *initrd_spec = NULL; env_dev_t cur_dev = { 0 }; err = get_params(&kernel_spec, &initrd_spec, params, &cur_dev); if (err != ERR_NONE) { return err; } /* * In case get_params didn't set the device or partition, * propagate from the default device path. */ env_dev_update_from_default(&cur_dev); err = file_path(kernel_spec, &cur_dev, kernel); if (err != ERR_NONE) { printk("Error parsing kernel path '%s': %r\n", kernel_spec, err); return err; } /* * If cur_dev is bogus, fill it with dev info * from parsing the kernel path. This lets you * be less verbose speccing out the initrd path. */ if (env_dev_is_valid(&cur_dev) != ERR_NONE) { env_dev_set_part(&cur_dev, (*kernel)->part); cur_dev.device = (*kernel)->device; } if (initrd_spec != NULL) { err = file_path(initrd_spec, &cur_dev, initrd); if (err != ERR_NONE) { printk("Error parsing initrd path '%s': %r\n", initrd_spec, err); free(kernel); return err; } } return ERR_NONE; }
StatusLine FileReader::get_resource(const std::string& abs_path,Entity& saver) { StatusLine ret(http_200,""); std::string full_path=m_doc_root+abs_path; try { boost::filesystem::path file_path(full_path); if(boost::filesystem::exists(file_path) ) { if (is_regular_file(file_path)) { ret = read_file(full_path,saver); } else if (is_directory(file_path)) { ret.reson_pharse()="can not get a directory :" + full_path; ret.status_code().code()=http_403; } else { ret.reson_pharse()=full_path+ " is neither a regular file nor a directory"; ret.status_code().code()=http_409; } } else { ret.reson_pharse()=full_path+ " is not exists"; ret.status_code().code()=http_404; } } catch (boost::filesystem::filesystem_error& e) { ret.reson_pharse()=e.what(); ret.status_code().code()=http_500; } catch (std::exception& e) { ret.reson_pharse()=e.what(); ret.status_code().code()=http_500; } catch (...) { ret.reson_pharse()="Unkonw exception"; ret.status_code().code()=http_500; } return ret; }
/* * bitmap_file_kick - if an error occurs while manipulating the bitmap file * then it is no longer reliable, so we stop using it and we mark the file * as failed in the superblock */ static void bitmap_file_kick(struct bitmap *bitmap) { char *path, *ptr = NULL; if (bitmap_mask_state(bitmap, BITMAP_STALE, MASK_SET) == 0) { bitmap_update_sb(bitmap); if (bitmap->file) { path = kmalloc(PAGE_SIZE, GFP_KERNEL); if (path) ptr = file_path(bitmap->file, path, PAGE_SIZE); printk(KERN_ALERT "%s: kicking failed bitmap file %s from array!\n", bmname(bitmap), ptr ? ptr : ""); kfree(path); } else printk(KERN_ALERT "%s: disabling internal bitmap due to errors\n", bmname(bitmap)); } bitmap_file_put(bitmap); return; }
long pgsDictionaryGen::count_lines() { long result = 0; wxFileName file_path(m_file_path); if (file_path.FileExists() && file_path.IsFileReadable()) { wxFFileInputStream input(m_file_path); if (input.IsOk()) { #if wxUSE_UNICODE wxTextInputStream text(input, wxT(" \t"), m_conv); #else wxTextInputStream text(input, wxT(" \t")); #endif wxString line; while (!(line = text.ReadLine()).IsEmpty() && !input.Eof()) { ++result; } } } if (result < 0) result = 0; wxASSERT(result >= 0); return result; }
// // int main() // /// Main driver, choose which file to parse and call testParse. /// /// \param argc the count of arguments. /// \param argv the vector containing the arguments. /// /// \return always zero. // int main(int argc, char* argv[]) { bool success(true); // // Try to open the filename given on the command line, otherwise // try to open "default.eve". // try { boost::filesystem::path file_path("default.eve"); if (argc > 1) file_path = boost::filesystem::path(argv[1]); // // Call our testParse function with the selected filename. // testParse(file_path); } catch (const std::exception& error) { // // Oops, something didn't work out. // std::cerr << "Exception: " << error.what() << std::endl; success = false; } catch (...) { std::cerr << "Unknown exception" << std::endl; success = false; } return success ? 0 : 1; }
void NewGeneMainWindow::on_actionSave_Output_Dataset_As_triggered() { if (outp == nullptr) { QMessageBox::information(nullptr, "NewGene", "No output project is currently open."); return; } UIMessager messager; OpenOutputFilePath::instance folder_path = OpenOutputFilePath::get(messager); QString the_file = QFileDialog::getSaveFileName(this, "Select a name and location for the copied output dataset", folder_path ? folder_path->getPath().string().c_str() : "", "NewGene output settings file (*.xml)", nullptr, QFileDialog::DontConfirmOverwrite); if (the_file.size()) { std::string the_file_str = the_file.toStdString(); checkValidProjectFilenameExtension(false, the_file_str, true); the_file = the_file_str.c_str(); boost::filesystem::path file_path(the_file.toStdString()); settingsManagerUI().globalSettings().getUISettings().UpdateSetting(messager, GLOBAL_SETTINGS_UI_NAMESPACE::OPEN_OUTPUT_DATASET_FOLDER_PATH, OpenOutputFilePath(messager, file_path.parent_path())); emit SignalSaveCurrentOutputDatasetAs(the_file.toStdString(), this); } }
void NewGeneMainWindow::on_actionNew_Output_Dataset_triggered() { UIMessager messager; OpenOutputFilePath::instance folder_path = OpenOutputFilePath::get(messager); QString the_file = QFileDialog::getSaveFileName(this, "Select a name and location for the new output dataset", folder_path ? folder_path->getPath().string().c_str() : "", "NewGene output settings file (*.xml)"); if (the_file.size()) { std::string the_file_str = the_file.toStdString(); checkValidProjectFilenameExtension(false, the_file_str, true); the_file = the_file_str.c_str(); if (!boost::filesystem::exists(the_file.toStdString())) { boost::filesystem::path file_path(the_file.toStdString()); settingsManagerUI().globalSettings().getUISettings().UpdateSetting(messager, GLOBAL_SETTINGS_UI_NAMESPACE::OPEN_OUTPUT_DATASET_FOLDER_PATH, OpenOutputFilePath(messager, file_path.parent_path())); newOutputDataset = true; // kluge; see header emit SignalOpenOutputDataset(the_file.toStdString(), this); } } }
map<fc::time_point, fc::exception> client_impl::debug_list_errors( int32_t first_error_number, uint32_t limit, const string& filename )const { map<fc::time_point, fc::exception> result; int count = 0; auto itr = _exception_db.begin(); while( itr.valid() ) { ++count; if( count > first_error_number ) { result[itr.key()] = itr.value(); if (--limit == 0) break; } ++itr; } if( filename != "" ) { fc::path file_path( filename ); FC_ASSERT( !fc::exists( file_path ) ); std::ofstream out( filename.c_str() ); for( auto item : result ) { out << std::string(item.first) << " " << item.second.to_detail_string() <<"\n-----------------------------\n"; } } return result; }
/** * FS_User::OpenFile service function * Inputs: * 1 : Transaction * 2 : Archive handle lower word * 3 : Archive handle upper word * 4 : Low path type * 5 : Low path size * 6 : Open flags * 7 : Attributes * 8 : (LowPathSize << 14) | 2 * 9 : Low path data pointer * Outputs: * 1 : Result of function, 0 on success, otherwise error code * 3 : File handle */ static void OpenFile(Service::Interface* self) { u32* cmd_buff = Service::GetCommandBuffer(); // TODO(Link Mauve): cmd_buff[2], aka archive handle lower word, isn't used according to // 3dmoo's or ctrulib's implementations. Triple check if it's really the case. Handle archive_handle = static_cast<Handle>(cmd_buff[3]); auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[4]); u32 filename_size = cmd_buff[5]; FileSys::Mode mode; mode.hex = cmd_buff[6]; u32 attributes = cmd_buff[7]; // TODO(Link Mauve): do something with those attributes. u32 filename_ptr = cmd_buff[9]; FileSys::Path file_path(filename_type, filename_size, filename_ptr); DEBUG_LOG(KERNEL, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex, attributes); ResultVal<Handle> handle = Kernel::OpenFileFromArchive(archive_handle, file_path, mode); cmd_buff[1] = handle.Code().raw; if (handle.Succeeded()) { cmd_buff[3] = *handle; } else { ERROR_LOG(KERNEL, "failed to get a handle for file %s", file_path.DebugStr().c_str()); } DEBUG_LOG(KERNEL, "called"); }
vfsDevice* VFS::GetDeviceLocal(const std::string& local_path, std::string& path) const { u32 max_eq; s32 max_i=-1; wxFileName file_path(fmt::FromUTF8(local_path)); file_path.Normalize(); std::string mormalized_path = fmt::ToUTF8(file_path.GetFullPath()); for(u32 i=0; i<m_devices.size(); ++i) { const u32 eq = m_devices[i]->CmpLocalPath(mormalized_path); if(max_i < 0 || eq > max_eq) { max_eq = eq; max_i = i; } } if(max_i < 0) return nullptr; path = vfsDevice::GetPs3Path(m_devices[max_i]->GetPs3Path(), local_path.substr(max_eq, local_path.length() - max_eq)); return m_devices[max_i]; }
static void apply_changes_on_x(const char *current, const String *previous) { if(repeat_press_value) XAutoRepeatOn(fl_display); else XAutoRepeatOff(fl_display); /* do not do anything if selected layout is the same as previous */ if(!previous || *previous != current) { /* * believe me, it is easier to call this command than to reimplmement a mess for * uploading keyboard layout on X server! */ String setxkbmap = file_path("setxkbmap"); if(setxkbmap.empty()) { alert(_("Unable to find 'setxkbmap' tool.\n\nThis tool is used as helper tool for " "easier keyboard setup and is standard tool shipped with every X package. " "Please install it first and run this program again.")); } else { int ret = run_sync("%s %s", setxkbmap.c_str(), current); /* do not show dialog since we can fail if config has bad entry when called from apply_chages_from_config() */ if(ret != 0) E_WARNING(E_STRLOC ": 'setxkbmap %s' failed with %i\n", current, ret); } } /* force panel applet to re-read config file to see if flag should be displayed or not */ foreign_callback_call(PANEL_APPLET_ID); }
static int cn_print_exe_file(struct core_name *cn) { struct file *exe_file; char *pathbuf, *path; int ret; exe_file = get_mm_exe_file(current->mm); if (!exe_file) return cn_esc_printf(cn, "%s (path unknown)", current->comm); pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY); if (!pathbuf) { ret = -ENOMEM; goto put_exe_file; } path = file_path(exe_file, pathbuf, PATH_MAX); if (IS_ERR(path)) { ret = PTR_ERR(path); goto free_buf; } ret = cn_esc_printf(cn, "%s", path); free_buf: kfree(pathbuf); put_exe_file: fput(exe_file); return ret; }
fs::path filestorage::get_parent_path(t_filestore file_type, const std::string &filename) { fs::path user_home(getenv("HOME")); fs::path parent_path(user_home.c_str()); switch (file_type) { case e_filestore_galaxy_wallet_PRV: { parent_path += "/.config/antinet/galaxy42/wallet/"; break; } case e_filestore_galaxy_pub: { parent_path += "/.config/antinet/galaxy42/public/"; break; } case e_filestore_galaxy_sig: { parent_path += "/.config/antinet/galaxy42/public/"; break; } case e_filestore_local_path: { fs::path file_path(filename); parent_path = file_path.parent_path(); break; } } return parent_path; }
/* Does the actual work of handling the client. This allows spawn_handler to * create a new thread and immediately return. */ static void handler(int fd) { Request req; main_log << DEBUG << "Reading request..."; req = read_request(fd); main_log << DEBUG <<"Finished reading request."; std::string file_path(get_config("root_dir")); file_path=file_path + "/" + req.URI; int error_code; std::string response_body = get_resource(file_path,NULL,error_code); if (!response_body.size()) { main_log << ERROR << "Server error occurred. Ending handler...\n"; return; } if (send_data(fd,response_body.c_str())) { main_log << WARNING << "Server error occured. Ending handler...\n"; return; } return; }
vfsDevice* VFS::GetDeviceLocal(const wxString& local_path, wxString& path) const { u32 max_eq; s32 max_i=-1; wxFileName file_path(local_path); file_path.Normalize(); wxString mormalized_path = file_path.GetFullPath(); for(u32 i=0; i<m_devices.GetCount(); ++i) { const u32 eq = m_devices[i].CmpLocalPath(mormalized_path); if(max_i < 0 || eq > max_eq) { max_eq = eq; max_i = i; } } if(max_i < 0) return nullptr; path = vfsDevice::GetPs3Path(m_devices[max_i].GetPs3Path(), local_path(max_eq, local_path.Len() - max_eq)); return &m_devices[max_i]; }
bool StatisticsCollectionConfigurationFile::TryLoad(string& config_xml, std::time_t& file_modified_time) { config_xml = ""; boost::filesystem::path file_path(local_config_file_path_); if (false == base::filesystem::exists_nothrow(file_path)) { return false; } std::ifstream input_file_stream(local_config_file_path_.c_str()); if (input_file_stream) { string config_string; util::archive::BinaryIArchive<> ar(input_file_stream); ar >> config_xml; input_file_stream.close(); boost::system::error_code code; base::filesystem::last_write_time_nothrow(file_path, file_modified_time, code); if (!code) { return true; } } return false; }
void wmdf::Directory::GetAllFileOfPath( const std::string& path,std::vector<std::string>& files ) { bfs::path file_path(path); if (!bfs::exists(file_path)) return; if(bfs::is_directory(file_path))//可能为目录 { bfs::directory_iterator end_itr; // 缺省构造生成一个结束迭代器 for ( bfs::directory_iterator iter( file_path );iter != end_itr;++iter ) { if(bfs::is_directory(iter->path()))//可能为目录 { GetAllFileOfPath(iter->path().string(),files); } else { files.push_back(iter->path().string()); } } } else { files.push_back(file_path.string()); } }
std::string VIVADO_xsim_wrapper::create_project_script(const std::string& top_filename, const std::list<std::string>& file_list) { std::string project_filename = XSIM_SUBDIR + suffix + "/" + top_filename + ".prj"; std::ofstream prj_file(project_filename.c_str()); for(auto const file : file_list) { boost::filesystem::path file_path(file); std::string extension = GetExtension(file_path); std::string filename; std::string language; if(extension == "vhd" || extension == "vhdl" || extension == "VHD" || extension == "VHDL") language = "VHDL"; else if(extension == "v" || extension == "V" || extension == "sv") language = "VERILOG"; else THROW_ERROR("Extension not recognized! "+extension); filename = file_path.string(); if(filename[0] == '/') prj_file << language << " " << "work" << " " << filename << std::endl; else prj_file << language << " " << "work" << " " << boost::filesystem::current_path().string() << "/" << filename << std::endl; } prj_file.close(); return project_filename; }
static void show_faulting_vma(unsigned long address) { struct vm_area_struct *vma; struct mm_struct *active_mm = current->active_mm; /* can't use print_vma_addr() yet as it doesn't check for * non-inclusive vma */ down_read(&active_mm->mmap_sem); vma = find_vma(active_mm, address); /* check against the find_vma( ) behaviour which returns the next VMA * if the container VMA is not found */ if (vma && (vma->vm_start <= address)) { char buf[ARC_PATH_MAX]; char *nm = "?"; if (vma->vm_file) { nm = file_path(vma->vm_file, buf, ARC_PATH_MAX-1); if (IS_ERR(nm)) nm = "?"; } pr_info(" @off 0x%lx in [%s]\n" " VMA: 0x%08lx to 0x%08lx\n", vma->vm_start < TASK_UNMAPPED_BASE ? address : address - vma->vm_start, nm, vma->vm_start, vma->vm_end); } else pr_info(" @No matching VMA found\n"); up_read(&active_mm->mmap_sem); }
void NewGeneMainWindow::on_actionOpen_Output_Dataset_triggered() { UIMessager messager; OpenOutputFilePath::instance folder_path = OpenOutputFilePath::get(messager); QString the_file = QFileDialog::getOpenFileName(this, "Choose output dataset", folder_path ? folder_path->getPath().string().c_str() : "", "NewGene output settings file (*.xml)"); if (the_file.size()) { std::string the_file_str = the_file.toStdString(); if (checkValidProjectFilenameExtension(false, the_file_str)) { if (boost::filesystem::exists(the_file.toStdString()) && !boost::filesystem::is_directory(the_file.toStdString())) { boost::filesystem::path file_path(the_file.toStdString()); settingsManagerUI().globalSettings().getUISettings().UpdateSetting(messager, GLOBAL_SETTINGS_UI_NAMESPACE::OPEN_OUTPUT_DATASET_FOLDER_PATH, OpenOutputFilePath(messager, file_path.parent_path())); emit SignalOpenOutputDataset(the_file.toStdString(), this); } } } }
static void report_cb(Fl_Widget*, void*) { String bug_tool = file_path("ede-bug-report"); if(bug_tool.empty()) { alert(_("Unable to find ede-bug-report tool." " Please check if PATH variable contains directory where this tool was installed")); return; } collect_info_once(); TempFile tmp; if(!tmp.create("/tmp/.ecrash-dump")) { alert(_("Unable to create temporary file: (%i) %s"), tmp.status(), strerror(tmp.status())); return; } /* close it since we need the file name */ tmp.close(); txt_buf->savefile(tmp.name()); run_async("%s --gdb-dump %s", bug_tool.c_str(), tmp.name()); /* wait some time until the file was read; dumb, I know :( */ sleep(1); /* remove it */ tmp.unlink(); }
int LocalDirReader::read_file_with_meta(butil::IOBuf* out, const std::string &filename, google::protobuf::Message* file_meta, off_t offset, size_t max_count, bool* is_eof) const { out->clear(); std::string file_path(_path + "/" + filename); butil::File::Error e; FileAdaptor* file = _fs->open(file_path, O_RDONLY | O_CLOEXEC, file_meta, &e); if (!file) { return file_error_to_os_error(e); } std::unique_ptr<FileAdaptor, DestroyObj<FileAdaptor> > guard(file); butil::IOPortal buf; ssize_t nread = file->read(&buf, offset, max_count); if (nread < 0) { return EIO; } *is_eof = false; if ((size_t)nread < max_count) { *is_eof = true; } else { ssize_t size = file->size(); if (size < 0) { return EIO; } if (size == ssize_t(offset + max_count)) { *is_eof = true; } } out->swap(buf); return 0; }
int init_msg_tau (const char *name) { ssize_t rc; msg_s m; if (Msg_fd) { fprintf(stderr, "Message system already initialized %d\n", Msg_fd); return EBUSY; } Msg_fd = open(Dev_name, O_RDWR); if (Msg_fd == -1) { Msg_fd = 0; fprintf(stderr, "Couldn't open %s to initalize message system %s\n", Dev_name, strerror(errno)); return errno; } strncpy(Process_name, file_path(name), TAU_NAME); Process_name[TAU_NAME-1] = '\0'; strncpy(m.my_name, Process_name, TAU_NAME); rc = pread(Msg_fd, &m, sizeof(msg_s), MSG_NAME); if (rc != 0) { shutdown_msg_tau(); } RTN(rc); }
/// If entry in zipfile is a file, then read the file and write the /// uncompressed data at the proper filepath. int ZIP_Wrapper::handlethefile (char* filename_inzip, unzFile uf, unz_file_info file_info, bool verbose, ACE_CString arch_dir) { int k = unzOpenCurrentFile(uf); if (k!=UNZ_OK) { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR,ACE_TEXT("unzOpenCurrentFile failed in" " opening the current file"))); return false; } else { size_t const file_size = file_info.uncompressed_size; char* temp = 0; ACE_NEW_RETURN (temp, char [file_size], false); ACE_Auto_Basic_Array_Ptr<char> buffer (temp); //read in the data unzReadCurrentFile(uf, &(*buffer), file_size); //close the zip handle unzCloseCurrentFile(uf); //create file name + path to open std::string file_path (arch_dir.c_str ()); //NOTE: need the c-style char to stop at '\0' file_path += "/"; file_path += filename_inzip; //print out the file to be uncompressed if (verbose) { ACE_OS::write(ACE_STDOUT, file_path.c_str (), file_path.length () ); ACE_OS::write(ACE_STDOUT, "\n", 1); } // Open a file handle to the local filesystem ACE_HANDLE handle = ACE_OS::open (file_path.c_str (), O_CREAT | O_TRUNC | O_WRONLY); if (handle == ACE_INVALID_HANDLE) { unzClose(uf); DANCE_ERROR_RETURN (DANCE_LOG_ERROR, (LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("[uncompress] file creation error")), 0); } //write the uncompressed data to the file if (ACE_OS::write (handle, &(*buffer), file_size) == -1) { unzClose(uf); DANCE_ERROR_RETURN (DANCE_LOG_ERROR, (LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("[uncompress] file write error")), 0); } // Close the file handle ACE_OS::close (handle); } return 0; }
void LevelData::writeUserData() { char app_dir[255]; int ret = PDL_GetDataFilePath("my_data.mja", app_dir, 256); string file_path(app_dir); ofstream config_file(file_path.c_str()); if (config_file.is_open()) { if (!current_level.empty() && getDetailsById(current_level).filename != "end_scene.xml") { config_file << "(inp)" << endl; config_file << "core:" << current_level << endl; config_file << "(endinp)" << endl; } config_file << "(lvl)" << endl; vector<LevelDetails>::iterator iter; for (iter = core_levels.begin(); iter != core_levels.end(); iter++) { string score = iter->score; if (score == "--") score = "0"; if (iter->filename != "end_scene.xml") { // cout << "s: " << score << endl; cout << iter->id << ":" << score << ":" << iter->completed << ":" << iter->unlocked << ":" << iter->stars << endl; config_file << iter->id << ":" << score << ":" << iter->completed << ":" << iter->unlocked << ":" << iter->stars << endl; } } config_file << "(endlvl)"; } config_file.close(); // rename tmp_save.mja to user_data.mja // int res = rename("./tmp_save.mja", "./my_data.mja"); }
Stream* Manager::getStream(const std::string& file_name) { /// search for cached streams std::string file_path(findFilePath(file_name)) ; std::map<std::string,Stream*>::const_iterator stream = m_cached_streams.find(file_path) ; if (stream != m_cached_streams.end()) { return stream->second ; } Stream* result = NULL ; if (file_name.find(".ogg") != std::string::npos) { result = new OggFileStream(file_path) ; m_streams.insert(result) ; } else if (file_name.find(".wav") != std::string::npos) { result = new WavFileStream(file_path) ; m_streams.insert(result) ; } else { ErrorMessage("[OpenAl::Manager] unsupported file type") ; } return result ; }
v8::Handle<v8::Value> LoadHistoryFromCurrentState(const v8::Arguments& args) { v8::HandleScope scope; if (args.Length() != 1) { ThrowException(v8::Exception::TypeError(v8::String::New("Wrong number of arguments"))); return scope.Close(v8::Undefined()); } if (!args[0]->IsString()) { ThrowException(v8::Exception::TypeError(v8::String::New("Wrong arguments"))); return scope.Close(v8::Undefined()); } v8::String::AsciiValue file_path(args[0]->ToString()); switcher_is_loading = true; switcher::QuiddityManager::CommandHistory histo = switcher_container[0]->get_command_history_from_file (std::string (*file_path).c_str ()); if (histo.empty ()) { v8::Handle<v8::String> res = v8::String::New("false"); return scope.Close(res); } switcher_container[0]->play_command_history (histo, NULL, NULL, true); v8::Handle<v8::String> res = v8::String::New("true"); switcher_is_loading = false; return scope.Close(res); }
void ReadTextFile(const tstring & file, tstring & text, DirectoryMode directory) { #ifdef ANDROID if(directory == DirectoryMode::assets) { SerializedData data; star_a::ReadFileAsset(file, data); text = string_cast<tstring>(data.data); delete [] data.data; } else { text = _T(""); auto app = StarEngine::GetInstance()->GetAndroidApp(); sstringstream strstr; if(directory == DirectoryMode::internal) { strstr << app->activity->internalDataPath << "/"; } else if(directory == DirectoryMode::external) { strstr << app->activity->internalDataPath << "/"; } strstr << string_cast<sstring>(file); sifstream myfile; myfile.open(strstr.str(), std::ios::in); bool succes = myfile.is_open(); ASSERT(succes, (_T("Couldn't open the text file '") + strstr.str() + _T("'.")).c_str()); if(succes) { sstring str; while (std::getline(myfile,str)) { text += str; } myfile.close(); } } #else tifstream myfile; tstring file_path(EMPTY_STRING); Filepath::GetCorrectPath(file, file_path, directory); myfile.open(file_path, std::ios::in); bool succes = myfile.is_open(); ASSERT(succes, (_T("Couldn't open the text file '") + file_path + _T("'.")).c_str()); if(succes) { tstring str; while (std::getline(myfile,str)) { text += str; } myfile.close(); } #endif }
int main(int argc, char *argv[]) { std::wstring file_path( L"ExampleModel.ifc" ); if( argc > 1 ) { std::string arg1 = argv[1]; if( arg1.length() > 4 ) { std::string ext = arg1.substr( arg1.find_last_of( "." ) + 1 ); if( boost::iequals( ext, "ifc" ) ) { file_path.assign( arg1.begin(), arg1.end() ); } } } shared_ptr<IfcPPModel> ifc_model( new IfcPPModel() ); shared_ptr<IfcPPReaderSTEP> reader( new IfcPPReaderSTEP() ); reader->loadModelFromFile( file_path, ifc_model ); const boost::unordered_map<int, shared_ptr<IfcPPEntity> >& map_ifc_entities = ifc_model->getMapIfcEntities(); for( auto it = map_ifc_entities.begin(); it != map_ifc_entities.end(); ++it ) { int entity_id = it->first; const shared_ptr<IfcPPEntity>& ifcpp_entity = it->second; shared_ptr<IfcProduct> ifc_product = dynamic_pointer_cast<IfcProduct>( ifcpp_entity ); if( ifc_product ) { // entity is an IfcProduct, we can access its attributes now: if( ifc_product->m_Name ) { std::wcout << "name: " << ifc_product->m_Name->m_value; } if( ifc_product->m_Description ) { std::wcout << ", description: " << ifc_product->m_Description->m_value; } if( ifc_product->m_GlobalId ) { std::wcout << ", Globally Unique ID: " << ifc_product->m_GlobalId->m_value << std::endl; } // also inverse attributes can be accessed: std::vector<weak_ptr<IfcRelAssigns> >& vec_has_assignments = ifc_product->m_HasAssignments_inverse; std::vector<weak_ptr<IfcRelNests> >& vec_nests = ifc_product->m_Nests_inverse; std::vector<weak_ptr<IfcRelNests> >& vec_is_nested_by = ifc_product->m_IsNestedBy_inverse; std::vector<weak_ptr<IfcRelDeclares> >& vec_has_context = ifc_product->m_HasContext_inverse; std::vector<weak_ptr<IfcRelAggregates> >& vec_is_decomposed = ifc_product->m_IsDecomposedBy_inverse; std::vector<weak_ptr<IfcRelAggregates> >& vec_decomposes = ifc_product->m_Decomposes_inverse; std::vector<weak_ptr<IfcRelAssociates> >& vec_has_associations = ifc_product->m_HasAssociations_inverse; } } return 0; }
void StatisticsCollectionConfigurationFile::Remove() { boost::filesystem::path file_path(local_config_file_path_); if (base::filesystem::exists_nothrow(file_path)) { base::filesystem::remove_nothrow(file_path); } }