// STATIC // called by CProjectDoc when it is opening // This reads parameters out of the project document. These // params give us the path of the base file (ana document) // the size and placement of the window, the processing goal, etc. CAnaInputDoc * CAnaInputDoc ::loadDocument( LPCTSTR lpszField, SFMFile & f) { CDocTemplate* pT = theApp.getDocTemplate(getRegFileTypeID()); ASSERTX(pT); CParseStream stream(lpszField); CString sPath; stream.getQuotedString(sPath); //if(!theApp.askUserToFindFileIfNotFound(sPath, getRegFileTypeID())) // return NULL; CPathDescriptor path(sPath); if(!path.fileExists()) // don't bother the user (mar 99) { // need to skip the rest of the fields related to this document in the project file CString sMarker, sField; do { f.getField(sMarker, sField); } while (sMarker != END_MARKER()); return NULL; } // jdh I'm not certain what this does, but it appears that it will just set // the member variable m_strPathName, so that whent the panels are displayed, // we then go and load up that file into the first panel. CAnaInputDoc * pDoc = (CAnaInputDoc *)pT->OpenDocumentFile(sPath); ASSERTX(pDoc->IsKindOf(RUNTIME_CLASS(CAnaInputDoc ))); pDoc->readParams(f); pDoc->SetTitle(getFullFileName(pDoc->GetPathName())); return pDoc; }
void CInputDoc::SetModifiedFlag(BOOL bModified) { if(bModified==IsModified()) return; // no change CDocument::SetModifiedFlag(bModified); SetTitle(getFullFileName(GetPathName())); }
// called by CProjectDoc::OnOpenDocument() for each \+Lang field it encounters // This STATIC method will read the parameters and then try to open the language // file. CLangModelsDoc* CLangModelsDoc::loadDocument(LPCTSTR lpszField, LPCTSTR sProjectPath) { CString sPath(lpszField); // sAbrev, // CParseStream stream(lpszField); // stream.word(sAbrev, FALSE); // i'm thinking the abrev appearing in the project file is not used anymore // stream.getQuotedString(sPath); //CCarlaLanguage *pLang = new CCarlaLanguage(sAbrev); CFileStatus status; // is the file there? if(!CFile::GetStatus(sPath, status)) { // if not, look in the same directory as this project //CString sPossiblePath = getLang()->getFilePath(getLang()->getLanguageDirectory(sProjectPath, FALSE)); CString sPossiblePath = ::getDirectory(sProjectPath); sPossiblePath += getFileName(sPath); sPossiblePath += " control files\\"; sPossiblePath += getFullFileName(sPath); // if it's there, switch the path and don't bother the user if(CFile::GetStatus(sPossiblePath, status)) sPath = sPossiblePath; else { // ask the user to find it if(!theApp.askUserToFindFile(sPath, CLangModelsDoc::getRegFileTypeID())) { THROWSTRING3("The language file", getFullFileName(sPath), " could not be found."); } } } CLangModelsDoc *pLangDoc = (CLangModelsDoc *)theApp.internalOpenDocumentFile(sPath); if(!pLangDoc) { checkForFileError(sPath); THROWSTRING3("The language file ", sPath, " could not be opened."); } else if(!pLangDoc->IsKindOf(RUNTIME_CLASS(CLangModelsDoc))) { ASSERTX(FALSE); // to do notify user or something } return pLangDoc; }
FILE *openFileForReading(const string &fileName) { string fullName; bool fileExists = getFullFileName(fileName, fullName); if (fileExists) { cout << "Opening file '" << fileName << "'" << endl; return fopen(fullName.c_str(), "rb"); } string msg = "Could not open file " + fileName; ERROR_MSG(msg.c_str(), false); return NULL; }
void CInputDoc::OnEditProcessingProperties() { CPropertySheet dlg("Processing Goal"); customizePropertySheet(dlg); if(!dlg.DoModal()) return; readPropertySheet(dlg); propertySheetClosed(dlg); SetTitle(getFullFileName(GetPathName())); UpdateAllViews(NULL); }
bool RGBAImage::loadPNG(const string &fileName, bool doFlipY) { string fullName; getFullFileName(fileName, fullName); unsigned error = lodepng::decode(pixels, width, height, fullName.c_str()); if (error) { ERROR_MSG(lodepng_error_text(error), false); return false; } if (doFlipY) flipY(); // PNGs go top-to-bottom, OpenGL is bottom-to-top name = fileName; return true; }
bool loadFileAsString(const string &fileName, string &fileContents) { printf("loading file '%s'\n", fileName.c_str()); string fullName; bool fileExists = getFullFileName(fileName, fullName); if (!fileExists) return false; ifstream fileStream(fullName.c_str()); if (fileStream.good()) { stringstream stringStream; stringStream << fileStream.rdbuf(); fileContents = stringStream.str(); fileStream.close(); return true; } fileStream.close(); return false; }
TextFile::TextFile(const std::string &fileName): fileName_(getFullFileName(fileName)) { if (!fileName.empty()) setName(toUtf16(baseName(fileName))); else setName(L"Untitled"); std::ifstream f(fileName_); if (f.is_open()) while (!f.eof()) { std::string line; std::getline(f, line); buffer_.push_back(toUtf16(line)); } else buffer_.push_back(L""); if (isCpp(fileName)) highlighter_ = new CppHighlighter(this); }
void testcheckIfErrorOccured() { int errorCode = 0; char *jsonFullPath = getFullFileName("tests/jsons/googleOauth2Access_invalidGrand.json"); char *fileContent = getFileContent(jsonFullPath, &errorCode); CU_ASSERT_EQUAL_FATAL(errorCode, 0); CU_ASSERT_PTR_NOT_NULL_FATAL(fileContent); json_settings settings; memset(&settings, 0, sizeof (json_settings)); char error[256]; json_value *value = json_parse_ex(&settings, fileContent, error); CU_ASSERT_PTR_NOT_NULL_FATAL(value); int return_value = checkIfErrorOccured(value); CU_ASSERT_NOT_EQUAL(return_value, 0); CU_ASSERT_EQUAL(return_value, INVALID_GRAND); json_value_free(value); }
void testProcessIncomingAccessTokenResponse() { int errorCode = 0; char *jsonFullPath = getFullFileName("tests/jsons/googleOauth2AccessTokenResponse_valid.json"); char *fileContent = getFileContent(jsonFullPath, &errorCode); CU_ASSERT_EQUAL_FATAL(errorCode, 0); CU_ASSERT_PTR_NOT_NULL_FATAL(fileContent); json_settings settings; memset(&settings, 0, sizeof (json_settings)); char error[256]; json_value *value = json_parse_ex(&settings, fileContent, error); TokenResponse* result = processIncomingAccessTokenResponse(value); CU_ASSERT_PTR_NOT_NULL_FATAL(result); CU_ASSERT_STRING_EQUAL(result->access_token, "access_token_string"); CU_ASSERT_STRING_EQUAL(result->error_code, NO_ERROR); CU_ASSERT_STRING_EQUAL(result->refresh_token, "refresh_token_string"); CU_ASSERT_STRING_EQUAL(result->token_type, "Bearer"); CU_ASSERT_EQUAL(result->expires_in, 3920); json_value_free(value); }
list<string> copyFileSet::addDirs(string path) { list<string> paths; paths.push_back(path); list<string> absolutePaths; char *resName = new char[PATH_MAX]; string tmpAbsPath; for (string strTmpPath:paths) { if (realpath(strTmpPath.c_str(), resName) != NULL) { tmpAbsPath = resName; } if (copyHelper::is_dir(tmpAbsPath.c_str())) { DIR *dir; struct dirent *ent; if ((dir = opendir( tmpAbsPath.c_str() )) != NULL) { absolutePaths.push_back(tmpAbsPath); while ((ent = readdir (dir)) != NULL) { string tmpFileName = ent->d_name; if (tmpFileName.compare(".") != 0 && tmpFileName.compare("..") != 0) { string tmpFullPath = getFullFileName( tmpAbsPath, tmpFileName ); absolutePaths.push_back(tmpFullPath); if (copyHelper::is_dir(tmpFullPath.c_str())) { paths.push_back(tmpFullPath); } } } closedir (dir); } else { cout << "Can't access " << tmpAbsPath << endl; } } else { absolutePaths.push_back( tmpAbsPath ); } } return absolutePaths; }
String Path::getFullPathWithoutRoot() const { return Torque::Path::Join(getPath(), '/', getFullFileName()); }
//jdh 12April2001 Support various readonly behaviors void CInputDoc::SetBaseReadOnly(BOOL bReadOnly) { m_bBaseIsEditable = ! bReadOnly; m_pView->SetBaseReadOnly(bReadOnly); SetTitle(getFullFileName(GetPathName())); }