std::string Support::temppath(const std::string& file) { const std::string s = temppath() + file; return s; }
void Project::Save(const char *path) { BString projectPath = fPath.GetFolder(); projectPath << "/"; BString data; data << "NAME=" << fName << "\nTARGETNAME=" << fTargetName << "\n"; data << "PLATFORM=" << sPlatformArray[fPlatform] << "\n"; switch (fSCMType) { case SCM_HG: { data << "SCM=hg\n"; break; } case SCM_GIT: { data << "SCM=git\n"; break; } case SCM_SVN: { data << "SCM=svn\n"; break; } case SCM_NONE: { data << "SCM=none\n"; break; } default: { break; } } for (int32 i = 0; i < CountGroups(); i++) { SourceGroup *group = GroupAt(i); data << "GROUP=" << group->name << "\n"; data << "EXPANDGROUP=" << (group->expanded ? "yes" : "no") << "\n"; for (int32 j = 0; j < group->filelist.CountItems(); j++) { SourceFile *file = group->filelist.ItemAt(j); BString temppath(file->GetPath().GetFullPath()); if (temppath.FindFirst(projectPath.String()) == 0) { // Absolute paths which include the project folder are stripped // down into relative paths temppath.RemoveFirst(projectPath.String()); } data << "SOURCEFILE=" << temppath << "\n"; if (file->GetDependencies() && strlen(file->GetDependencies()) > 0) data << "DEPENDENCY=" << file->GetDependencies() << "\n"; } } for (int32 i = 0; i < fLocalIncludeList.CountItems(); i++) data << "LOCALINCLUDE=" << fLocalIncludeList.ItemAt(i)->Relative() << "\n"; for (int32 i = 0; i < fSystemIncludeList.CountItems(); i++) { BString *string = fSystemIncludeList.ItemAt(i); BString include = *string; if (include[0] == '/') include.RemoveFirst(projectPath.String()); data << "SYSTEMINCLUDE=" << include << "\n"; } for (int32 i = 0; i < fLibraryList.CountItems(); i++) { SourceFile *file = (SourceFile*)fLibraryList.ItemAt(i); if (!file) continue; BString strpath(file->GetPath().GetFullPath()); if (gPlatform == PLATFORM_ZETA) { if (strpath.FindFirst("/boot/beos/etc/develop/zeta-r1-gcc2-x86/") == 0) strpath.ReplaceFirst("/boot/beos/etc/develop/zeta-r1-gcc2-x86/", "/boot/develop/"); } if (strpath.FindFirst(projectPath.String()) == 0) strpath.RemoveFirst(projectPath.String()); data << "LIBRARY=" << strpath.String() << "\n"; } data << "RUNARGS=" << fRunArgs << "\n"; data << "CCDEBUG=" << (fDebug ? "yes" : "no") << "\n"; data << "CCPROFILE=" << (fProfile ? "yes" : "no") << "\n"; data << "CCOPSIZE=" << (fOpSize ? "yes" : "no") << "\n"; data << "CCOPLEVEL=" << (int)fOpLevel << "\n"; data << "CCTARGETTYPE=" << fTargetType << "\n"; data << "CCEXTRA=" << fExtraCompilerOptions << "\n"; data << "LDEXTRA=" << fExtraLinkerOptions << "\n"; BFile file(path,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() != B_OK) { STRACE(2,("Couldn't create project file %s. Bailing out\n",path)); return; } STRACE(2,("Saved Project %s. Data as follows:\n%s\n",path,data.String())); file.Write(data.String(),data.Length()); fPath = path; fObjectPath = fPath.GetFolder(); BString objfolder("(Objects."); objfolder << GetName() << ")"; fObjectPath.Append(objfolder.String()); BNodeInfo nodeInfo(&file); nodeInfo.SetType(PROJECT_MIME_TYPE); UpdateBuildInfo(); }