void wxcHelper::AddFilesToProject(cbProject* proj, const std::vector<wxFileName>& files, bool compile) { wxFileName folderPath(proj->GetFilename()); proj->BeginAddFiles(); for(size_t i=0; i<files.size(); ++i) { wxFileName fn = files.at(i); fn.MakeRelativeTo( folderPath.GetPath() ); ProjectFile* pf(NULL); for(int targetIndex=0; targetIndex<proj->GetBuildTargetsCount(); ++targetIndex) { pf = proj->AddFile( targetIndex, fn.GetFullPath(), compile, compile ); } if ( pf ) { // This is the only sane way I found to add the file all build targets: // clear the array and then iterate them one by one and add them pf->buildTargets.Clear(); for(int targetIndex=0; targetIndex<proj->GetBuildTargetsCount(); ++targetIndex) { pf->buildTargets.Add( proj->GetBuildTarget(targetIndex)->GetTitle() ); } } } proj->EndAddFiles(); // Save and rebuild the project tree Manager::Get()->GetProjectManager()->SaveAllProjects(); Manager::Get()->GetProjectManager()->GetUI().RebuildTree(); }
/** * DeleteFolder * * Description: FAILS .... fix this */ bool CFtpManager::DeleteFolder(CConnection * con, CFileContainer & file) { bool result = false; CString folderPath(file.path + file.name); if(!m_ftpClient.IsConnected()) { int retcode = 11; retcode = m_ftpClient.FTPConnect(con->host, con->user, con->password, _T("")); if(retcode == UTE_SUCCESS) { } } m_ftpClient.SetFireWallMode(TRUE); int r = m_ftpClient.RmDir(folderPath); if(r == UTE_SUCCESS) { result = true; } if(r == UTE_NO_RESPONSE) { TRACE1(" Delete Folder %s Failed: No Response \n", folderPath); } if(r == UTE_SVR_REQUEST_DENIED) { TRACE1(" Delete Folder %s Failed: Request Denied \n", folderPath); } return result; }
// GetFolderIndexFor //------------------------------------------------------------------------------ uint32_t ProjectGeneratorBase::GetFolderIndexFor( const AString & path ) { // Get the path exluding the file file or dir const char * lastSlash = path.FindLast( NATIVE_SLASH ); if ( ( lastSlash == nullptr ) || ( lastSlash == path.Get() ) ) { return 0; // no sub-path: put it in the root } // Search for existing folder AStackString<> folderPath( path.Get(), lastSlash ); for ( const Folder& folder : m_Folders ) { if ( folder.m_Path == folderPath ) { return (uint32_t)( &folder - m_Folders.Begin() ); // Found existing } } // Add new folder(s) recursively const uint32_t parentFolderIndex = GetFolderIndexFor( folderPath ); // Create new folder Folder f; f.m_Path = folderPath; m_Folders.Append( f ); const uint32_t folderIndex = (uint32_t)( m_Folders.GetSize() - 1 ); // Add to parent folder m_Folders[ parentFolderIndex ].m_Folders.Append( folderIndex ); return folderIndex; }
std::string Driver::minidump(const std::string& prefix) { if (!log_enabled_) { const std::string& err = "Log is not enabled, please enable logging before calling minidump"; std::cout << BOLDRED << err << std::endl << RESETCOLOR << std::endl; return err; } // CHECK SIZE IN FOLDER long files_size = 0; boost::filesystem::path folderPath(boost::filesystem::current_path()); helpers::filesystem::getFilesSize(folderPath, files_size); if (files_size > helpers::filesystem::folderMaximumSize) { std::cout << BOLDRED << "No more space on robot. You need to upload the presents bags and remove them to make new ones." << std::endl << "To remove all the presents bags, you can run this command:" << std::endl << "\t$ qicli call ROS-Driver.removeFiles" << RESETCOLOR << std::endl; return "No more space on robot. You need to upload the presents bags and remove them to make new ones."; } // IF A ROSBAG WAS OPENED, FIRST CLOSE IT if (record_enabled_) { stopRecording(); } // STOP BUFFERIZING log_enabled_ = false; for(EventIter iterator = event_map_.begin(); iterator != event_map_.end(); iterator++) { iterator->second.isDumping(true); } ros::Time time = ros::Time::now(); // START A NEW ROSBAG boost::mutex::scoped_lock lock_record( mutex_record_ ); recorder_->startRecord(prefix); // WRITE ALL BUFFER INTO THE ROSBAG for(EventIter iterator = event_map_.begin(); iterator != event_map_.end(); iterator++) { iterator->second.writeDump(time); } for(RecIter iterator = rec_map_.begin(); iterator != rec_map_.end(); iterator++) { iterator->second.writeDump(time); } // RESTART BUFFERIZING log_enabled_ = true; for(EventIter iterator = event_map_.begin(); iterator != event_map_.end(); iterator++) { iterator->second.isDumping(false); } return recorder_->stopRecord(::naoqi::ros_env::getROSIP("eth0")); }
bool File::list(StringStorage *fileList, UINT32 *filesCount) const { StringStorage folderPath(m_pathName.getString()); folderPath.appendString(_T("\\*")); UINT32 index = 0; HANDLE hfile; WIN32_FIND_DATA findFileData; // // Change error mode to avoid windows error message in message box // when we attemt to find first file on unmounted device // UINT savedErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); hfile = FindFirstFile(folderPath.getString(), &findFileData); // Restore error mode SetErrorMode(savedErrorMode); if (hfile == INVALID_HANDLE_VALUE) { return false; } do { // // Skip "fake" file names // if (_tcscmp(findFileData.cFileName, _T(".")) == 0 || _tcscmp(findFileData.cFileName, _T("..")) == 0) { continue; } if (fileList != NULL) { fileList[index].setString(findFileData.cFileName); } index++; } while (FindNextFile(hfile, &findFileData)); FindClose(hfile); if (fileList == NULL) { *filesCount = index; } return true; }
bool File::list(StringStorage *fileList, UINT32 *filesCount) const { StringStorage folderPath(m_pathName.getString()); folderPath.appendString(_T("\\*")); UINT32 index = 0; HANDLE hfile; WIN32_FIND_DATA findFileData; UINT savedErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); hfile = FindFirstFile(folderPath.getString(), &findFileData); SetErrorMode(savedErrorMode); if (hfile == INVALID_HANDLE_VALUE) { return false; } do { if (_tcscmp(findFileData.cFileName, _T(".")) == 0 || _tcscmp(findFileData.cFileName, _T("..")) == 0) { continue; } if (fileList != NULL) { fileList[index].setString(findFileData.cFileName); } index++; } while (FindNextFile(hfile, &findFileData)); FindClose(hfile); if (fileList == NULL) { *filesCount = index; } return true; }
/** * GetFtpDirectory * * Description: 1) Conect to ftp server, change directory. * 2) Get dir listing. * 3) Read existing listing file, * 4) If listing has changed, write new dir listing file. * * Parameters: CConnection - describes ftp connection info, user, host etc. * dir - ftp remote directory * ftpClient - optional ftpclient. if null, will create, connect and close. * Return: * bool - success * ??? was it updated? */ bool CFtpManager::GetFtpDirectory(CConnection * con, CString &directory, CRealFtpClient * ftpClient) { bool result = false; //TRACE1(" con %s \n ", con->name); //Connect(con, m_ftpClient); //if(!m_ftpClient.IsConnected()) // Not connected //{ // return; //} bool closeConnection = false; if(!ftpClient) { ftpClient = new CRealFtpClient(); closeConnection = true; } if(!ftpClient->IsConnected()) // Not connected { int retcode = 11; retcode = ftpClient->FTPConnect(con->host, con->user, con->password, _T("")); if(retcode == UTE_SUCCESS) { ftpClient->SetFireWallMode(TRUE); } } //m_ftpClient.SetFireWallMode(TRUE); //ftpClient->SetFireWallMode(TRUE); CString localStorePath; GetLocalStorePath(con, localStorePath); localStorePath = localStorePath + directory + CString(_T("")); localStorePath.Replace('/', '\\'); CString dirContentListing(_T("")); CString fileListing(_T("")); CString folderListing(_T("")); CUT_DIRINFO di; _TCHAR entry[HISTORY_ENTRY_SIZE]; _TCHAR dir[MAX_PATH]; int valRet; { valRet = ftpClient->ChDir( directory ); if (valRet != UTE_SUCCESS){ //m_history.AddLine(CUT_ERR::GetErrorString (valRet)); TRACE1(" chdir failed: %s \n ", CUT_ERR::GetErrorString(valRet) ); } else { int dirInfo = ftpClient->GetDirInfo(); int count = ftpClient->GetDirInfoCount(); for(int t=0;t<count;t++){ ftpClient->GetDirEntry(t, &di); // v4.2 dir info now has _TCHAR // Format: Name,size,time, time display _sntprintf(entry, sizeof(entry)/sizeof(_TCHAR), _T("<n>%s</n><s>%ld</s><d>%2.2d/%2.2d/%2.2d %2.2d:%2.2d</d><p>%d</p><o>%s</o><g>%s</g>"), di.fileName, di.fileSize, di.year, di.month, di.day, di.hour, di.minute, di.permissions, di.owner, di.group); //m_history.AddLine(entry); if(di.isDir) { CString folderPath(localStorePath + _T("") + di.fileName ); if(GetFileAttributes(folderPath) == INVALID_FILE_ATTRIBUTES){ CreateDirectory(folderPath, NULL); } CString fileInfo(_T("")); fileInfo = fileInfo + CString(_T("<t>d</t>")) + CString(entry) + _T("\n"); folderListing = folderListing + fileInfo; } else { // File CString fileInfo(_T("")); fileInfo = fileInfo + CString(_T("<t>f</t>")) + CString(entry) + _T("\n"); fileListing = fileListing + fileInfo; } } dirContentListing = CString(folderListing + fileListing); // write dir descriptor // dirContentListing CString dirContentFile(localStorePath + _T(".files.rftp")); // Check existing files.rftp. Don't rewrite if its the same. SSD safety. CString existingListing(_T("")); CFileStatus status; if(CFile::GetStatus(dirContentFile, status)) { CStdioFile file (dirContentFile, CStdioFile::modeRead | CFile::shareDenyNone); CString buffer; while (file.ReadString(buffer)) { existingListing = existingListing + buffer + _T("\n"); } } if(existingListing.Compare(dirContentListing) != 0) { CFile theFile(dirContentFile, CFile::modeReadWrite | CFile::modeCreate); char buffer[200000]; sprintf(buffer, "%S", dirContentListing); // CString to char * int len = strlen(buffer); //theFile.Write( (LPCTSTR) dirContentListing, dirContentListing.GetLength() * sizeof(TCHAR)); // // Error here *********** // CString buffy(dirContentFile); if(buffy.Find(CString(_T("newsletter-form"))) != 1){ int i = 0; } theFile.Write(buffer, len); TRACE0(" GetFtpDirectory Updated \n"); m_directoryUpdated = true; } else { //TRACE0(" GetFtpDirectory Allready up to date \n"); m_directoryUpdated = false; } //TRACE1(" file: %s \n", entry); result = true; } // chdir success } if(closeConnection){ ftpClient->Close(); delete ftpClient; } return result; }
std::string Driver::minidumpConverters(const std::string& prefix, const std::vector<std::string>& names) { if (!log_enabled_) { const std::string& err = "Log is not enabled, please enable logging before calling minidump"; std::cout << BOLDRED << err << std::endl << RESETCOLOR << std::endl; return err; } // CHECK SIZE IN FOLDER long files_size = 0; boost::filesystem::path folderPath(boost::filesystem::current_path()); helpers::filesystem::getFilesSize(folderPath, files_size); if (files_size > helpers::filesystem::folderMaximumSize) { std::cout << BOLDRED << "No more space on robot. You need to upload the presents bags and remove them to make new ones." << std::endl << "To remove all the presents bags, you can run this command:" << std::endl << "\t$ qicli call ROS-Driver.removeFiles" << RESETCOLOR << std::endl; return "No more space on robot. You need to upload the presents bags and remove them to make new ones."; } // IF A ROSBAG WAS OPENED, FIRST CLOSE IT if (record_enabled_) { stopRecording(); } // STOP BUFFERIZING log_enabled_ = false; for(EventIter iterator = event_map_.begin(); iterator != event_map_.end(); iterator++) { iterator->second.isDumping(true); } ros::Time time = ros::Time::now(); // WRITE CHOOSEN BUFFER INTO THE ROSBAG boost::mutex::scoped_lock lock_record( mutex_record_ ); bool is_started = false; for_each( const std::string& name, names) { RecIter it = rec_map_.find(name); if ( it != rec_map_.end() ) { if ( !is_started ) { recorder_->startRecord(prefix); is_started = true; } it->second.writeDump(time); } else { EventIter it_event = event_map_.find(name); if ( it_event != event_map_.end() ) { if ( !is_started ) { recorder_->startRecord(prefix); is_started = true; } it_event->second.writeDump(time); } } }