Example #1
0
	Path Path::GetParentAtDepthN(UInt32 nDepth)
	{    
		if(!IsValid() ||
		nDepth >= Depth())
		{
			return *this;
		}
			
		// create Path object to parent object at depth N relative to this
		// path object.
		bool bHasFSOnStart = (m_sPath.length() > 0 && m_sPath[0] == PATH_SEPARATOR_CHAR);
		
		// create a copy of m_sPath.
		std::vector<TCHAR> pPath(m_sPath.length() + 1);
		strcpy(&pPath[0], m_sPath.c_str());
		
		// reset m_sPath as required.
		std::string sTmpPath = bHasFSOnStart ? PATH_SEPARATOR_STR : "";
		
		// split path into it tokens.
		LPSTR p = strtok(&pPath[0], PATH_SEPARATOR_STR);
			
		while(p && nDepth > 0)
		{
			if(sTmpPath.length() > 0 && sTmpPath[sTmpPath.length() - 1] != PATH_SEPARATOR_CHAR)
			{
				sTmpPath += PATH_SEPARATOR_CHAR;
			}
			
			sTmpPath += p;
			--nDepth;
			
			p = strtok(NULL, PATH_SEPARATOR_STR);
		}
		
		// put / on end as required
		if(sTmpPath.length() > 0 ? (sTmpPath[sTmpPath.length() - 1] != PATH_SEPARATOR_CHAR) : true)
		{
			sTmpPath += PATH_SEPARATOR_CHAR;
		}
	
	#if defined(_WINDOWS)
		return Path(m_sDrive + sTmpPath, false);
	#else
		return Path(sTmpPath, false);
	#endif
	}
Example #2
0
bool DirectoryList::isPathInList(const PathName& path) const
{
	if (fb_utils::bootBuild())
	{
		return true;
	}

	fb_assert(mode != NotInitialized);

	// Handle special cases
	switch (mode)
	{
	case None:
		return false;
	case Full:
		return true;
	}

	// Disable any up-dir(..) references - in case our path_utils
	// and OS handle paths in slightly different ways,
	// this is "wonderful" potential hole for hacks
	// Example of IIS attack attempt:
	// "GET /scripts/..%252f../winnt/system32/cmd.exe?/c+dir HTTP/1.0"
	//								(live from apache access.log :)
	if (path.find(PathUtils::up_dir_link) != PathName::npos)
		return false;

	PathName varpath(path);
	if (PathUtils::isRelative(path)) {
		PathUtils::concatPath(varpath, PathName(Config::getRootDirectory()), path);
	}

	ParsedPath pPath(varpath);
	bool rc = false;
	for (size_t i = 0; i < getCount(); i++)
	{
		if ((*this)[i].contains(pPath))
		{
			rc = true;
			break;
		}
	}
	return rc;
}
Example #3
0
void pManagement::createProject()
{
    //Görsel arayüzden alacağımız proje ismi ve yoluna dizin eklenecek
    //İçerisine sınıf ve index.txt atılacak.

    QTextStream cout(stdout);


    QDir pPath(getProjectPath()+QDir::separator()+getProjectName());
    bool stats = pPath.exists();
    if(!stats)
    {
        QDir dir(getProjectPath());
        dir.mkdir(getProjectName());
        projectContents();
    }else
    {
        cout << "Dizin var" << endl;
    }
}
Example #4
0
void DiscoveryJob::update_job_update_callback(bool local,
    const char *dirUrl,
    void *userdata)
{
    DiscoveryJob *updateJob = static_cast<DiscoveryJob *>(userdata);
    if (updateJob) {
        // Don't wanna overload the UI
        if (!updateJob->_lastUpdateProgressCallbackCall.isValid()) {
            updateJob->_lastUpdateProgressCallbackCall.start(); // first call
        } else if (updateJob->_lastUpdateProgressCallbackCall.elapsed() < 200) {
            return;
        } else {
            updateJob->_lastUpdateProgressCallbackCall.start();
        }

        QByteArray pPath(dirUrl);
        int indx = pPath.lastIndexOf('/');
        if (indx > -1) {
            const QString path = QUrl::fromPercentEncoding(pPath.mid(indx + 1));
            emit updateJob->folderDiscovered(local, path);
        }
    }
}
Example #5
0
	void Path::CleanupPath()
	{
		// compress the path, and resolve ~
		bool bHasFSOnEnd = (m_sPath.length() > 1 && m_sPath[m_sPath.length() - 1] == PATH_SEPARATOR_CHAR);
		bool bHasFSOnStart = (m_sPath.length() > 0 && m_sPath[0] == PATH_SEPARATOR_CHAR);
		
		// create a copy of m_sPath.
		std::vector<TCHAR> pPath(m_sPath.length() + 1);
		strcpy(&pPath[0], m_sPath.c_str());
		
		// reset m_sPath as required.
		m_sPath = bHasFSOnStart ? PATH_SEPARATOR_STR : "";
		
		// split path into it tokens, using strtok which is NOT reentrant
		// so be careful!
		LPSTR p = strtok(&pPath[0], PATH_SEPARATOR_STR);
			
		while(p)
		{
			if(StrCmp(p, "~") == 0 &&		// check for ~
			p == &pPath[0] &&			// check that the ~ is the first character in the path
			RetrieveHomePath().IsValid())// check that we have been able to resolve the home path
			{
				// create new path with resolved home path
				Path homePath = RetrieveHomePath();
					
				m_sPath = homePath.m_sPath;
	
	#if defined(_WINDOWS)
				// drive letter must be updated
				m_sDrive = homePath.m_sDrive;
	#endif
			}
			else if(StrCmp(p, ".") == 0 &&	// check for .
					p == &pPath[0])			// check that the . is the first character in the path
			{                        
				// get current working directory
				TCHAR * pBuff = getcwd(NULL, 0);
				
				// create new path with resolved working directory
				Path workingPath = Path(pBuff != NULL ? pBuff : ".", false);
				
				if(!pBuff)
				{
					TRACE(("Unable to retrieve current working directory!  getwd() failed with error %s (%d)",
							strerror(errno),
							errno), 
							DEBUG_LEVEL_MIN);
				}
				else
				{
					free(pBuff);
				}
				
				m_sPath = workingPath.m_sPath;
				
	
	#if defined(_WINDOWS)
				// drive letter must be updated
				m_sDrive = workingPath.m_sDrive;
	#endif
			}
			else if(StrCmp(p, "..") == 0 && getParent().IsValid())
			{
				// update path to parent path.
				m_sPath = getParent().m_sPath;
			}
			else
			{
				if(m_sPath.length() > 0 && m_sPath[m_sPath.length() - 1] != PATH_SEPARATOR_CHAR)
				{
					m_sPath += PATH_SEPARATOR_CHAR;
				}
				
				m_sPath += p;
			}
			
			p = strtok(NULL, PATH_SEPARATOR_STR);
		}
		
		// put / on end as required
		if(bHasFSOnEnd && (m_sPath.length() > 0 ? (m_sPath[m_sPath.length() - 1] != PATH_SEPARATOR_CHAR) : true))
		{
			m_sPath += PATH_SEPARATOR_CHAR;
		}
	}
Example #6
0
void CFDE_TextOut::DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen) {
  FX_BOOL bUnderLine = !!(m_dwStyles & FDE_TTOSTYLE_Underline);
  FX_BOOL bStrikeOut = !!(m_dwStyles & FDE_TTOSTYLE_Strikeout);
  FX_BOOL bHotKey = !!(m_dwStyles & FDE_TTOSTYLE_HotKey);
  FX_BOOL bVertical = !!(m_dwStyles & FDE_TTOSTYLE_VerticalLayout);
  if (!bUnderLine && !bStrikeOut && !bHotKey)
    return;

  if (!pPen) {
    pPen = new CFDE_Pen;
    pPen->SetColor(m_TxtColor);
  }
  std::unique_ptr<CFDE_Path> pPath(new CFDE_Path);
  int32_t iLineCount = 0;
  CFX_RectF rtText = pPiece->rtPiece;
  CFX_PointF pt1, pt2;
  if (bUnderLine) {
    if (bVertical) {
      pt1.x = rtText.left;
      pt1.y = rtText.top;
      pt2.x = rtText.left;
      pt2.y = rtText.bottom();
    } else {
      pt1.x = rtText.left;
      pt1.y = rtText.bottom();
      pt2.x = rtText.right();
      pt2.y = rtText.bottom();
    }
    pPath->AddLine(pt1, pt2);
    iLineCount++;
  }
  if (bStrikeOut) {
    if (bVertical) {
      pt1.x = rtText.left + rtText.width * 2.0f / 5.0f;
      pt1.y = rtText.top;
      pt2.x = pt1.x;
      pt2.y = rtText.bottom();
    } else {
      pt1.x = rtText.left;
      pt1.y = rtText.bottom() - rtText.height * 2.0f / 5.0f;
      pt2.x = rtText.right();
      pt2.y = pt1.y;
    }
    pPath->AddLine(pt1, pt2);
    iLineCount++;
  }
  if (bHotKey) {
    int32_t iHotKeys = m_hotKeys.GetSize();
    int32_t iCount = GetCharRects(pPiece);
    if (iCount > 0) {
      for (int32_t i = 0; i < iHotKeys; i++) {
        int32_t iCharIndex = m_hotKeys.GetAt(i);
        if (iCharIndex >= pPiece->iStartChar &&
            iCharIndex < pPiece->iStartChar + pPiece->iChars) {
          CFX_RectF rect = m_rectArray.GetAt(iCharIndex - pPiece->iStartChar);
          if (bVertical) {
            pt1.x = rect.left;
            pt1.y = rect.top;
            pt2.x = rect.left;
            pt2.y = rect.bottom();
          } else {
            pt1.x = rect.left;
            pt1.y = rect.bottom();
            pt2.x = rect.right();
            pt2.y = rect.bottom();
          }
          pPath->AddLine(pt1, pt2);
          iLineCount++;
        }
      }
    }
  }
  if (iLineCount > 0)
    m_pRenderDevice->DrawPath(pPen, 1, pPath.get(), &m_Matrix);
}
Example #7
0
// CreateNewProject - create all the text files for the new project
void NewProjectWindow::CreateNewProject(void)
{
	// Set Project Name and Various other settings
	char tmp[300];       // this will be removed when all references are gone 
	char cmd[256];
	int x;               // this will be removed when all references are gone
	FILE *f;             // this will be removed when all references are gone
	char FileName[256];
	char AppName[256];   // this will be removed when all references are gone
	BString FileContents;
	BString UpperProjectName;
	
	ProjectName.SetTo(txtNewProject->Text());
	UpperProjectName.SetTo(ProjectName.String());
	UpperProjectName.ToUpper();
	sprintf(AppName,"%s",ProjectName.String());  // this will be removed when all references are gone
		
	// 1) Get Current Directory
	app_info	daInfo;
	be_app->GetAppInfo(&daInfo);
	BEntry	daEntry(&daInfo.ref);
	daEntry.GetParent(&daEntry);
	BPath	pPath(&daEntry);
	char	apath[256];
	::memcpy(apath, pPath.Path(), 256);			
			
	// 2) Create New Directory
	sprintf(cmd,"mkdir %s/projects/%s",apath,ProjectName.String());
	system(cmd);
			
	// 3) Create Basic Files for a Default App
	
	// Application Header
	sprintf(FileName,"%s/projects/%s/%s.h",apath,ProjectName.String(),ProjectName.String());
	FileContents.SetTo("#ifndef __");
	FileContents.Append(UpperProjectName.String());
	FileContents.Append("_H__\n");
	FileContents.Append("#define __");
	FileContents.Append(UpperProjectName.String());
	FileContents.Append("_H__\n\n");
	FileContents.Append("extern const char *APP_SIGNATURE;\n\n");
	FileContents.Append("class ");
	FileContents.Append(ProjectName.String());
	FileContents.Append(" : public BApplication\n{\n\tpublic:\n\t\t");
	FileContents.Append(ProjectName.String());
	FileContents.Append("();\n");
	FileContents.Append("\t\tvirtual void MessageReceived(BMessage *message);\n");
	FileContents.Append("\tprivate:\n\n};\n\n");
	FileContents.Append("#endif\n");
	CreateFile(FileName,"Header",FileContents);
		
	// Application Constants.h
	sprintf(FileName,"%s/projects/%s/%sConstants.h",apath,ProjectName.String(),ProjectName.String());
	FileContents.SetTo("#ifndef __");
	FileContents.Append(UpperProjectName.String());
	FileContents.Append("CONSTANTS_H__\n");
	FileContents.Append("#define __");
	FileContents.Append(UpperProjectName.String());
	FileContents.Append("CONSTANTS_H__\n\n");
	FileContents.Append("// Pointers to BWindows\n");
	FileContents.Append("extern ");
	FileContents.Append(ProjectName.String());
	FileContents.Append("Window* ptr");
	FileContents.Append(ProjectName.String());
	FileContents.Append("Window;\n\n");
	FileContents.Append("// Product Name and Properties\n");
	FileContents.Append("const char projtitle[]=\"");
	FileContents.Append(ProjectName.String());
	FileContents.Append("\";\nconst char projversion[]=\"v0.1\";\nconst char projauthor[]=\"");
	FileContents.Append(txtAuthor->Text());
	FileContents.Append("\";\n\n");
	
	FileContents.Append("#endif\n");
	CreateFile(FileName,"Constants",FileContents);
	
	// Windows Header
	sprintf(FileName,"%s/projects/%s/%sWindows.h",apath,ProjectName.String(),ProjectName.String());
	FileContents.SetTo("#ifndef __");
	FileContents.Append(UpperProjectName.String());
	FileContents.Append("WINDOWS_H__\n");
	FileContents.Append("#define __");
	FileContents.Append(UpperProjectName.String());
	FileContents.Append("WINDOWS_H__\n\n");
	FileContents.Append("#include \"");
	FileContents.Append(ProjectName.String());
	FileContents.Append(".h\"\n");
	FileContents.Append("#include \"");
	FileContents.Append(ProjectName.String());
	FileContents.Append("Views.h\"\n\n");
	FileContents.Append("class ");
	FileContents.Append(ProjectName.String()); 
	FileContents.Append("View;\n\n");
	FileContents.Append("class ");
	FileContents.Append(ProjectName.String()); 
	FileContents.Append("Window : public BWindow\n");
	FileContents.Append("{\n\tpublic:\n\t\t");
	FileContents.Append(ProjectName.String()); 
	FileContents.Append("Window(BRect frame);\n");
	FileContents.Append("\t\t~");
	FileContents.Append(ProjectName.String()); 
	FileContents.Append("Window();\n");
	FileContents.Append("\t\tvirtual bool QuitRequested();\n");
	FileContents.Append("\t\tvirtual void MessageReceived(BMessage *message);\n");
	FileContents.Append("\tprivate:\n");
	FileContents.Append("\t\tvoid InitWindow(void);\n\n");
	if (chkLoadSavePrefs->Value() == B_CONTROL_ON) {
		FileContents.Append("\t\tvoid LoadSettings(BMessage *msg);\n");
		FileContents.Append("\t\tvoid SaveSettings(void);\n");
	}
	FileContents.Append("\t\t");
	FileContents.Append(ProjectName.String());
	FileContents.Append("View*\t\tptr");
	FileContents.Append(ProjectName.String());
	FileContents.Append("View;\n");
	FileContents.Append("};\n\n");
	FileContents.Append("#endif\n");
	CreateFile(FileName,"Windows Header",FileContents);

//	FileContents.Append("");
	
//	f = fopen(FileName,"w");
//	x = fputs("/*\n\n",f);
//	sprintf(tmp,"%s Windows Header\n\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"Author: %s\n\n",txtAuthor->Text());
//	x = fputs(tmp,f);
//	x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f);
//	x = fputs("*/\n\n",f);
//	sprintf(tmp,"#ifndef __%sWINDOWS_H__\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"#define __%sWINDOWS_H__\n\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"#include \"%s.h\"\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"#include \"%sViews.h\"\n\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"class %sView;\n\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"class %sWindow : public BWindow\n",ProjectName.String());
//	x = fputs(tmp,f);
//	x = fputs("{\n",f);
//	x = fputs("\tpublic:\n",f);
//	sprintf(tmp,"\t\t%sWindow(BRect frame);\n",ProjectName.String());
//	x = fputs(tmp,f);
//	sprintf(tmp,"\t\t~%sWindow();\n",ProjectName.String());
//	x = fputs(tmp,f);
//	x = fputs("\t\tvirtual bool QuitRequested();\n",f);
//	x = fputs("\t\tvirtual void MessageReceived(BMessage *message);\n",f);
//	x = fputs("\tprivate:\n",f);
//	x = fputs("\t\tvoid InitWindow(void);\n\n",f);
	
	// add load/save pref (if checked)
//	if (chkLoadSavePrefs->Value() == B_CONTROL_ON) {
//		x = fputs("\t\tvoid LoadSettings(BMessage *msg);\n",f);
//		x = fputs("\t\tvoid SaveSettings(void); \n",f);
//	}
//	sprintf(tmp,"\t\t%sView*\t\tptr%sView;\n",ProjectName.String(),ProjectName.String());
//	x = fputs(tmp,f);
//	x = fputs("};\n\n",f);
//	x = fputs("#endif\n",f);
//	fclose(f);
	
	// Views Header
	sprintf(FileName,"%s/projects/%s/%sViews.h",apath,ProjectName.String(),ProjectName.String());
	f = fopen(FileName,"w");
	x = fputs("/*\n\n",f);
	sprintf(tmp,"%s Views Header\n\n",ProjectName.String());
	x = fputs(tmp,f);
	sprintf(tmp,"Author: %s\n\n",txtAuthor->Text());
	x = fputs(tmp,f);
	x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f);
	x = fputs("*/\n\n",f);
	sprintf(tmp,"#ifndef __%sVIEWS_H__\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#define __%sVIEWS_H__\n\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%s.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sWindows.h\"\n\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"class %sView : public BView\n",AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tpublic:\n",f);
	sprintf(tmp,"\t\t%sView(BRect frame);\n",AppName);
	x = fputs(tmp,f);
	x = fputs("\t\tvirtual void Draw(BRect updateRect);\n",f);
	x = fputs("};\n\n",f);
	x = fputs("#endif\n",f);
	fclose(f);

	// View CPP
	sprintf(FileName,"%s/projects/%s/%sView.cpp",apath,AppName,AppName);
	f = fopen(FileName,"w");
	x = fputs("/*\n\n",f);
	sprintf(tmp,"%s View\n\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"Author: %s\n\n",txtAuthor->Text());
	x = fputs(tmp,f);
	x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f);
	x = fputs("*/\n\n",f);
	x = fputs("// Includes ------------------------------------------------------------------------------------------ //\n",f);
	x = fputs("#include <Alert.h>\n",f);
	x = fputs("#include <Application.h>\n",f);
	x = fputs("#include <Screen.h>\n",f);
	x = fputs("#include <stdio.h>\n",f);
	x = fputs("#include <Window.h>\n",f);
	x = fputs("#include <View.h>\n\n",f);
	sprintf(tmp,"#include \"%sWindows.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sViews.h\"\n",AppName);
	x = fputs(tmp,f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %sView - Constructor\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"%sView::%sView (BRect frame) : BView (frame, \"%sView\", B_FOLLOW_ALL_SIDES, B_WILL_DRAW )\n",AppName,AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tSetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));\n",f);
	x = fputs("}\n",f);
	x = fputs("// ------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"void %sView::Draw(BRect /*updateRect*/)\n",AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tBRect r;\n",f);
	x = fputs("\tr = Bounds();\n",f);
	x = fputs("}\n",f);
	x = fputs("// ------------------------------------------------------------------------------------------------- //\n",f);
	fclose(f);
	
	// Main CPP
	sprintf(FileName,"%s/projects/%s/%s.cpp",apath,AppName,AppName);
	f = fopen(FileName,"w");
	x = fputs("/*\n\n",f);
	sprintf(tmp,"%s\n\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"Author: %s\n\n",txtAuthor->Text());
	x = fputs(tmp,f);
	x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f);
	x = fputs("*/\n\n",f);
	x = fputs("// Includes ------------------------------------------------------------------------------------------ //\n",f);
	x = fputs("#include <Alert.h>\n",f);
	x = fputs("#include <Application.h>\n",f);
	x = fputs("#include <Button.h>\n",f);
	x = fputs("#include <Entry.h>\n",f);
	x = fputs("#include <File.h>\n",f);
	x = fputs("#include <FilePanel.h>\n",f);
	x = fputs("#include <ListView.h>\n",f);
	x = fputs("#include <Path.h>\n",f);
	x = fputs("#include <Screen.h>\n",f);
	x = fputs("#include <ScrollView.h>\n",f);
	x = fputs("#include <stdio.h>\n",f);
	x = fputs("#include <string.h>\n",f);
	x = fputs("#include <TextControl.h>\n",f);
	x = fputs("#include <Window.h>\n",f);
	x = fputs("#include <View.h>\n\n",f);
	sprintf(tmp,"#include \"%s.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sWindows.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sViews.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sConstants.h\"\n",AppName);
	x = fputs(tmp,f);
	//x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	x = fputs("// Constants ---------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"const char *APP_SIGNATURE = \"application/x-vnd.%s.%s\";  // Application Signature and Title\n\n",txtAuthor->Text(),AppName);
	x = fputs(tmp,f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"%sWindow\t\t*ptr%sWindow;\n\n",AppName,AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"// %s - Constructor\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"%s::%s() : BApplication (APP_SIGNATURE)\n",AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\t// Default Window Size - Position doesn't matter as we centre the form to the current screen size\n",f);
	x = fputs("\tBRect	screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());\n\n",f);
	x = fputs("\tfloat FormTopDefault = 0;\n",f);
	x = fputs("\tfloat FormLeftDefault = 0;\n",f);
	x = fputs("\tfloat FormWidthDefault = screenFrame.Width() - 500;\n",f);
	x = fputs("\tfloat FormHeightDefault = screenFrame.Height() - 500;\n",f);
	sprintf(tmp,"\tBRect %sWindowRect(FormTopDefault,FormLeftDefault,FormLeftDefault+FormWidthDefault,FormTopDefault+FormHeightDefault);\n\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"\tptr%sWindow = new %sWindow(%sWindowRect);\n",AppName,AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("}\n",f);
	x = fputs("// ------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %s::MessageReceived -- handles incoming messages\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"void %s::MessageReceived (BMessage *message)\n",AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tswitch(message->what)\n",f);
	x = fputs("\t{\n",f);
	x = fputs("\t\tdefault:\n",f);
	x = fputs("\t\t\tBApplication::MessageReceived(message); // pass it along ... \n",f);
	x = fputs("\t\t\tbreak;\n",f);
	x = fputs("\t}\n",f);
	x = fputs("}\n",f);
	x = fputs("// ------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %s Main\n",AppName);
	x = fputs(tmp,f);
	x = fputs("int main(void)\n",f);
	x = fputs("{\n",f);
	sprintf(tmp,"\t%s theApp;\n",AppName);
	x = fputs(tmp,f);
	x = fputs("\ttheApp.Run();\n",f);
	x = fputs("\treturn 0;\n",f);
	x = fputs("}\n",f);
	x = fputs("// end --------------------------------------------------------------------------------------------- //\n\n",f);
	fclose(f);
	
	// Window CPP
	sprintf(FileName,"%s/projects/%s/%sWindow.cpp",apath,AppName,AppName);
	f = fopen(FileName,"w");
	x = fputs("/*\n\n",f);
	sprintf(tmp,"%sWindow\n\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"Author: %s\n\n",txtAuthor->Text());
	x = fputs(tmp,f);
	x = fputs("(C)2003 Created using BRIE (http://brie.sf.net/)\n\n",f);
	x = fputs("*/\n\n",f);
	x = fputs("// Includes ------------------------------------------------------------------------------------------ //\n",f);
	x = fputs("#include <Alert.h>\n",f);
	x = fputs("#include <Application.h>\n",f);
	x = fputs("#include <Button.h>\n",f);
	
	// add load/save pref (if checked)
	if (chkLoadSavePrefs->Value() == B_CONTROL_ON) {
		x = fputs("#include <File.h>\n",f);
		x = fputs("#include <FindDirectory.h>\n",f);
	}	
	
	// add menubar includes (if checked)
	if (chkMenuBar->Value() == B_CONTROL_ON) {
		x = fputs("#include <MenuBar.h>\n",f);
		x = fputs("#include <Menu.h>\n",f);
		x = fputs("#include <MenuItem.h>\n",f);
	}
	
	x = fputs("#include <Path.h>\n",f);
	x = fputs("#include <Screen.h>\n",f);
	x = fputs("#include <ScrollView.h>\n",f);
	x = fputs("#include <stdio.h>\n",f);
	x = fputs("#include <string.h>\n",f);
	x = fputs("#include <TextControl.h>\n",f);
	x = fputs("#include <Window.h>\n",f);
	x = fputs("#include <View.h>\n\n",f);
	sprintf(tmp,"#include \"%s.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sWindows.h\"\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"#include \"%sViews.h\"\n",AppName);
	x = fputs(tmp,f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	x = fputs("// CenterWindowOnScreen -- Centers the BWindow to the Current Screen\n",f);
	x = fputs("static void CenterWindowOnScreen(BWindow* w)\n",f);
	x = fputs("{\n",f);
	x = fputs("\tBRect\tscreenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame());",f);
	x = fputs("\tBPoint\tpt;\n",f);
	x = fputs("\tpt.x = screenFrame.Width()/2 - w->Bounds().Width()/2;\n",f);
	x = fputs("\tpt.y = screenFrame.Height()/2 - w->Bounds().Height()/2;\n\n",f);
	x = fputs("\tif (screenFrame.Contains(pt))\n",f);
	x = fputs("\t\tw->MoveTo(pt);\n",f);
	x = fputs("}\n",f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %sWindow - Constructor\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"%sWindow::%sWindow(BRect frame) : BWindow (frame, \"%s v0.1\", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0)\n",AppName,AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tInitWindow();\n",f);
	x = fputs("\tCenterWindowOnScreen(this);\n",f);
	
	// add load/save pref (if checked)
	if (chkLoadSavePrefs->Value() == B_CONTROL_ON) {
		x = fputs("\n",f);
		x = fputs("\t// Load User Settings \n",f);
		x = fputs("\tBPath path;\n",f);
		x = fputs("\tfind_directory(B_USER_SETTINGS_DIRECTORY,&path);\n",f);
		sprintf(tmp,"\tpath.Append(\"%s_Settings\",true);\n",AppName);
		x = fputs(tmp,f);
		x = fputs("\tBFile file(path.Path(),B_READ_ONLY);\n",f);
		x = fputs("\tBMessage msg;\n",f);
		x = fputs("\tmsg.Unflatten(&file);\n",f);
		x = fputs("\tLoadSettings (&msg);\n",f);
		x = fputs("\n",f);
    }
	
	x = fputs("\tShow();\n",f);
	x = fputs("}\n",f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %sWindow - Destructor\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"%sWindow::~%sWindow()\n",AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\texit(0);\n",f);
	x = fputs("}\n",f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %sWindow::InitWindow -- Initialization Commands here\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"void %sWindow::InitWindow(void)\n",AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tBRect r;\n",f);
	x = fputs("\tr = Bounds(); // the whole view\n",f);
		
	// add MenuBar (if checked)
	if (chkMenuBar->Value() == B_CONTROL_ON) {
		ptrMenuCreator = new MenuCreator(BRect(367.0, 268.0, 657.0, 500.0));
		x = fputs("\n",f);
		x = fputs("\t// MenuBar - Created by BRIE Menu Creator\n",f);
		x = fputs("\tBMenu *menu;\n",f);
		x = fputs("\tBRect rMenuBar;\n\n",f);
		x = fputs("\trMenuBar = Bounds();\n",f);
		x = fputs("\trMenuBar.top = 20;\n\n",f);
		x = fputs("\t// Add the menu bar\n",f);
		x = fputs("\trMenuBar.top = 0;\n",f);
		x = fputs("\trMenuBar.bottom = 19;\n",f);
		x = fputs("\tmenubar = new BMenuBar(rMenuBar, \"menu_bar\");\n",f);
		x = fputs("\tAddChild(menubar);\n",f);
		x = fputs("\n",f);
		x = fputs("\t// ### INSERT MENU HERE FROM MENU CREATOR ### \n",f);
		x = fputs("\n",f);
		x = fputs("\t// EndMenuBar (please do not remove this line)\n\n",f);
	}
	
	x = fputs("\t// Create the Views\n",f);
	sprintf(tmp,"\tAddChild(ptr%sView = new %sView(r));\n",AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("}\n",f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	sprintf(tmp,"// %sWindow::QuitRequested -- Post a message to the app to quit\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"bool %sWindow::QuitRequested()\n",AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	
	if (chkLoadSavePrefs->Value() == B_CONTROL_ON) {
		x = fputs("\tSaveSettings();\n",f);
	}
	
	x = fputs("\tbe_app->PostMessage(B_QUIT_REQUESTED);\n",f);
	x = fputs("\treturn true;\n",f);
	x = fputs("}\n",f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);	
	
	// add load/save pref (if checked)
	if (chkLoadSavePrefs->Value() == B_CONTROL_ON) {
		sprintf(tmp,"// %sWindow::LoadSettings -- Loads your current settings\n",AppName);
		x = fputs(tmp,f);
		sprintf(tmp,"void %sWindow::LoadSettings(BMessage *msg)\n",AppName);
		x = fputs(tmp,f);
		x = fputs("{\n",f);
		x = fputs("\tBRect frame;\n\n",f);
		x = fputs("\tif (B_OK == msg->FindRect(\"windowframe\",&frame)) {\n",f);
		x = fputs("\t\tMoveTo(frame.left,frame.top);\n",f);
		x = fputs("\t\tResizeTo(frame.right-frame.left,frame.bottom-frame.top);\n",f);
		x = fputs("\t}\n",f);
		x = fputs("}\n",f);
		x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);		

		sprintf(tmp,"// %sWindow::SaveSettings -- Saves the Users settings\n",AppName);
		x = fputs(tmp,f);
		sprintf(tmp,"void %sWindow::SaveSettings(void)\n",AppName);
		x = fputs(tmp,f);
		x = fputs("{\n",f);
		x = fputs("\tBMessage msg;\n",f);
		x = fputs("\tmsg.AddRect(\"windowframe\",Frame());\n\n",f);
		x = fputs("\tBPath path;\n",f);
		x = fputs("\tstatus_t result = find_directory(B_USER_SETTINGS_DIRECTORY,&path);\n",f);
		x = fputs("\tif (result == B_OK) {\n",f);
		sprintf(tmp,"\t\tpath.Append(\"%s_Settings\",true);\n",AppName);
		x = fputs(tmp,f);
		x = fputs("\t\tBFile file(path.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);\n",f);
		x = fputs("\t\tmsg.Flatten(&file);\n",f);
		
		x = fputs("\t}\n",f);
		x = fputs("}\n",f);
		x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);
	}
		
	sprintf(tmp,"// %sWindow::MessageReceived -- receives messages\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"void %sWindow::MessageReceived (BMessage *message)\n",AppName);
	x = fputs(tmp,f);
	x = fputs("{\n",f);
	x = fputs("\tswitch(message->what)\n",f);
	x = fputs("\t{\n",f);
	x = fputs("\t\tdefault:\n",f);
	x = fputs("\t\t\tBWindow::MessageReceived(message);\n",f);
	x = fputs("\t\t\tbreak;\n",f);
	x = fputs("\t}\n",f);
	x = fputs("}\n",f);
	x = fputs("// -------------------------------------------------------------------------------------------------- //\n\n",f);	
	fclose(f);
	
	// this step doesnt work - would be nice if rsrc files could be made from text
	// 4) Copy newproject.rsrc to our project folder
	//sprintf(cmd,"cp %s/newproject.rsrc %s/projects/%s/",apath,apath,AppName);
	//system(cmd);
	//sprintf(cmd,"mv %s/projects/%s/newproject.rsrc %s/projects/%s/%s.rsrc",apath,AppName,apath,AppName,AppName);
	//system(cmd);
	
	// 5) Create BRIE Project File - this is required for internal use in this application only
	sprintf(FileName,"%s/projects/%s.bprj",apath,AppName);
	f = fopen(FileName,"w");
	sprintf(tmp,"## BRIE Project File for %s ##\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"ProjectName=%s\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"ProjectDir=%s/projects/%s\n",apath,AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"Author=%s\n",txtAuthor->Text());
	x = fputs(tmp,f);
	sprintf(tmp,"Language=%s\n","C/C++"); // might change later ...
	x = fputs(tmp,f);
	x = fputs("### Files\n",f);
	sprintf(tmp,"%s.cpp\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"%sWindow.cpp\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"%sView.cpp\n",AppName);
	x = fputs(tmp,f);
	fclose(f);
	sprintf(tmp,"%s.bprj",AppName);
	//ptrFileWindow->SetProject(FileName,tmp);
	//ptrProjectWindow->SetProjectTitle(AppName);
	
	//msg = new BMessage(SET_PROJECT_NAME);
	//msg.AddString("ProjectName",AppName);
	//msg.AddBool("NotSaved",true);
	//ptrProjectWindow->PostMessage(&msg);
	
	// Create our ProjectFiles BMessage
	BMessage pfmsg(ADD_PROJECT_FILE);
	BString ProgName;
	ProgName.SetTo(AppName);
	ProgName.Append(".cpp");
	pfmsg.AddString(kProjectFile, ProgName.String());
	BMessenger(ptrProjectWindow).SendMessage(&pfmsg);
	
	pfmsg.MakeEmpty();
	ProgName.SetTo(AppName);
	ProgName.Append("Window.cpp");
	pfmsg.AddString(kProjectFile, ProgName.String());
	BMessenger(ptrProjectWindow).SendMessage(&pfmsg);
	
	pfmsg.MakeEmpty();
	ProgName.SetTo(AppName);
	ProgName.Append("View.cpp");
	pfmsg.AddString(kProjectFile, ProgName.String());
	BMessenger(ptrProjectWindow).SendMessage(&pfmsg);
	
	// 6) Create makefile for compilation
	sprintf(FileName,"%s/projects/%s/makefile",apath,AppName);
	f = fopen(FileName,"w");
	sprintf(tmp,"## BeOS Makefile for %s ##\n",AppName);
	x = fputs(tmp,f);
	sprintf(tmp,"## Author: %s\n",txtAuthor->Text());
	x = fputs(tmp,f);
	x = fputs("## Created by BRIE (http://brie.sf.net/)\n\n",f);
	x = fputs("## Application Specific Settings ---------------------------------------------\n\n",f);
	x = fputs("# specify the name of the binary\n",f);
	sprintf(tmp,"NAME= %s\n",AppName);
	x = fputs(tmp,f);
	x = fputs("# specify the type of binary\n",f);
	x = fputs("#	APP:	Application\n",f);
	x = fputs("#	SHARED:	Shared library or add-on\n",f);
	x = fputs("#	STATIC:	Static library archive\n",f);
	x = fputs("#	DRIVER: Kernel Driver\n",f);
	x = fputs("TYPE= APP\n\n",f);
	x = fputs("#	specify the source files to use\n",f);
	x = fputs("#	Note that spaces in folder names do not work well with this makefile.\n",f);
	sprintf(tmp,"SRCS= %s.cpp %sWindow.cpp %sView.cpp\n",AppName,AppName,AppName);
	x = fputs(tmp,f);
	x = fputs("# end of srcs\n\n",f);
	x = fputs("#	specify the resource files to use\n",f);
	//x = fputs("RSRCS= ../../newproject.rsrc\n\n",f);
	x = fputs("RSRCS= \n\n",f);
	x = fputs("#	specify additional libraries to link against\n",f);
	x = fputs("LIBS= be root\n\n",f);
	x = fputs("#	specify additional paths to directories \n",f);
	x = fputs("LIBPATHS=\n\n",f);
	x = fputs("#	additional paths to look for system headers\n",f);
	x = fputs("SYSTEM_INCLUDE_PATHS =\n\n",f);
	x = fputs("#	additional paths to look for local headers\n",f);
	x = fputs("LOCAL_INCLUDE_PATHS =\n\n",f);
	x = fputs("#	specify the level of optimization that you desire - NONE, SOME, FULL\n",f);
	x = fputs("OPTIMIZE=\n\n",f);
	x = fputs("#	specify any preprocessor symbols to be defined.  \n",f);
	x = fputs("DEFINES=\n\n",f);
	x = fputs("#	specify special warning levels - NONE, ALL\n",f);
	x = fputs("WARNINGS = ALL\n\n",f);
	x = fputs("#	specify whether image symbols will be created\n",f);
	x = fputs("SYMBOLS = TRUE\n\n",f);
	x = fputs("#	specify debug settings\n",f);
	x = fputs("DEBUGGER =\n\n",f);
	x = fputs("#	specify additional compiler flags for all files\n",f);	
	x = fputs("COMPILER_FLAGS =\n\n",f);
	x = fputs("#	specify additional linker flags\n",f);
	x = fputs("LINKER_FLAGS =\n\n",f);
	x = fputs("## include the makefile-engine\n",f);
	x = fputs("DEVEL_DIRECTORY := \\\n",f);
	x = fputs("\t$(shell findpaths -r \"makefile_engine\" B_FIND_PATH_DEVELOP_DIRECTORY)",f);
	x = fputs("include $(DEVEL_DIRECTORY)/etc/makefile-engine",f);
	fclose(f);
	
	// 7) Send Messages to other Windows to update
	BMessage msg(SET_PROJECT_TITLE);
	msg.AddString(kProjectName, AppName);
	//msg.AddBool(kNotSaved, true); // make this false later - true for debug purposes
	BMessenger(ptrFileWindow).SendMessage(&msg);
	BMessenger(ptrProjectWindow).SendMessage(&msg);
	ProjectName.SetTo(AppName);
	ProjectPath = apath;
	
	// set properties window to show current Window from New Project
	ptrPropertiesWindow->ShowProperties("Window",ProjectName.String());
		
	// 8) Show Tracker and/or Continue
	ShowTracker(apath,AppName);
}