//! Changes the current Working Directory to the given string. bool CFileSystem::changeWorkingDirectoryTo(const core::string<c16>& newDirectory) { bool success=false; if (FileSystemType != FILESYSTEM_NATIVE) { WorkingDirectory[FILESYSTEM_VIRTUAL].append(newDirectory); flattenFilename(WorkingDirectory[FILESYSTEM_VIRTUAL], ""); success = 1; } else { WorkingDirectory[FILESYSTEM_NATIVE] = newDirectory; #if defined(_IRR_USE_WINDOWS_CE_DEVICE_) success = true; #elif defined(_MSC_VER) #if defined(_IRR_WCHAR_FILESYSTEM) success=(_wchdir(newDirectory.c_str()) == 0); #else success=(_chdir(newDirectory.c_str()) == 0); #endif #else success=(chdir(newDirectory.c_str()) == 0); #endif } return success; }
const mchar* getZzipError(zzip_error_t zzipError) { static core::string errorMsg; switch (zzipError) { case ZZIP_NO_ERROR: break; case ZZIP_OUTOFMEM: errorMsg = mT("Out of memory."); break; case ZZIP_DIR_OPEN: case ZZIP_DIR_STAT: case ZZIP_DIR_SEEK: case ZZIP_DIR_READ: errorMsg = mT("Unable to read zip file."); break; case ZZIP_UNSUPP_COMPR: errorMsg = mT("Unsupported compression format."); break; case ZZIP_CORRUPTED: errorMsg = mT("Corrupted archive."); break; default: errorMsg = mT("Unknown error."); break; }; return errorMsg.c_str(); }
bool OFSerialPort::OpenByName(const core::string& port,int baudRate) { if(m_open) Close(); m_open=m_sp->setup(port.c_str(),baudRate); return m_open; }
core::string AlphabetFlow::prevValue(const core::string & value) { char *ret = alphabetflow_prev(value.c_str(), (uint)value.length()); core::string str = ret; free(ret); return str; }
bool delete_db() { if (db == NULL) return false; // close db. close(); // remove. DB* agent = NULL; if (db_create(&agent, NULL, 0) != 0) { trace_msg("failed to create agent bdb."); return false; } if (agent->remove(agent, dbpath.c_str(), NULL, 0) != 0) { trace_msg("failed to delete db."); return false; } // had free while remove. //agent->close(agent, DB_NOSYNC); return true; }
void Sqlite::re_key(core::string const& key) { if (key.length()) sqlite3_rekey(d_ptr->db, key.c_str(), key.length()); else sqlite3_rekey(d_ptr->db, NULL, 0); }
bool open(core::string const& file) { this->close(); fd.open(file.c_str(), ::std::ios_base::app | ::std::ios_base::out); if (!fd.is_open()) return false; // open. appender = new log4cpp::OstreamAppender(file.c_str(), &fd); log4cpp::PatternLayout* layout = new log4cpp::PatternLayout; layout->setConversionPattern("%d: %p %c %x: %m%n"); appender->setLayout(layout); category->addAppender(appender); return true; }
//! determines if a file exists and would be able to be opened. bool CFileSystem::existFile(const core::string<c16>& filename) const { for (u32 i=0; i < FileArchives.size(); ++i) if ( FileArchives[i]->findFile(filename)!=-1) return true; #if defined ( _IRR_WCHAR_FILESYSTEM ) FILE* f = _wfopen(filename.c_str(), L"rb"); #else FILE* f = fopen(filename.c_str(), "rb"); #endif if (f) { fclose(f); return true; } _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; return false; }
core::string<c16> CFileSystem::getAbsolutePath(const core::string<c16>& filename) const { c16 *p=0; #if defined(_IRR_USE_WINDOWS_CE_DEVICE_) return filename; #elif defined(_IRR_WINDOWS_API_) #if defined(_IRR_WCHAR_FILESYSTEM ) c16 fpath[_MAX_PATH]; p = _wfullpath(fpath, filename.c_str(), _MAX_PATH); #else c8 fpath[_MAX_PATH]; p = _fullpath(fpath, filename.c_str(), _MAX_PATH); #endif #elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) c8 fpath[4096]; fpath[0]=0; p = realpath(filename.c_str(), fpath); if (!p) { // content in fpath is undefined at this point if ('0'==fpath[0]) // seems like fpath wasn't altered { // at least remove a ./ prefix if ('.'==filename[0] && '/'==filename[1]) return filename.subString(2, filename.size()-2); else return filename; } else return core::string<c16>(fpath); } #endif return core::string<c16>(p); }
bool ofGstUtils::setPipelineWithSink(const core::string &pipeline, const core::string & sinkname, bool isStream){ ofGstUtils::startGstMainLoop(); gchar* pipeline_string = g_strdup((pipeline).c_str()); GError * error = NULL; gstPipeline = gst_parse_launch (pipeline_string, &error); gLogManager.log( core::string("gstreamer pipeline: ")+ pipeline_string,ELL_INFO); if(error!=NULL){ gLogManager.log(core::string("couldnt create pipeline: ") + error->message,ELL_WARNING); return false; } gstSink = gst_bin_get_by_name(GST_BIN(gstPipeline),sinkname.c_str()); if(!gstSink){ gLogManager.log( "couldn't get sink from string pipeline",ELL_WARNING); } return setPipelineWithSink(gstPipeline,gstSink,isStream); }
sel::selector luaengine::operator [] (const core::string & variable) { return _state[variable.c_str()]; }
core::data md5::hex(core::string const& str) { core::data re(MD5_DIGEST_LENGTH); MD5((byte*)str.c_str(), str.length(), core::pointer(re)); return re; }
core::string md5::digest(core::string const& str) { core::data re(MD5_DIGEST_LENGTH); MD5((byte*)str.c_str(), str.length(), core::pointer(re)); return core::present_cast<core::string>(re); }
const mchar* getMessage(int msgCode){ static core::string msgStr; switch(msgCode){ case HMSG_NET_START: msgStr+=mT("Network startup."); break; case HMSG_SOCKET_OPEN: msgStr+=mT("Socket Open."); break; case HMSG_TCP_SOCKET_CREATE: msgStr+=mT("TCP Socket Create."); break; case HMSG_UDP_SOCKET_CREATE: msgStr+=mT("UDP Socket Create."); break; case HMSG_GETHOST: msgStr+=mT("Get Host Name."); break; case HMSG_BIND: msgStr+=mT("socket Bind."); break; case HMSG_GETSOCKNAME: msgStr+=mT("Getting socket name."); break; case HMSG_ACCEPT: msgStr+=mT("accept data."); break; case HMSG_LISTEN: msgStr+=mT("Socket Listning."); break; case HMSG_FIND_REMOTE_HOST: msgStr+=mT("Find Remote Host."); break; case HMSG_CREATE_CONNECTION: msgStr+=mT("Creating Connection to Remote Host."); break; case HMSG_SEND: msgStr+=mT("Send Data."); break; case HMSG_RECIVE: msgStr+=mT("Recive Data."); break; case HMSG_SERVER_LOST: msgStr+=mT("Server Lost."); break; case HMSG_CANOT_CONNECT: msgStr+=mT("Cann't connect to server."); break; case HMSG_MAX_CLIENTS: msgStr+=mT("Max Clients Reached."); break; case HMSG_CLIENT_LOST: msgStr+=mT("Client Lost."); break; case HMSG_SETBROADCAST: msgStr+=mT("set Broadcast."); break; case HMSG_BROADCAST: msgStr+=mT("Broadcasting!."); break; case HMSG_TIMEOUT: msgStr+=mT("timeout!."); break; case HMSG_UNREACHABLEHOST: msgStr+=mT("Unreachable remote host!."); break; default: msgStr+=mT("Unkwon."); break; } return msgStr.c_str(); }
bool BrowserWindow::NavigateToUrl(const core::string& url) { return m_impl->GetWindow()->navigateTo(url.c_str(),url.length()); }
void Sqlite::set_key(core::string const& key) { sqlite3_key(d_ptr->db, key.c_str(), key.length()); }
Error::Error(const core::string& message) : std::runtime_error(message.c_str()) { }
bool luaengine::load(const core::string & file) { //TODO - actually load file from packages return _state.load(file.c_str()); }
bool luaengine::eval(const core::string & code) { return _state(code.c_str()); }