void CMaNGOS_Map::ScanFoldersForMaps() { scanDirectory("maps", "*.map", m_MapFiles); scanDirectory("vmaps", "*.vmtree", m_VMapFiles); m_MapsFound.clear(); for (FileList::const_iterator itr = m_MapFiles.begin(); itr != m_MapFiles.end(); itr++) { string fullname(*itr); int lastsep = fullname.find_last_of("/"); string fname = fullname.substr(lastsep + 1); string mapStr = fname.substr(0, 3); unsigned int mapId = atoi(mapStr.c_str()); m_MapsFound.insert(mapId); } for (FileList::const_iterator itr = m_VMapFiles.begin(); itr != m_VMapFiles.end(); itr++) { string fullname(*itr); int lastsep = fullname.find_last_of("/"); string fname = fullname.substr(lastsep + 1); string mapStr = fname.substr(0, 3); unsigned int mapId = atoi(mapStr.c_str()); m_MapsFound.insert(mapId); } m_mapID = *m_MapsFound.begin(); }
int samepath(char *a, char *b) { char a1[MAXPATH],b1[MAXPATH]; fullname(a, a1); fullname(b, b1); return (patheq(a1, b1)); }
/** * Computes the real fileinfo and pathinfo part. * * Modifies: * <ul> * <li>pathinfo</li> * <li>fileinfo</li> * </ul> */ void HttpRequest::updatePathInfo() { if (!fileinfo) return; // split "/the/tail" from "/path/to/script.php/the/tail" std::string fullname(fileinfo->path()); size_t origpos = fullname.size() - 1; size_t pos = origpos; for (;;) { if (fileinfo->exists()) { if (pos != origpos) pathinfo = path.ref(path.size() - (origpos - pos + 1)); break; } if (fileinfo->error() == ENOTDIR) { pos = fileinfo->path().rfind('/', pos - 1); fileinfo = connection.worker().fileinfo(fileinfo->path().substr(0, pos)); } else { break; } } }
// ----------------------------------------------------------------------------- // CSIPHeaderBase::ToTextL // ----------------------------------------------------------------------------- // EXPORT_C HBufC8* CSIPHeaderBase::ToTextL() const { TPtrC8 fullname(Name().DesC()); // Because SIP Codec's string table has entry "expires" before "Expires", // and entry "require" before "Require", // literal "Expires" and "Require" must be used here. // Changing the order of string table entries would have caused a SC break. if (Name() == SIPStrings::StringF(SipStrConsts::EExpiresHeader)) { fullname.Set(KExpiresHeaderNameDes); } else if (Name() == SIPStrings::StringF(SipStrConsts::ERequireHeader)) { fullname.Set(KRequireHeaderNameDes); } else { } TUint headerLength = fullname.Length(); headerLength += KColonAndSpace().Length(); HBufC8* encodedHeaderValue = ToTextValueL(); headerLength += encodedHeaderValue->Length(); CleanupStack::PushL (encodedHeaderValue); HBufC8* encodedHeader = HBufC8::NewL(headerLength); TPtr8 encodedHeaderPtr = encodedHeader->Des(); encodedHeaderPtr.Append(fullname); encodedHeaderPtr.Append(KColonAndSpace); encodedHeaderPtr.Append(*encodedHeaderValue); CleanupStack::PopAndDestroy(encodedHeaderValue); return encodedHeader; }
int main() { printf("Alan Yachmenyev\n"); name(); fullname(); return 0; }
std::string mitk::ImageSerializer::Serialize() { const Image* image = dynamic_cast<const Image*>( m_Data.GetPointer() ); if (!image) { MITK_ERROR << " Object at " << (const void*) this->m_Data << " is not an mitk::Image. Cannot serialize as image."; return ""; } std::string filename( this->GetUniqueFilenameInWorkingDirectory() ); std::cout << "creating file " << filename << " in " << m_WorkingDirectory << std::endl; filename += "_"; filename += m_FilenameHint; std::string fullname(m_WorkingDirectory); fullname += Poco::Path::separator(); fullname += filename + ".nrrd"; try { IOUtil::Save(image, fullname); } catch (std::exception& e) { MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data << " to " << fullname << ": " << e.what(); return ""; } return Poco::Path(fullname).getFileName();// + ".pic"; }
wxString EditorColourSet::GetSampleCode(HighlightLanguage lang, int* breakLine, int* debugLine, int* errorLine) { if (lang == HL_NONE) return wxEmptyString; OptionSet& mset = m_Sets[lang]; if (breakLine) *breakLine = mset.m_BreakLine; if (debugLine) *debugLine = mset.m_DebugLine; if (errorLine) *errorLine = mset.m_ErrorLine; const wxString shortname = _T("lexer_") + lang + _T(".sample"); // user path first wxString path = ConfigManager::GetFolder(sdDataUser) + _T("/lexers/"); wxFileName fullname( path + shortname ); if ( ! fullname.FileExists(path + shortname) ) { // global path next path = ConfigManager::GetFolder(sdDataGlobal) + _T("/lexers/"); } if (!mset.m_SampleCode.IsEmpty()) return path + mset.m_SampleCode; return wxEmptyString; }
// msmeyer: Large parts of this function have been copied from 'ProjectFSCK'. // Might want to unify / modularize the approach some time. void DirManager::RemoveOrphanedBlockfiles() { int i; // get a rough guess of how many blockfiles will be found/processed // at each step by looking at the size of the blockfile hash int blockcount=blockFileHash.size(); // enumerate *all* files in the project directory wxArrayString fnameList; // this function is finally a misnomer rm_dash_rf_enumerate_prompt((projFull != wxT("")? projFull: mytemp), fnameList,wxEmptyString,1,0,blockcount, _("Inspecting project file data...")); // enumerate orphaned blockfiles wxArrayString orphanList; for(i=0;i<(int)fnameList.GetCount();i++){ wxFileName fullname(fnameList[i]); wxString basename=fullname.GetName(); if(blockFileHash.find(basename) == blockFileHash.end()){ // the blockfile on disk is orphaned orphanList.Add(fullname.GetFullPath()); } } // remove all orphaned blockfiles for(i=0;i<(int)orphanList.GetCount();i++){ wxRemoveFile(orphanList[i]); } }
int CloudStitcher::setOutputPath( const std::string output_path ) { //make a boost path out of the provided path boost::filesystem::path fullname( output_path ); //split up the path into the file's parent directory path and the filename boost::filesystem::path parent_path( fullname.parent_path() ); boost::filesystem::path basename( fullname.filename() ); //check to make sure the parent directory actually exists and exit otherwise if( !boost::filesystem::is_directory( parent_path ) ) { std::stringstream output; output << "Error: specified output directory does not exist: " << parent_path.string() << "\n"; this->sendOutput( output.str() , true ); return -1; } //check to make sure the user gave us an actual filename to use std::string filename = basename.string(); if( filename.size() < 2 ) { this->sendOutput( "Error: no filename was specified.\n" , true ); return -1; } //if everything goes well, we will set the class member to the provided output path //for use later this->output_path = output_path; return 0; }
std::string mitk::ContourModelSerializer::Serialize() { const ContourModel *contour = dynamic_cast<const ContourModel *>(m_Data.GetPointer()); if (!contour) { MITK_ERROR << " Object at " << (const void *)this->m_Data << " is not an mitk::ContourModel. Cannot serialize as contour model."; return ""; } std::string filename(this->GetUniqueFilenameInWorkingDirectory()); filename += "_"; filename += m_FilenameHint; filename += ".cnt"; std::string fullname(m_WorkingDirectory); fullname += "/"; fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str()); try { ContourModelWriter writer; writer.SetOutputLocation(fullname); writer.SetInput(const_cast<ContourModel *>(contour)); writer.Write(); } catch (std::exception &e) { MITK_ERROR << " Error serializing object at " << (const void *)this->m_Data << " to " << fullname << ": " << e.what(); return ""; } return filename; }
Missile* UnitFactory::parseMissileBuffer( NetBuffer &netbuf ) { ObjSerial serial = netbuf.getSerial(); string file( netbuf.getString() ); string name( netbuf.getString() ); string fullname( netbuf.getString() ); int faction = netbuf.getInt32(); string mods( netbuf.getString() ); const float damage( netbuf.getFloat() ); float phasedamage = netbuf.getFloat(); float time = netbuf.getFloat(); float radialeffect = netbuf.getFloat(); float radmult = netbuf.getFloat(); float detonation_radius = netbuf.getFloat(); const string modifs( mods ); cerr<<"NETCREATE MISSILE : "<<file<<" ("<<serial<<")"<<endl; string facname = FactionUtil::GetFactionName( faction ); if ( facname.empty() ) { //Got an invalid faction number... cerr<<" Missile has an invalid faction "<<faction<<endl; faction = 0; } Missile *mis = createMissile( file.c_str(), faction, modifs, damage, phasedamage, time, radialeffect, radmult, detonation_radius, serial ); if (netbuf.version() <= 4951) mis->curr_physical_state = netbuf.getTransformation(); else netbuf.getClientState().setUnitState( mis ); mis->name = name; mis->fullname = fullname; return mis; }
std::string mitk::VigraRandomForestClassifierSerializer::Serialize() { const mitk::VigraRandomForestClassifier* data = dynamic_cast<const mitk::VigraRandomForestClassifier*>( m_Data.GetPointer() ); if (!data) { MITK_ERROR << " Object at " << (const void*) this->m_Data << " is not an mitk::ContourModelSet. Cannot serialize as contour model set."; return ""; } std::string filename( this->GetUniqueFilenameInWorkingDirectory() ); filename += "_"; filename += m_FilenameHint; filename += ".hdf5"; std::string fullname(m_WorkingDirectory); fullname += "/"; fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str()); try { mitk::IOUtil::Save(const_cast<mitk::VigraRandomForestClassifier*>( data ),fullname); } catch (std::exception& e) { MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data << " to " << fullname << ": " << e.what(); return ""; } return filename; }
/** * \brief Save an image in the directory, return the short name */ std::string ImageDirectory::save(astro::image::ImagePtr image) { debug(LOG_DEBUG, DEBUG_LOG, 0, "saving an image"); // create a temporary file name in the base directory char buffer[1024]; snprintf(buffer, sizeof(buffer), "%s/XXXXXXXX.fits", basedir().c_str()); int fd = mkstemps(buffer, 5); if (fd < 0) { std::string cause = stringprintf("cannot create a tmp " "image file: %s", strerror(errno)); debug(LOG_ERR, DEBUG_LOG, 0, "%s", cause.c_str()); throw std::runtime_error(cause); } unlink(buffer); close(fd); std::string fullname(buffer); // construct the filename std::string filename = basename(fullname); debug(LOG_DEBUG, DEBUG_LOG, 0, "image full name: %s, filename: %s", fullname.c_str(), filename.c_str()); // write the file ImageDirectory::write(image, filename); // return the filename debug(LOG_DEBUG, DEBUG_LOG, 0, "image short name: %s", filename.c_str()); return filename; }
std::string mitk::SurfaceSerializer::Serialize() { const Surface* surface = dynamic_cast<const Surface*>( m_Data.GetPointer() ); if (!surface) { MITK_ERROR << " Object at " << (const void*) this->m_Data << " is not an mitk::Surface. Cannot serialize as surface."; return ""; } std::string filename( this->GetUniqueFilenameInWorkingDirectory() ); filename += "_"; filename += m_FilenameHint; filename += ".vtp"; std::string fullname(m_WorkingDirectory); fullname += IOUtil::GetDirectorySeparator(); fullname += filename; try { IOUtil::Save(surface, fullname); } catch (std::exception& e) { MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data << " to " << fullname << ": " << e.what(); return ""; } return filename; }
void SoundSystem::CreateShareBuffer_(typeSound type) { std::string path("resources/sounds/"); std::string filename(SoundTypeToName_(type)); std::string ext(".wav"); std::string fullname(path + filename + ext); OGuint buffer; if (filename.compare("NONETYPE") == 0) { return; } if (shareBuffers_.empty()) { buffer = OGAlut::CreateBufferFromFile((OGpchar)fullname.c_str()); shareBuffers_.push_back(OGShareBuffer(type, buffer)); return; } for (std::list<OGShareBuffer>::iterator it=shareBuffers_.begin(); it != shareBuffers_.end(); it++) { if (it->type == type) { it->counter = it->counter + 1; return; } } buffer = OGAlut::CreateBufferFromFile((OGpchar)fullname.c_str()); shareBuffers_.push_back(OGShareBuffer(type, buffer)); }
Path& Path::operator+=(const Path &rhs) { if (isDir() && !rhs.isAbsolute()) { mPaths.insert(mPaths.end(), rhs.mPaths.begin(), rhs.mPaths.end()); mFullName = fullname(DIR_SEP); } return *this; }
// remove any . or .. and make absolute if necessary Path& Path::normalize() { size_t i = 0; bool wasMadeAbsolute = isAbsolute(); while (i < mPaths.size()) { if (mPaths[i] == ".") { mPaths.erase(mPaths.begin()+i); } else if (mPaths[i] == "..") { if (i == 0) { if (wasMadeAbsolute) { // invalid path mPaths.clear(); break; } Path cwd = GetCurrentDir(); cwd.pop(); size_t sz = cwd.mPaths.size(); mPaths.erase(mPaths.begin()+i); mPaths.insert(mPaths.begin(), cwd.mPaths.begin(), cwd.mPaths.end()); i = sz; wasMadeAbsolute = true; } else { mPaths.erase(mPaths.begin()+i); mPaths.erase(mPaths.begin()+i-1); --i; } } else { ++i; } } mFullName = fullname(DIR_SEP); return *this; }
// if path is relative, prepend current directory Path& Path::makeAbsolute() { if (!isAbsolute()) { Path cwd = GetCurrentDir(); mPaths.insert(mPaths.begin(), cwd.mPaths.begin(), cwd.mPaths.end()); mFullName = fullname(DIR_SEP); } return *this; }
String Path::pop() { String rv; if (mPaths.size() > 0) { rv = mPaths.back(); mPaths.pop_back(); mFullName = fullname(DIR_SEP); } return rv; }
/// Construct a listening receiver with the given io_service. receiver(boost::asio::io_service& io_service, naming::locality here, connection_handler& parcelport) : window_(io_service), parcelport_(parcelport) { std::string fullname(here.get_address() + "." + boost::lexical_cast<std::string>(here.get_port())); window_.set_option(data_window::bound_to(fullname)); }
/// Construct a listening parcelport_connection with the given io_service. parcelport_connection(boost::asio::io_service& io_service, naming::locality here, parcelset::shmem::parcelport& parcelport) : window_(io_service), in_buffer_(), parcelport_(parcelport) { std::string fullname(here.get_address() + "." + boost::lexical_cast<std::string>(here.get_port())); window_.set_option(parcelset::shmem::data_window::bound_to(fullname)); }
WindowFullscreenTest() : GtkTestHarness::GtkTestHarness() , win_(gtk_window_new(GTK_WINDOW_TOPLEVEL)) , isFullscreen_(false) , isConfigured_(false) { gtk_window_set_title(*this, fullname(*this).c_str()); gtk_window_resize(*this, 360, 225); }
bool DiskFile::open(const char *mode /* = NULL */) { if(isopen()) close(); _fh = real_fopen(fullname(), mode ? mode : "rb"); return !!_fh; }
/** * \brief Test whether a file exists */ bool ImageDirectory::isFile(const std::string& filename) const { std::string fn = fullname(filename); struct stat sb; if (stat(fn.c_str(), &sb) < 0) { debug(LOG_DEBUG, DEBUG_LOG, 0, "cannot stat file %s: %s", fn.c_str(), strerror(errno)); return false; } return S_ISREG(sb.st_mode) ? true : false; }
/** * \brief Get the size of the file */ long ImageDirectory::fileSize(const std::string& name) const { std::string fn = fullname(name); struct stat sb; if (stat(fn.c_str(), &sb) < 0) { debug(LOG_ERR, DEBUG_LOG, 0, "file %s does not exist: %s", fn.c_str(), strerror(errno)); return -1; } return sb.st_size; }
//------------------------------------------------------------------------------- void VoidBot::UserLoggedInOrChangedName(const char *SessionID, const char *Name) { // Keep list of UserIDs. If UserID is not found then it is new user if( fLogged.find(SessionID) == fLogged.end() ) { // If user has bigger SessionID than bot has, then send message. if( atol(SessionID) > atol(fData.SessionID()) ) { // Send special message for one user only. Not private, since it beeps String fullname(botPath); fullname += "/motd/"; fullname += "motd"; SendTextfile(SessionID, fullname.Cstr(), true); } String log("L"); fLogged[SessionID] = log; } if( fLastWords.find(Name) == fLastWords.end() ) { String log("logging in on "); log += Time(); log += " ["; log += NetTime(); log += "]"; log += ", and hasn't said anything yet."; fLastWords[Name] = log; fReportedNewMessages[Name] = false; } else { // set last words of previous nick const char* prevname = fData.UserByID(SessionID)->Name(); String log(fLastWords[prevname]); log += ", and changed to "; log += Name; log += " on "; log += Time(); log += " ["; log += NetTime(); log += "]"; fLastWords[prevname] = log; // set log for new nick log = "changing from "; log += prevname; log += ", and hasn't said anything yet"; fLastWords[Name] = log; fData.UserByID(SessionID)->Name(String(Name).ToLowerCase().Cstr()); } // message reporting ReportMessageExistence(SessionID, Name); }
void startKey(const char *name) { const char *curname = tagname(); if (tail.length() && isEmpty()) { StringBuffer fullname(name); push(fullname.append(tail).str()); } else push(name); }
void EntityClassDoom3_loadFile( const char* filename ){ globalOutputStream() << "parsing entity classes from " << makeQuoted( filename ) << "\n"; StringOutputStream fullname( 256 ); fullname << "def/" << filename; ArchiveTextFile* file = GlobalFileSystem().openTextFile( fullname.c_str() ); if ( file != 0 ) { EntityClassDoom3_parse( file->getInputStream(), fullname.c_str() ); file->release(); } }
/** * \brief Remove an image from the directory */ void ImageDirectory::remove(const std::string& filename) { if (!isFile(filename)) { throw std::runtime_error("file not found"); } if (unlink(fullname(filename).c_str()) < 0) { debug(LOG_ERR, DEBUG_LOG, 0, "cannot remove %s: %s", filename.c_str(), strerror(errno)); throw std::runtime_error("cannot remove file"); } debug(LOG_DEBUG, DEBUG_LOG, 0, "file %s removed (unlink)", filename.c_str()); }
void DesuraJSBinding::setCacheValue(gcString name, gcString value) { gcString fullname("WEBCACHE_{0}", name); auto cvar = GetCVarManager()->findCVar(fullname.c_str()); if (!cvar) { cvar = gcRefPtr<CVar>::create(fullname.c_str(), "", CFLAG_USER); g_pCvarList.push_back(cvar); } cvar->setValue(value.c_str()); }